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 | Variables
DataStock.cpp File Reference

Implementation file of DataStock classes. More...

#include "DataStock.h"
#include <iomanip>
#include <sstream>
#include <cassert>
#include <cstring>
#include <limits>
Include dependency graph for DataStock.cpp:

Go to the source code of this file.

Namespaces

 FDS
 For Format of the DataStock output.
 

Functions

size_t reconstruct_stream_operator (std::iostream &is, char *buf_to_ret)
 Reconstruct a stream in skipping the values already consumed
This is used by friend operator>> ( iostream )
This version use only C-string array, no string or streamstring intermediate. More...
 
bool operator== (const SimpleData &lhs, const SimpleData &rhs)
 
bool operator== (const MultiData &lhs, const MultiData &rhs)
 
bool operator== (const DataCSV &lhs, const DataCSV &rhs)
 
std::ostream & operator<< (std::ostream &os, const DataStock &obj)
 
std::iostream & operator>> (std::iostream &ios, DataStock &obj)
 
std::string & operator<< (std::string &line_csv, const DataStock &obj)
 
std::string & operator>> (std::string &line_csv, DataStock &obj)
 

Variables

const int FDS::WCOL = 10
 Witdh of the values with setw. More...
 
const int FDS::PRECISION = 2
 Precison of floating numbers. More...
 

Detailed Description

Implementation file of DataStock classes.

Last modified :

Id:
DataStock.cpp 511 2014-12-07 15:42:15Z martinml

Definition in file DataStock.cpp.

Function Documentation

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

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.

References DataStock::helper_operator_write(), and DataStock::helper_operator_write_base().

Here is the call graph for this function:

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

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.

bool operator== ( const SimpleData lhs,
const SimpleData rhs 
)

Definition at line 910 of file DataStock.cpp.

References DataStock::date, and SimpleData::value.

bool operator== ( const MultiData lhs,
const MultiData rhs 
)

Definition at line 916 of file DataStock.cpp.

References DataStock::date, and MultiData::values.

bool operator== ( const DataCSV lhs,
const DataCSV rhs 
)

Definition at line 922 of file DataStock.cpp.

References DataCSV::close, DataStock::date, DataCSV::high, DataCSV::low, and DataCSV::open.

std::iostream& operator>> ( std::iostream &  ios,
DataStock obj 
)
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.

References BDS::BUFFER_STREAM, DataStock::helper_operator_read(), DataStock::helper_operator_read_base(), and reconstruct_stream_operator().

Here is the call graph for this function:

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

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.

size_t reconstruct_stream_operator ( std::iostream &  is,
char *  buf_to_ret 
)

Reconstruct a stream in skipping the values already consumed
This is used by friend operator>> ( iostream )
This version use only C-string array, no string or streamstring intermediate.

More efficient.

To call when the istream has already read all the values.
The function will read the resting values, then the date(at the beginning) and
cat all in buf_to_ret (all size defined in namespace FDS

Definition at line 39 of file DataStock.cpp.

References BDS::BUFFER_DATE, and BDS::BUFFER_STREAM.

Referenced by operator>>().

Here is the caller graph for this function: