Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:53

0001 #ifndef CondFormats_FileBlob_h
0002 #define CondFormats_FileBlob_h
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <vector>
0007 #include <string>
0008 #include <iostream>
0009 #include <memory>
0010 
0011 class FileBlob {
0012 public:
0013   FileBlob() {
0014     compressed = false;
0015     isize = 0;
0016   };
0017   /// constructor from file to read
0018   FileBlob(const std::string &fname, bool zip);
0019   /// constructor from  stream to read
0020   FileBlob(std::istream &is, bool zip);
0021 
0022   ~FileBlob(){};
0023 
0024   /// read from real file
0025   void read(const std::string &);
0026   /// write to real file
0027   void write(const std::string &) const;
0028 
0029   /// read from istream
0030   void read(std::istream &);
0031   /// write to ostream
0032   void write(std::ostream &) const;
0033 
0034   bool isCompressed() const { return compressed; };
0035 
0036   int size() const { return isize; };
0037     /// i didn't want to do two copies ... hope this works.
0038 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0039   std::unique_ptr<std::vector<unsigned char> > getUncompressedBlob() const;
0040 #endif
0041   void getUncompressedBlob(std::vector<unsigned char> &myblobcopy) const;
0042 
0043 private:
0044   static unsigned int computeFileSize(const std::string &);
0045   static unsigned int computeStreamSize(std::istream &);
0046 
0047   std::vector<unsigned char> blob;
0048   bool compressed;
0049   unsigned int isize;
0050 
0051   COND_SERIALIZABLE;
0052 };
0053 
0054 #endif