CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::FileReader Class Reference

#include <FileUtils.h>

Public Member Functions

const std::string & content () const
 
 FileReader ()
 
bool read (const std::string &fileName)
 
virtual ~FileReader ()
 

Private Attributes

std::string m_content
 

Detailed Description

Definition at line 7 of file FileUtils.h.

Constructor & Destructor Documentation

cond::FileReader::FileReader ( )
inline

Definition at line 27 of file FileUtils.h.

27  :m_content(""){
28 }
std::string m_content
Definition: FileUtils.h:21
virtual cond::FileReader::~FileReader ( )
inlinevirtual

Member Function Documentation

const std::string & cond::FileReader::content ( ) const
inline

Definition at line 31 of file FileUtils.h.

References m_content.

Referenced by cond::XMLAuthenticationService::XMLAuthenticationService::processFile(), and ~FileReader().

31  {
32  return m_content;
33 }
std::string m_content
Definition: FileUtils.h:21
bool cond::FileReader::read ( const std::string &  fileName)

Definition at line 6 of file FileUtils.cc.

References edmScanValgrind::buffer, end, recoMuon::in, analyzePatCleaning_cfg::inputFile, m_content, mps_check::msg, and findQualityFiles::size.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), cond::XMLAuthenticationService::XMLAuthenticationService::processFile(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches(), and ~FileReader().

6  {
7  std::ifstream inputFile;
8  inputFile.open (fileName.c_str());
9  if(!inputFile.good()){
10  std::stringstream msg;
11  msg << "File \"" << fileName << "\" cannot be open.";
12  inputFile.close();
13  throw cond::Exception(msg.str());
14  }
15  // get pointer to associated buffer object
16  std::filebuf* pbuf=inputFile.rdbuf();
17  // get file size using buffer's members
18  long size=pbuf->pubseekoff (0,std::ios::end,std::ios::in);
19  pbuf->pubseekpos (0,std::ios::in);
20  // allocate memory to contain file data
21  char* buffer=new char[size+1];
22  // get file data
23  pbuf->sgetn (buffer,size);
24  inputFile.close();
25  buffer[size]=0;
26  m_content += buffer;
27  delete [] buffer;
28  return true;
29 }
persistency::Exception Exception
Definition: Exception.h:25
size
Write out results.
std::string m_content
Definition: FileUtils.h:21
#define end
Definition: vmac.h:39
tuple msg
Definition: mps_check.py:278

Member Data Documentation

std::string cond::FileReader::m_content
private

Definition at line 21 of file FileUtils.h.

Referenced by content(), and read().