Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:21

0001 #include "Alignment/Geners/interface/ColumnBuffer.hh"
0002 #include "Alignment/Geners/interface/streamposIO.hh"
0003 
0004 namespace gs {
0005   namespace Private {
0006     bool ColumnBuffer::write(std::ostream &os) const {
0007       write_pod(os, firstrow);
0008       write_pod(os, lastrowp1);
0009       const unsigned char isPod = (podsize ? 1 : 0);
0010       write_pod(os, isPod);
0011       if (isPod)
0012         write_pod(os, podsize);
0013       else
0014         write_pod_vector(os, offsets);
0015       return !os.fail() && buf.write(os);
0016     }
0017 
0018     void ColumnBuffer::restore(const ClassId &id, const ClassId &bufId, std::istream &is, ColumnBuffer *obj) {
0019       assert(obj);
0020       obj->classId().ensureSameId(id);
0021 
0022       read_pod(is, &obj->firstrow);
0023       read_pod(is, &obj->lastrowp1);
0024       unsigned char isPod;
0025       read_pod(is, &isPod);
0026       if (isPod) {
0027         obj->offsets.clear();
0028         read_pod(is, &obj->podsize);
0029       } else {
0030         obj->podsize = 0;
0031         read_pod_vector(is, &obj->offsets);
0032       }
0033       if (is.fail())
0034         throw IOReadFailure("In gs::Private::ColumnBuffer::restore: input stream failure");
0035 
0036       // Size of a POD object can not be zero
0037       if (isPod && !obj->podsize)
0038         throw IOInvalidData("In gs::Private::ColumnBuffer::restore: corrupted record");
0039 
0040       CharBuffer::restore(bufId, is, &obj->buf);
0041     }
0042 
0043     bool ColumnBuffer::operator==(const ColumnBuffer &r) const {
0044       return firstrow == r.firstrow && lastrowp1 == r.lastrowp1 && podsize == r.podsize && offsets == r.offsets &&
0045              buf == r.buf;
0046     }
0047 
0048     const ClassId &ColumnBuffer::static_classId() {
0049       static const ClassId classId_(ClassId(classname(), version()));
0050       return classId_;
0051     }
0052   }  // namespace Private
0053 }  // namespace gs