ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Functions
Operators for reading/writing DataStock to files and streams

See Operators for reading and writing data. More...

Namespaces

 FDS
 For Format of the DataStock output.
 
 BDS
 For buffer DataStock.
 

Functions

int DataStock::helper_operator_read_base (std::iostream &ios)
 Helper function for operator<< for reading date from input streams. More...
 
void DataStock::helper_operator_write_base (std::ostream &os) const
 Helper function for operator>> for writing date to output. More...
 

Friend operators for input/output.

The functions allow to combine DataStocks and use pointer or reference to the base class.

More description of their usage in this link

std::ostream & DataStock::operator<< (std::ostream &os, const DataStock &obj)
 Fill ostream ( ostringstream ) with text data
. More...
 
std::iostream & DataStock::operator>> (std::iostream &ios, DataStock &obj)
 Set a DataStock(s) with data from a iostream( e.g.,stringstream )
. More...
 
std::string & DataStock::operator<< (std::string &line_csv, const DataStock &obj)
 Similar operator, but for use with string as output. More...
 
std::string & DataStock::operator>> (std::string &line_csv, DataStock &obj)
 Similar operator, but can use string as input. More...
 

Pure virtual helper functions for operator << and >>

virtual void DataStock::helper_operator_write (std::ostream &os) const =0
 
virtual void DataStock::helper_operator_read (std::iostream &ios)=0
 

Specific to input/output of SimpleData

virtual void SimpleData::helper_operator_write (std::ostream &os) const
 
virtual void SimpleData::helper_operator_read (std::iostream &ios)
 

Specific to input/output of MultiData

virtual void MultiData::helper_operator_write (std::ostream &os) const
 
virtual void MultiData::helper_operator_read (std::iostream &ios)
 

Specific to input/output of DataCSV

virtual void DataCSV::helper_operator_write (std::ostream &os) const
 
virtual void DataCSV::helper_operator_read (std::iostream &ios)
 

Detailed Description

See Operators for reading and writing data.

Function Documentation

virtual void DataStock::helper_operator_read ( std::iostream &  ios)
pure virtual

Implemented in DataCSV, MultiData, and SimpleData.

Referenced by operator>>().

Here is the caller graph for this function:

void SimpleData::helper_operator_read ( std::iostream &  ios)
protectedvirtual

Implements DataStock.

Definition at line 389 of file DataStock.cpp.

References Utils::fromStreamToDouble(), and SimpleData::SetValue().

Here is the call graph for this function:

void MultiData::helper_operator_read ( std::iostream &  ios)
protectedvirtual

Implements DataStock.

Definition at line 611 of file DataStock.cpp.

References Utils::fromStreamToDouble(), MultiData::nb_data, and MultiData::SetValues().

Here is the call graph for this function:

void DataCSV::helper_operator_read ( std::iostream &  ios)
protectedvirtual

Implements DataStock.

Definition at line 894 of file DataStock.cpp.

References Utils::fromStreamToDouble(), and DataCSV::SetValues().

Here is the call graph for this function:

int DataStock::helper_operator_read_base ( std::iostream &  ios)
protected

Helper function for operator<< for reading date from input streams.

In base class, reads the date

Parameters
isinput/output stream
Returns
status, 0 if ok, 1 if error in parsing the date

Definition at line 186 of file DataStock.cpp.

References BDS::BUFFER_DATE, Utils::ERROR_StrToTime, DataStock::SetDate(), and Utils::StringToTime_t().

Referenced by operator>>().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void DataStock::helper_operator_write ( std::ostream &  os) const
pure virtual

Implemented in DataCSV, MultiData, and SimpleData.

Referenced by operator<<().

Here is the caller graph for this function:

void SimpleData::helper_operator_write ( std::ostream &  os) const
protectedvirtual

Implements DataStock.

Definition at line 384 of file DataStock.cpp.

References SimpleData::GetValue(), FDS::PRECISION, and FDS::WCOL.

Here is the call graph for this function:

void MultiData::helper_operator_write ( std::ostream &  os) const
protectedvirtual

Implements DataStock.

Definition at line 604 of file DataStock.cpp.

References MultiData::nb_data, FDS::PRECISION, MultiData::values, and FDS::WCOL.

void DataCSV::helper_operator_write ( std::ostream &  os) const
protectedvirtual

Implements DataStock.

Definition at line 885 of file DataStock.cpp.

References DataCSV::GetClose(), DataCSV::GetHigh(), DataCSV::GetLow(), DataCSV::GetOpen(), FDS::PRECISION, and FDS::WCOL.

Here is the call graph for this function:

void DataStock::helper_operator_write_base ( std::ostream &  os) const
protected

Helper function for operator>> for writing date to output.

Warning
cannot combine with std::cout, certainly also cerr, clog
Need to use an intermediate stringstream

Definition at line 173 of file DataStock.cpp.

References DataStock::GetDateString().

Referenced by operator<<().

Here is the call graph for this function:

Here is the caller graph for this function:

Friends

std::ostream& operator<< ( std::ostream &  os,
const DataStock obj 
)
friend

Fill ostream ( ostringstream ) with text data
.

Single DataStock can be used:

os << data_csv;

And multiple DataStock can be combined:

os << data_csv << data_vol;
Warning
cannot combine DataStocks with std::cout, certainly also cerr, clog
Need to use an intermediate stringstream
Parameters
osa ostream with text data
Returns
a ref to the output os, allows to be combined

Definition at line 936 of file DataStock.cpp.

std::string& operator<< ( std::string &  line_csv,
const DataStock obj 
)
friend

Similar operator, but for use with string as output.

Call the standard friend operator>>
Single and multiple DataStock can be used:

line_csv << data_csv << data_vol
Parameters
line_csvstring containing the text data to read
Returns
reference to line_csv, should be empty after the execution

Definition at line 990 of file DataStock.cpp.

std::iostream& operator>> ( std::iostream &  ios,
DataStock obj 
)
friend

Set a DataStock(s) with data from a iostream( e.g.,stringstream )
.

Note
an input/output stream must be used

Single DataStock can be used:

ios >> data_csv;

And multiple DataStock can be combined:

ios >> data_csv >> data_vol;

Normal state of the stream after reading:

  • ios.eof() : true; fail(), bad(), good() : false

Test:

  • if missing data in the stream is.fail() is true or assert in debug mode
  • if more data is.eof() return false

Test than the input was read correctly:

( ios.eof() == true && ios.fail() == false ) == true
Parameters
iosa iostream with the data
objthe DataStock object to set
Returns
a ref to the input ios, allows to be combined

Definition at line 948 of file DataStock.cpp.

std::string& operator>> ( std::string &  line_csv,
DataStock obj 
)
friend

Similar operator, but can use string as input.

If the processing is correct the input string should be empty after the execution

line_csv.empty() == true
Parameters
line_csvstring to fill with text data
objDataStock object to set
Returns
std::string, allow to combine operators

Definition at line 999 of file DataStock.cpp.