CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
jsoncollector::FileIO Class Reference

#include <FileIO.h>

Static Public Member Functions

static bool fileExists (std::string &path)
 
static bool readStringFromFile (std::string &filename, std::string &content)
 
static void writeStringToFile (std::string &filename, std::string &content)
 

Detailed Description

Definition at line 15 of file FileIO.h.

Member Function Documentation

bool FileIO::fileExists ( std::string &  path)
static

Checks if path points to an existing file

Definition at line 50 of file FileIO.cc.

References compare_using_db::ifile.

Referenced by readStringFromFile().

50  {
51  ifstream ifile(path.c_str());
52  return ifile;
53 }
bool FileIO::readStringFromFile ( std::string &  filename,
std::string &  content 
)
static

Reads string from specified path, returns false if file does not exist

Definition at line 33 of file FileIO.cc.

References end, fileExists(), and analyzePatCleaning_cfg::inputFile.

Referenced by jsoncollector::ObjectMerger::getDataPointDefinitionFor().

33  {
34  if (!fileExists(filename))
35  return false;
36 
37  std::ifstream inputFile(filename.c_str());
38 
39  inputFile.seekg(0, std::ios::end);
40  content.reserve(inputFile.tellg());
41  inputFile.seekg(0, std::ios::beg);
42 
43  content.assign((std::istreambuf_iterator<char>(inputFile)),
44  std::istreambuf_iterator<char>());
45 
46  inputFile.close();
47  return true;
48 }
static bool fileExists(std::string &path)
Definition: FileIO.cc:50
#define end
Definition: vmac.h:37
tuple filename
Definition: lut2db_cfg.py:20
void FileIO::writeStringToFile ( std::string &  filename,
std::string &  content 
)
static

Writes given string to specified file path

Definition at line 26 of file FileIO.cc.

References ws_sso_content_reader::content, and download_sqlite_cfg::outputFile.

Referenced by jsoncollector::FastMonitor::outputFullHistoDataPoint().

26  {
27  ofstream outputFile;
28  outputFile.open(filename.c_str());
29  outputFile << content;
30  outputFile.close();
31 }
tuple filename
Definition: lut2db_cfg.py:20