3 #include "Alignment/Geners/interface/IOException.hh"
5 #include "Alignment/Geners/interface/StringArchive.hh"
6 #include "Alignment/Geners/interface/streamposIO.hh"
11 std::vector<unsigned long long> idlist;
12 catalog_.search(reference.namePattern(),
13 reference.categoryPattern(),
15 const unsigned long nfound = idlist.size();
16 for (
unsigned long i=0;
i<nfound; ++
i)
18 CPP11_shared_ptr<const CatalogEntry> pentry =
19 catalog_.retrieveEntry(idlist[
i]);
20 if (reference.isIOCompatible(*pentry))
21 addItemToReference(reference, idlist[i]);
25 std::istream& StringArchive::inputStream(
const unsigned long long id)
27 if (!
id)
throw gs::IOInvalidArgument(
28 "In gs::StringArchive::inputStream: invalid item id");
31 unsigned long long itemLen;
32 if (!catalog_.retrieveStreampos(
id, &cCode, &itemLen, &pos))
34 std::ostringstream os;
35 os <<
"In gs::StringArchive::inputStream: "
36 <<
"failed to locate item with id " << id;
37 throw gs::IOInvalidArgument(os.str());
43 bool StringArchive::isEqual(
const AbsArchive& cata)
const
45 const StringArchive&
r =
static_cast<const StringArchive&
>(cata);
46 return lastpos_ == r.lastpos_ &&
48 stream_ == r.stream_ &&
49 catalog_ == r.catalog_;
54 write_pod(of, lastpos_);
55 write_pod(of,
name());
57 stream_.classId().write(of) &&
59 catalog_.classId().write(of) &&
65 static const ClassId
current(ClassId::makeId<StringArchive>());
68 std::streampos lastpos;
69 read_pod(in, &lastpos);
72 if (in.fail())
throw IOReadFailure(
73 "In gs::StringArchive::read: input stream failure");
74 CPP11_auto_ptr<StringArchive> archive(
new StringArchive(nam.c_str()));
75 archive->lastpos_ = lastpos;
76 ClassId streamId(in, 1);
77 CharBuffer::restore(streamId, in, &archive->stream_);
81 archive->catalog_ = *
p;
82 return archive.release();