Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
JEEP::JProperties::JFileReader Class Reference

Auxiliary class to handle input from file. More...

#include <JProperties.hh>

Public Member Functions

 JFileReader (JProperties &__properties)
 
JFileReaderoperator= (const std::string &file_name)
 Assignment operator. More...
 

Private Member Functions

void read (const std::string &file_name)
 Read properties from file. More...
 

Private Attributes

JPropertiesproperties
 

Friends

std::istream & operator>> (std::istream &in, JProperties::JFileReader &fileReader)
 Stream input. More...
 
std::ostream & operator<< (std::ostream &out, const JProperties::JFileReader &fileReader)
 Stream output. More...
 

Detailed Description

Auxiliary class to handle input from file.

The assignment of a value will cause the file with the corresponding name to be opened and read. The contents of the file are processed in the same way as any input to the associated JProperties object.

Definition at line 522 of file JProperties.hh.

Constructor & Destructor Documentation

JEEP::JProperties::JFileReader::JFileReader ( JProperties __properties)
inline

Definition at line 524 of file JProperties.hh.

524  :
525  properties(__properties)
526  {}

Member Function Documentation

JFileReader& JEEP::JProperties::JFileReader::operator= ( const std::string &  file_name)
inline

Assignment operator.

Parameters
file_namefile name
Returns
this JFileReader

Definition at line 535 of file JProperties.hh.

536  {
537  read(file_name);
538 
539  return *this;
540  }
void read(const std::string &file_name)
Read properties from file.
Definition: JProperties.hh:581
void JEEP::JProperties::JFileReader::read ( const std::string &  file_name)
inlineprivate

Read properties from file.

Parameters
file_namefile name

Definition at line 581 of file JProperties.hh.

582  {
583  std::ifstream in(file_name.c_str());
584 
585  if (!in) {
586  THROW(JFileOpenException, "JFileReader: error opening file " << file_name);
587  }
588 
589  properties.read(in);
590 
591  if (in.bad()) {
592  THROW(JFileReadException, "JFileReader: error reading file " << file_name);
593  }
594 
595  in.close();
596  }
bool read(const JEquation &equation)
Read equation.
Definition: JProperties.hh:665
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JProperties::JFileReader fileReader 
)
friend

Stream input.

Parameters
ininput stream
fileReaderfile reader object
Returns
input stream

Definition at line 550 of file JProperties.hh.

551  {
552  std::string file_name;
553 
554  in >> file_name;
555 
556  fileReader.read(file_name);
557 
558  return in;
559  }
void read(const std::string &file_name)
Read properties from file.
Definition: JProperties.hh:581
std::ostream& operator<< ( std::ostream &  out,
const JProperties::JFileReader fileReader 
)
friend

Stream output.

Parameters
outoutput stream
fileReaderfile reader
Returns
output stream

Definition at line 569 of file JProperties.hh.

570  {
571  return out;
572  }

Member Data Documentation

JProperties& JEEP::JProperties::JFileReader::properties
private

Definition at line 599 of file JProperties.hh.


The documentation for this class was generated from the following file: