File indexing completed on 2024-04-06 11:56:21
0001 #include "Alignment/Geners/interface/IOException.hh"
0002 #include "Alignment/Geners/interface/ItemLocation.hh"
0003 #include "Alignment/Geners/interface/streamposIO.hh"
0004
0005 namespace gs {
0006 bool ItemLocation::operator==(const ItemLocation &r) const {
0007 if (pos_ != r.pos_)
0008 return false;
0009 if (URI_ != r.URI_)
0010 return false;
0011
0012
0013 if (!URI_.empty()) {
0014 if (!cachedItemURI_.empty() && !r.cachedItemURI_.empty())
0015 if (cachedItemURI_ != r.cachedItemURI_)
0016 return false;
0017 } else if (cachedItemURI_ != r.cachedItemURI_)
0018 return false;
0019 return true;
0020 }
0021
0022 bool ItemLocation::write(std::ostream &of) const {
0023
0024
0025
0026 write_pod(of, pos_);
0027 write_pod(of, URI_);
0028 write_pod(of, cachedItemURI_);
0029 return !of.fail();
0030 }
0031
0032 ItemLocation *ItemLocation::read(const ClassId &id, std::istream &in) {
0033 static const ClassId current(ClassId::makeId<ItemLocation>());
0034 current.ensureSameId(id);
0035
0036 std::streampos pos;
0037 read_pod(in, &pos);
0038
0039 std::string globURI;
0040 read_pod(in, &globURI);
0041
0042 std::string cachedItemURI;
0043 read_pod(in, &cachedItemURI);
0044
0045 if (in.fail())
0046 throw IOReadFailure("In ItemLocation::read: input stream failure");
0047
0048 return new ItemLocation(pos, globURI.c_str(), cachedItemURI.c_str());
0049 }
0050 }