Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
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.
 

Private Member Functions

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

Private Attributes

JPropertiesproperties
 

Friends

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

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 535 of file JProperties.hh.

Constructor & Destructor Documentation

◆ JFileReader()

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

Definition at line 537 of file JProperties.hh.

537 :
538 properties(__properties)
539 {}

Member Function Documentation

◆ operator=()

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

Assignment operator.

Parameters
file_namefile name
Returns
this JFileReader

Definition at line 548 of file JProperties.hh.

549 {
550 read(file_name);
551
552 return *this;
553 }
void read(const std::string &file_name)
Read properties from file.

◆ read()

void JEEP::JProperties::JFileReader::read ( const std::string & file_name)
inlineprivate

Read properties from file.

Parameters
file_namefile name

Definition at line 594 of file JProperties.hh.

595 {
596 std::ifstream in(file_name.c_str());
597
598 if (!in) {
599 THROW(JFileOpenException, "JFileReader: error opening file " << file_name);
600 }
601
602 properties.read(in);
603
604 if (in.bad()) {
605 THROW(JFileReadException, "JFileReader: error reading file " << file_name);
606 }
607
608 in.close();
609 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
bool read(const JEquation &equation)
Read equation.

Friends And Related Symbol Documentation

◆ operator>>

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

Stream input.

Parameters
ininput stream
fileReaderfile reader object
Returns
input stream

Definition at line 563 of file JProperties.hh.

564 {
565 std::string file_name;
566
567 in >> file_name;
568
569 fileReader.read(file_name);
570
571 return in;
572 }

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JProperties::JFileReader & fileReader )
friend

Stream output.

Parameters
outoutput stream
fileReaderfile reader
Returns
output stream

Definition at line 582 of file JProperties.hh.

583 {
584 return out;
585 }

Member Data Documentation

◆ properties

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

Definition at line 612 of file JProperties.hh.


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