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

◆ fileDirname()

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

Definition at line 29 of file uriUtils.cc.

References cms::cuda::assert(), corrVsCorr::filename, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by joinDir1WithName2().

29  {
31  const char *progname = std::strrchr(filename, '/');
32  if (progname)
33  return std::string(filename, progname - filename);
34  else
35  return std::string(".");
36  }
assert(be >=bs)

◆ fileTail()

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

Definition at line 19 of file uriUtils.cc.

References cms::cuda::assert(), corrVsCorr::filename, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by joinDir1WithName2().

19  {
21  const char *progname = std::strrchr(filename, '/');
22  if (progname)
23  ++progname;
24  else
25  progname = filename;
26  return std::string(progname);
27  }
assert(be >=bs)

◆ joinDir1WithName2()

std::string gs::joinDir1WithName2 ( const char *  fname1,
const char *  fname2 
)

Definition at line 38 of file uriUtils.cc.

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

38  {
39  std::string res(fileDirname(fname1));
40  res += '/';
41  res += fileTail(fname2);
42  return res;
43  }
Definition: Electron.h:6
std::string fileDirname(const char *filename)
Definition: uriUtils.cc:29
std::string fileTail(const char *filename)
Definition: uriUtils.cc:19

◆ loadStringArchiveFromArchive()

StringArchive* gs::loadStringArchiveFromArchive ( AbsArchive &  arch,
const unsigned long long  id 
)

Definition at line 80 of file stringArchiveIO.cc.

References makeMEIFBenchmarkPlots::arch, and AlCaHLTBitMon_ParallelJobs::p.

80  {
81  Reference<StringArchive> ref(arch, id);
82  if (!ref.unique()) {
83  std::ostringstream os;
84  os << "In gs::loadStringArchiveFromArchive: "
85  << "StringArchive item with id " << id << " not found";
86  throw gs::IOInvalidArgument(os.str());
87  }
88  std::unique_ptr<StringArchive> p = ref.get(0);
89  return p.release();
90  }

◆ localFileURI()

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

Definition at line 8 of file uriUtils.cc.

References cms::cuda::assert(), corrVsCorr::filename, and AlCaHLTBitMon_QueryRunRegistry::string.

8  {
10  if (strlen(filename) == 0)
11  throw gs::IOInvalidArgument("In gs::localFileURI: empty file name");
12  std::string uri("file://");
13  if (filename[0] != '/')
14  uri += "./";
15  uri += filename;
16  return uri;
17  }
assert(be >=bs)

◆ readCompressedStringArchive()

StringArchive* gs::readCompressedStringArchive ( const char *  filename)

Definition at line 71 of file stringArchiveIO.cc.

References cms::cuda::assert(), and corrVsCorr::filename.

Referenced by readCompressedStringArchiveExt().

71  {
73  std::ifstream is(filename, std::ios_base::binary);
74  if (!is.is_open())
75  throw IOOpeningFailure("gs::readCompressedStringArchive", filename);
76  std::unique_ptr<StringArchive> ar = read_compressed_item<StringArchive>(is);
77  return ar.release();
78  }
assert(be >=bs)

◆ readCompressedStringArchiveExt()

StringArchive* gs::readCompressedStringArchiveExt ( const char *  filename,
const char *  suffix 
)

Definition at line 92 of file stringArchiveIO.cc.

References corrVsCorr::filename, readCompressedStringArchive(), readStringArchive(), makePlotsFromDump::suffix, and suffix_matches().

92  {
95  else
97  }
static bool suffix_matches(const char *filename, const char *suffix)
StringArchive * readCompressedStringArchive(const char *filename)
StringArchive * readStringArchive(const char *filename)

◆ readStringArchive()

StringArchive* gs::readStringArchive ( const char *  filename)

Definition at line 39 of file stringArchiveIO.cc.

References cms::cuda::assert(), and corrVsCorr::filename.

Referenced by readCompressedStringArchiveExt().

39  {
41  std::ifstream is(filename, std::ios_base::binary);
42  if (!is.is_open())
43  throw IOOpeningFailure("gs::readStringArchive", filename);
44  std::unique_ptr<StringArchive> ar = read_item<StringArchive>(is);
45  return ar.release();
46  }
assert(be >=bs)

◆ writeBinaryCatalog()

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.

References getEcalConditions_orcoffint2r_cff::catalog.

9  {
10  os.seekp(0, std::ios_base::beg);
11 
12  const unsigned endianness = 0x01020304;
13  const unsigned char sizelong = sizeof(long);
14 
15  write_pod(os, formatId);
16  write_pod(os, endianness);
17  write_pod(os, sizelong);
18  write_pod(os, compressionCode);
19  write_pod(os, mergeLevel);
20  write_pod_vector(os, annotations);
21 
22  return !os.fail() && catalog.classId().write(os) && catalog.write(os);
23  }

◆ writeCompressedStringArchive()

bool gs::writeCompressedStringArchive ( const StringArchive &  ar,
const char *  filename,
const unsigned  inCompressionMode,
const int  compressionLevel,
const unsigned  minSizeToCompress,
const unsigned  bufSize 
)

Definition at line 48 of file stringArchiveIO.cc.

References cms::cuda::assert(), NanoAODEDMEventContent_cff::compressionLevel, corrVsCorr::filename, visualization-live-secondInstance_cfg::m, haddnano::of, and mps_update::status.

Referenced by writeCompressedStringArchiveExt().

53  {
55  if (inCompressionMode > CStringStream::BZIP2)
56  throw gs::IOInvalidArgument(
57  "In gs::writeCompressedStringArchive: "
58  "compression mode argument out of range");
59  const CStringStream::CompressionMode m = static_cast<CStringStream::CompressionMode>(inCompressionMode);
60  bool status = false;
61  {
62  std::ofstream of(filename, std::ios_base::binary);
63  if (of.is_open()) {
64  const_cast<StringArchive &>(ar).flush();
65  status = write_compressed_item(of, ar, m, compressionLevel, minSizeToCompress, bufSize);
66  }
67  }
68  return status;
69  }
assert(be >=bs)

◆ writeCompressedStringArchiveExt()

bool gs::writeCompressedStringArchiveExt ( const StringArchive &  ar,
const char *  filename,
const char *  suffix 
)

Definition at line 99 of file stringArchiveIO.cc.

References corrVsCorr::filename, makePlotsFromDump::suffix, suffix_matches(), writeCompressedStringArchive(), and writeStringArchive().

99  {
102  else
103  return writeStringArchive(ar, filename);
104  }
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)

◆ writeStringArchive()

bool gs::writeStringArchive ( const StringArchive &  ar,
const char *  filename 
)

Definition at line 26 of file stringArchiveIO.cc.

References cms::cuda::assert(), corrVsCorr::filename, haddnano::of, and mps_update::status.

Referenced by writeCompressedStringArchiveExt().

26  {
28  bool status = false;
29  {
30  std::ofstream of(filename, std::ios_base::binary);
31  if (of.is_open()) {
32  const_cast<StringArchive &>(ar).flush();
33  status = write_item(of, ar);
34  }
35  }
36  return status;
37  }
assert(be >=bs)