LibOFX
ofx_utilities.cpp File Reference

Various simple functions for type conversion & al. More...

Go to the source code of this file.

Macros

#define DIRSEP   "/"
 

Functions

string CharStringtostring (const SGMLApplication::CharString source, string &dest)
 Convert OpenSP CharString to a C++ STL string.
 
string AppendCharStringtostring (const SGMLApplication::CharString source, string &dest)
 Append an OpenSP CharString to an existing C++ STL string.
 
time_t ofxdate_to_time_t (const string &ofxdate)
 Convert a C++ string containing a time in OFX format to a C time_t.
 
double ofxamount_to_double (const string ofxamount)
 Convert OFX amount of money to double float.
 
string strip_whitespace (const string para_string)
 Sanitize a string coming from OpenSP.
 
std::string get_tmp_dir ()
 
int mkTempFileName (const char *tmpl, char *buffer, unsigned int size)
 

Detailed Description

Various simple functions for type conversion & al.

Definition in file ofx_utilities.cpp.

Macro Definition Documentation

◆ DIRSEP

#define DIRSEP   "/"

Definition at line 36 of file ofx_utilities.cpp.

Function Documentation

◆ AppendCharStringtostring()

string AppendCharStringtostring ( const SGMLApplication::CharString  source,
string &  dest 
)

Append an OpenSP CharString to an existing C++ STL string.

Definition at line 85 of file ofx_utilities.cpp.

Referenced by OFCApplication::data(), and OFXApplication::data().

◆ CharStringtostring()

string CharStringtostring ( const SGMLApplication::CharString  source,
string &  dest 
)

Convert OpenSP CharString to a C++ STL string.

Convert an OpenSP CharString directly to a C++ stream, to enable the use of cout directly for debugging.

Definition at line 72 of file ofx_utilities.cpp.

Referenced by OFCApplication::endElement(), OFXApplication::endElement(), OFCApplication::error(), OFXApplication::error(), OFCApplication::startElement(), and OFXApplication::startElement().

◆ get_tmp_dir()

std::string get_tmp_dir ( )

Definition at line 227 of file ofx_utilities.cpp.

◆ mkTempFileName()

int mkTempFileName ( const char *  tmpl,
char *  buffer,
unsigned int  size 
)

Definition at line 245 of file ofx_utilities.cpp.

◆ ofxamount_to_double()

double ofxamount_to_double ( const string  ofxamount)

Convert OFX amount of money to double float.

Convert a C++ string containing an amount of money as specified by the OFX standard and convert it to a double float.

Note
The ofx number format is the following: "." or "," as decimal separator, NO thousands separator.

Definition at line 167 of file ofx_utilities.cpp.

Referenced by OfxBalanceContainer::add_attribute(), OfxSecurityContainer::add_attribute(), OfxPositionContainer::add_attribute(), OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ ofxdate_to_time_t()

time_t ofxdate_to_time_t ( const string &  ofxdate)

Convert a C++ string containing a time in OFX format to a C time_t.

Converts a date from the YYYYMMDDHHMMSS.XXX[gmt offset:tz name] OFX format (see OFX 2.01 spec p.66) to a C time_t.

Parameters
ofxdatedate from the YYYYMMDDHHMMSS.XXX[gmt offset:tz name] OFX format
Returns
C time_t in the local time zone
Note
  • The library always returns the time in the system's local time
: DEVIATION FROM THE OFX SPECIFICATION:
  • : Specification permits timestamps with millisecond precision, but the normal C Library time functions support only second precision.
  • : Many banks don't even specify a time, either by providing only an 8-character string (YYYYMMDD) or by presenting 0 for all the time values (i.e. midnight). In those cases we take that to mean that the time isn't significant and set it to a time that is nearly always the same day regardless of timezone: 10:59 UTC. This works in all timezones except -12 and +13.

Definition at line 105 of file ofx_utilities.cpp.

Referenced by OfxBalanceContainer::add_attribute(), OfxStatementContainer::add_attribute(), OfxSecurityContainer::add_attribute(), OfxPositionContainer::add_attribute(), OfxTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ strip_whitespace()

string strip_whitespace ( const string  para_string)

Sanitize a string coming from OpenSP.

Many weird characters can be present inside a SGML element, as a result on the transfer protocol, or for any reason. This function greatly enhances the reliability of the library by zapping those gremlins (backspace,formfeed,newline,carriage return, horizontal and vertical tabs) as well as removing whitespace at the beginning and end of the string. Otherwise, many problems will occur during stringmatching.

Definition at line 190 of file ofx_utilities.cpp.

Referenced by OFCApplication::endElement(), and OFXApplication::endElement().