test
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 const &path)
 
static bool readStringFromFile (std::string const &filename, std::string &content)
 
static void writeStringToFile (std::string const &filename, std::string &content)
 

Detailed Description

Definition at line 15 of file FileIO.h.

Member Function Documentation

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

Checks if path points to an existing file

Definition at line 43 of file FileIO.cc.

References compare_using_db::ifile.

Referenced by readStringFromFile().

44 {
45  std::ifstream ifile(path.c_str());
46  return ifile;
47 }
tuple path
else: Piece not in the list, fine.
bool FileIO::readStringFromFile ( std::string const &  filename,
std::string &  content 
)
static

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

Definition at line 29 of file FileIO.cc.

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

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

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

Writes given string to specified file path

Definition at line 21 of file FileIO.cc.

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

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

22 {
23  std::ofstream outputFile;
24  outputFile.open(filename.c_str());
25  outputFile << content;
26  outputFile.close();
27 }
tuple filename
Definition: lut2db_cfg.py:20