ROOT_Application  2.0
C++ Core modules and GUIStock
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Functions | Variables
Utils Namespace Reference

All included in the namespace, must be called with Utils:: More...

Data Structures

struct  firstlast_dates
 general structure for dates in csv files More...
 

Functions

void SetPathData (std::string new_path)
 forced to use this function now. More...
 
std::string GetPathData ()
 
double fromStreamToDouble (std::iostream &stream, char delim)
 Read the next character of a stream as a double. More...
 
void splitline (const std::string &str, const std::string &delimiters, std::vector< std::string > &tokens)
 splitline More...
 
time_t GetTime_tToday ()
 Get the time_t of today. More...
 
time_t StringToTime_t (const std::string &str)
 Return the time_t from a string
. More...
 
time_t StringToTime_t (const char *str)
 Return the time_t from a c-string
. More...
 
std::string Time_tToString (const time_t &time, const bool b_hour=false)
 Return a string representing the date
All times are expressed in the localtime. More...
 
void GetDateYMD (time_t time_unix, int &year, int &month, int &day)
 Set year, month and day given an input time. More...
 
time_t StringToTime_t_old (std::string str_date)
 
static SUPPRESS_NOT_USED_WARN
firstlast_dates 
get_fldate_default ()
 need to be static for using default argument in a function More...
 
template<class T >
std::string toString (const T &t)
 
template<class T >
fromString (const std::string &s)
 Transform string to any type : float, double, int. More...
 

Variables

static std::string PATH_DATA ="/home/michael/workspace_kepler/ROOT_application/data"
 to modify before compilation to set from a Config file More...
 
const std::string PATH_DATA_TEST ="/home/michael/workspace_kepler/ROOT_application/data_test"
 Important variable to adjust before compilation, should be in a configuration. More...
 
const time_t ERROR_StrToTime = -105
 Error code returned by StringToTime_t if the string cannot be parsed correctly
Must be a time_t, -1 is the original epoch date, so choose a random number. More...
 

Detailed Description

All included in the namespace, must be called with Utils::

Declare PATH_DATA Functions for dealing with Date and Time

Function Documentation

double Utils::fromStreamToDouble ( std::iostream &  stream,
char  delim 
)

Read the next character of a stream as a double.

Parameters
streamto read
delimcharacter will be extracted from the initial position to the delimiter or the end of the stream
Returns
double value read. Return 0 if error

Definition at line 45 of file Utils.cpp.

Referenced by SimpleData::helper_operator_read(), MultiData::helper_operator_read(), and DataCSV::helper_operator_read().

Here is the caller graph for this function:

template<class T >
T Utils::fromString ( const std::string &  s)

Transform string to any type : float, double, int.

Definition at line 78 of file Utils.h.

static SUPPRESS_NOT_USED_WARN firstlast_dates Utils::get_fldate_default ( )
static
void Utils::GetDateYMD ( time_t  time_unix,
int &  year,
int &  month,
int &  day 
)

Set year, month and day given an input time.

If time_unix is 0 the actual date is used

Parameters
[in]time_unixinput time
[out]year
[out]month
[out]day

Definition at line 185 of file Utils.cpp.

Referenced by TransDateBox::ProcessMessage(), and TransDateBox::Valid().

Here is the caller graph for this function:

std::string Utils::GetPathData ( )

Definition at line 42 of file Utils.cpp.

References PATH_DATA.

Referenced by GUIMainController::GUIMainController(), main(), Stock::Read_HeaderCSV_static(), Stock::UpdateCSV_Inst(), and MainControllerIndicatorTHStock::Validation().

Here is the caller graph for this function:

time_t Utils::GetTime_tToday ( )

Get the time_t of today.

Definition at line 74 of file Utils.cpp.

Referenced by TransDateBox::ProcessMessage().

Here is the caller graph for this function:

void Utils::SetPathData ( std::string  new_path)

forced to use this function now.


dangerous to change during execution of a program, done for unit-test

Definition at line 37 of file Utils.cpp.

References PATH_DATA.

Referenced by wrap_SaveInst(), wrapLastCSVUpdate(), and wrapUpdateCSV().

Here is the caller graph for this function:

void Utils::splitline ( const std::string &  str,
const std::string &  delimiters,
std::vector< std::string > &  tokens 
)
time_t Utils::StringToTime_t ( const std::string &  str)

Return the time_t from a string
.

All times are expressed in the localtime
Format can be:

  • "YEAR-MOnth-DAy HH:MM:SS"
  • "YEAR-MOnth-DAy", here hour, minute and sec are considered as 0.
    Parameters
    strstring representing the date
    Returns
    the time_t corresponding, or Utils::ERROR_StrToTime if an error occurred in the parsing

Definition at line 93 of file Utils.cpp.

References ERROR_StrToTime.

Referenced by SimpleData::ExtractCSVLine(), MultiData::ExtractCSVLine(), DataCSV::ExtractCSVLine(), DataStock::helper_operator_read_base(), Stock::ReadCSV(), Stock::ReadLineHeader(), and StockManager::SendDatadCSV().

Here is the caller graph for this function:

time_t Utils::StringToTime_t ( const char *  str)

Return the time_t from a c-string
.

Todo:
check this version with char * str All times are expressed in the localtime
Format can be:
  • "YEAR-MOnth-DAy HH:MM:SS"
  • "YEAR-MOnth-DAy", here hour, minute and sec are considered as 0.
    Parameters
    strstring representing the date
    Returns
    the time_t corresponding, or Utils::ERROR_StrToTime if an error occurred in the parsing

Definition at line 125 of file Utils.cpp.

References ERROR_StrToTime.

time_t Utils::StringToTime_t_old ( std::string  str_date)

Definition at line 216 of file Utils.cpp.

std::string Utils::Time_tToString ( const time_t &  time,
const bool  b_hour = false 
)

Return a string representing the date
All times are expressed in the localtime.


Parameters
timeinput
b_houroptional includes the hour in the string
Returns
string with format "YEAR-MOnth-DAy"(b_hour false) or "YEAR-MOnth-DAy HH:MM:SS"(b_hour true)

Definition at line 157 of file Utils.cpp.

Referenced by ListDataStock< T, PolicyChronologic >::AddToList(), THStock::GetDateFromBin(), DataStock::GetDateString(), ObjectLine::GetValues(), Stock::LoadListData(), CandleStock::MakeStringForStatusBar(), BarStock::MakeStringForStatusBar(), PStockLine::MakeStringForStatusBar(), ObjectLineIndicator::MakeStringForStatusBar(), ObjectLineTendance::MakeStringForStatusBar(), ListDataStock< T, PolicyChronologic >::PrintData(), Stock::ReadCSV(), Stock::ReadLineHeader(), Stock::UpdateCSVFromFile(), Stock::UpdateCSVFromWeb(), TransDateBox::Valid(), and Stock::WriteLineHeader().

Here is the caller graph for this function:

template<class T >
std::string Utils::toString ( const T &  t)

Definition at line 69 of file Utils.h.

Referenced by Stock::ComputeTA(), MainIndicatorTHStockFrame::EventInfo(), FileReadError::FileReadError(), and ObjectLineTendance::MakeStringForStatusBar().

Here is the caller graph for this function:

Variable Documentation

const time_t Utils::ERROR_StrToTime = -105

Error code returned by StringToTime_t if the string cannot be parsed correctly
Must be a time_t, -1 is the original epoch date, so choose a random number.

Definition at line 51 of file Utils.h.

Referenced by DataStock::helper_operator_read_base(), Stock::ReadLineHeader(), StockManager::SendDatadCSV(), and StringToTime_t().

std::string Utils::PATH_DATA ="/home/michael/workspace_kepler/ROOT_application/data"
static

to modify before compilation to set from a Config file

Definition at line 30 of file Utils.cpp.

Referenced by GetPathData(), and SetPathData().

const std::string Utils::PATH_DATA_TEST ="/home/michael/workspace_kepler/ROOT_application/data_test"

Important variable to adjust before compilation, should be in a configuration.

Definition at line 38 of file Utils.h.

Referenced by wrap_SaveInst(), wrapLastCSVUpdate(), and wrapUpdateCSV().