Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:54

0001 //=========================================================================
0002 // streamposIO.hh
0003 //
0004 // Specialize read_pod and write_pod so that they also
0005 // work with std::streampos.
0006 //
0007 // The code for storing the stream offset is necessarily
0008 // going to be implementation-dependent. The C++ standard
0009 // does not specify std::streampos with enough detail.
0010 //
0011 // I. Volobouev
0012 // March 2011
0013 //=========================================================================
0014 
0015 #ifndef GENERS_STREAMPOSIO_HH_
0016 #define GENERS_STREAMPOSIO_HH_
0017 
0018 #include "Alignment/Geners/interface/binaryIO.hh"
0019 
0020 namespace gs {
0021   template <>
0022   inline void write_pod<std::streampos>(std::ostream &of, const std::streampos &s) {
0023     std::streamoff off(s);
0024     long long loc = off;
0025     write_pod(of, loc);
0026   }
0027 
0028   template <>
0029   inline void read_pod<std::streampos>(std::istream &in, std::streampos *ps) {
0030     assert(ps);
0031     long long loc = 0LL;
0032     read_pod(in, &loc);
0033     std::streamoff off(loc);
0034     *ps = std::streampos(off);
0035   }
0036 
0037   template <>
0038   inline void write_pod_array<std::streampos>(std::ostream &of, const std::streampos *pod, const unsigned long len) {
0039     if (len) {
0040       assert(pod);
0041       for (unsigned long i = 0; i < len; ++i)
0042         write_pod(of, pod[i]);
0043     }
0044   }
0045 
0046   template <>
0047   inline void read_pod_array<std::streampos>(std::istream &in, std::streampos *pod, const unsigned long len) {
0048     if (len) {
0049       assert(pod);
0050       for (unsigned long i = 0; i < len; ++i)
0051         read_pod(in, pod + i);
0052     }
0053   }
0054 }  // namespace gs
0055 
0056 #endif  // GENERS_STREAMPOSIO_HH_