CMS 3D CMS Logo

Namespaces | Functions
gs Namespace Reference

Namespaces

 Private
 

Functions

std::string fileDirname (const char *filename)
 
std::string fileTail (const char *filename)
 
std::string joinDir1WithName2 (const char *fname1, const char *fname2)
 
StringArchive * loadStringArchiveFromArchive (AbsArchive &arch, const unsigned long long id)
 
std::string localFileURI (const char *filename)
 
StringArchive * readCompressedStringArchive (const char *filename)
 
StringArchive * readCompressedStringArchiveExt (const char *filename, const char *suffix)
 
StringArchive * readStringArchive (const char *filename)
 
bool writeBinaryCatalog (std::ostream &os, const unsigned compressionCode, const unsigned mergeLevel, const std::vector< std::string > &annotations, const AbsCatalog &catalog, const unsigned formatId)
 
bool writeCompressedStringArchive (const StringArchive &ar, const char *filename, const unsigned inCompressionMode, const int compressionLevel, const unsigned minSizeToCompress, const unsigned bufSize)
 
bool writeCompressedStringArchiveExt (const StringArchive &ar, const char *filename, const char *suffix)
 
bool writeStringArchive (const StringArchive &ar, const char *filename)
 

Function Documentation

std::string gs::fileDirname ( const char *  filename)

Definition at line 31 of file uriUtils.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by joinDir1WithName2().

32  {
33  assert(filename);
34  const char *progname = std::strrchr(filename, '/');
35  if (progname)
36  return std::string(filename, progname - filename);
37  else
38  return std::string(".");
39  }
std::string gs::fileTail ( const char *  filename)

Definition at line 20 of file uriUtils.cc.

References corrVsCorr::filename, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by joinDir1WithName2().

21  {
22  assert(filename);
23  const char *progname = std::strrchr(filename, '/');
24  if (progname)
25  ++progname;
26  else
27  progname = filename;
28  return std::string(progname);
29  }
std::string gs::joinDir1WithName2 ( const char *  fname1,
const char *  fname2 
)

Definition at line 41 of file uriUtils.cc.

References fileDirname(), fileTail(), and AlCaHLTBitMon_QueryRunRegistry::string.

42  {
43  std::string res(fileDirname(fname1));
44  res += '/';
45  res += fileTail(fname2);
46  return res;
47  }
Definition: Electron.h:6
std::string fileDirname(const char *filename)
Definition: uriUtils.cc:31
std::string fileTail(const char *filename)
Definition: uriUtils.cc:20
StringArchive* gs::loadStringArchiveFromArchive ( AbsArchive &  arch,
const unsigned long long  id 
)

Definition at line 90 of file stringArchiveIO.cc.

References AlCaHLTBitMon_ParallelJobs::p.

92  {
93  Reference<StringArchive> ref(arch, id);
94  if (!ref.unique())
95  {
96  std::ostringstream os;
97  os << "In gs::loadStringArchiveFromArchive: "
98  << "StringArchive item with id " << id << " not found";
99  throw gs::IOInvalidArgument(os.str());
100  }
101  CPP11_auto_ptr<StringArchive> p = ref.get(0);
102  return p.release();
103  }
std::string gs::localFileURI ( const char *  filename)

Definition at line 8 of file uriUtils.cc.

References corrVsCorr::filename, and AlCaHLTBitMon_QueryRunRegistry::string.

9  {
10  assert(filename);
11  if (strlen(filename) == 0) throw gs::IOInvalidArgument(
12  "In gs::localFileURI: empty file name");
13  std::string uri("file://");
14  if (filename[0] != '/')
15  uri += "./";
16  uri += filename;
17  return uri;
18  }
StringArchive* gs::readCompressedStringArchive ( const char *  filename)

Definition at line 79 of file stringArchiveIO.cc.

Referenced by readCompressedStringArchiveExt().

80  {
81  assert(filename);
82  std::ifstream is(filename, std::ios_base::binary);
83  if (!is.is_open())
84  throw IOOpeningFailure("gs::readCompressedStringArchive", filename);
85  CPP11_auto_ptr<StringArchive> ar =
86  read_compressed_item<StringArchive>(is);
87  return ar.release();
88  }
StringArchive* gs::readCompressedStringArchiveExt ( const char *  filename,
const char *  suffix 
)

Definition at line 105 of file stringArchiveIO.cc.

References readCompressedStringArchive(), readStringArchive(), and suffix_matches().

107  {
110  else
111  return readStringArchive(filename);
112  }
static bool suffix_matches(const char *filename, const char *suffix)
StringArchive * readCompressedStringArchive(const char *filename)
StringArchive * readStringArchive(const char *filename)
StringArchive* gs::readStringArchive ( const char *  filename)

Definition at line 44 of file stringArchiveIO.cc.

Referenced by readCompressedStringArchiveExt().

45  {
46  assert(filename);
47  std::ifstream is(filename, std::ios_base::binary);
48  if (!is.is_open())
49  throw IOOpeningFailure("gs::readStringArchive", filename);
50  CPP11_auto_ptr<StringArchive> ar = read_item<StringArchive>(is);
51  return ar.release();
52  }
bool gs::writeBinaryCatalog ( std::ostream &  os,
const unsigned  compressionCode,
const unsigned  mergeLevel,
const std::vector< std::string > &  annotations,
const AbsCatalog &  catalog,
const unsigned  formatId 
)

Definition at line 4 of file CatalogIO.cc.

8  {
9  os.seekp(0, std::ios_base::beg);
10 
11  const unsigned endianness = 0x01020304;
12  const unsigned char sizelong = sizeof(long);
13 
14  write_pod(os, formatId);
15  write_pod(os, endianness);
16  write_pod(os, sizelong);
17  write_pod(os, compressionCode);
18  write_pod(os, mergeLevel);
19  write_pod_vector(os, annotations);
20 
21  return !os.fail() &&
22  catalog.classId().write(os) && catalog.write(os);
23  }
bool gs::writeCompressedStringArchive ( const StringArchive &  ar,
const char *  filename,
const unsigned  inCompressionMode,
const int  compressionLevel,
const unsigned  minSizeToCompress,
const unsigned  bufSize 
)

Definition at line 54 of file stringArchiveIO.cc.

References funct::m, and mps_update::status.

Referenced by writeCompressedStringArchiveExt().

58  {
59  assert(filename);
60  if (inCompressionMode > CStringStream::BZIP2)
61  throw gs::IOInvalidArgument(
62  "In gs::writeCompressedStringArchive: "
63  "compression mode argument out of range");
64  const CStringStream::CompressionMode m =
65  static_cast<CStringStream::CompressionMode>(inCompressionMode);
66  bool status = false;
67  {
68  std::ofstream of(filename, std::ios_base::binary);
69  if (of.is_open())
70  {
71  const_cast<StringArchive&>(ar).flush();
72  status = write_compressed_item(of, ar, m, compressionLevel,
73  minSizeToCompress, bufSize);
74  }
75  }
76  return status;
77  }
static int const bufSize
Definition: Guid.cc:24
bool gs::writeCompressedStringArchiveExt ( const StringArchive &  ar,
const char *  filename,
const char *  suffix 
)

Definition at line 114 of file stringArchiveIO.cc.

References suffix_matches(), writeCompressedStringArchive(), and writeStringArchive().

117  {
120  else
121  return writeStringArchive(ar, filename);
122  }
static bool suffix_matches(const char *filename, const char *suffix)
bool writeCompressedStringArchive(const StringArchive &ar, const char *filename, const unsigned inCompressionMode, const int compressionLevel, const unsigned minSizeToCompress, const unsigned bufSize)
bool writeStringArchive(const StringArchive &ar, const char *filename)
bool gs::writeStringArchive ( const StringArchive &  ar,
const char *  filename 
)

Definition at line 29 of file stringArchiveIO.cc.

References mps_update::status.

Referenced by writeCompressedStringArchiveExt().

30  {
31  assert(filename);
32  bool status = false;
33  {
34  std::ofstream of(filename, std::ios_base::binary);
35  if (of.is_open())
36  {
37  const_cast<StringArchive&>(ar).flush();
38  status = write_item(of, ar);
39  }
40  }
41  return status;
42  }