22 #include "ParserEventGeneratorKit.h" 
   23 #include "SGMLApplication.h" 
   75   for (i = 0; i < source.len; i++)
 
   77     dest += (char)(((source.ptr)[i]));
 
   86   for (i = 0; i < source.len; i++)
 
   88     dest += (char)(((source.ptr)[i]));
 
  112   float ofx_gmt_offset; 
 
  114   char exact_time_specified = 
false;
 
  115   char time_zone_specified = 
false;
 
  116   string ofxdate_whole;
 
  119   time.tm_isdst = daylight; 
 
  120   std::time(&temptime);
 
  121   local_offset = difftime(mktime(localtime(&temptime)), mktime(gmtime(&temptime))) + (3600 * daylight);
 
  123   if (ofxdate.size() != 0)
 
  125     ofxdate_whole = ofxdate.substr(0, ofxdate.find_first_not_of(
"0123456789"));
 
  126     if (ofxdate_whole.size() >= 8)
 
  128       time.tm_year = atoi(ofxdate_whole.substr(0, 4).c_str()) - 1900;
 
  129       time.tm_mon = atoi(ofxdate_whole.substr(4, 2).c_str()) - 1;
 
  130       time.tm_mday = atoi(ofxdate_whole.substr(6, 2).c_str());
 
  132       if (ofxdate_whole.size() > 8)
 
  134         if (ofxdate_whole.size() == 14)
 
  137           exact_time_specified = 
true;
 
  138           time.tm_hour = atoi(ofxdate_whole.substr(8, 2).c_str());
 
  139           time.tm_min = atoi(ofxdate_whole.substr(10, 2).c_str());
 
  140           time.tm_sec = atoi(ofxdate_whole.substr(12, 2).c_str());
 
  144           message_out(
WARNING, 
"ofxdate_to_time_t():  Successfully parsed date part, but unable to parse time part of string " + ofxdate_whole + 
". It is not in proper YYYYMMDDHHMMSS.XXX[gmt offset:tz name] format!");
 
  152       message_out(
ERROR, 
"ofxdate_to_time_t():  Unable to convert time, string " + ofxdate + 
" is not in proper YYYYMMDDHHMMSS.XXX[gmt offset:tz name] format!");
 
  153       return mktime(&time);
 
  158     string::size_type startidx = ofxdate.find(
"[");
 
  159     string::size_type endidx;
 
  160     if (startidx != string::npos)
 
  163       time_zone_specified = 
true;
 
  165       endidx = ofxdate.find(
":", startidx) - 1;
 
  166       ofx_gmt_offset = atof(ofxdate.substr(startidx, (endidx - startidx) + 1).c_str());
 
  167       startidx = endidx + 2;
 
  168       strncpy(timezone, ofxdate.substr(startidx, 3).c_str(), 4);
 
  174       strcpy(timezone, 
"GMT");
 
  177     if (time_zone_specified == 
true)
 
  182       time.tm_sec = time.tm_sec + (int)(local_offset - (ofx_gmt_offset * 60 * 60)); 
 
  184     else if (exact_time_specified == 
false)
 
  191     return mktime(&time);
 
  195     message_out(
ERROR, 
"ofxdate_to_time_t():  Unable to convert time, string is 0 length!");
 
  198   return mktime(&time);
 
  208   string::size_type idx;
 
  209   string tmp = ofxamount;
 
  212   if (idx == string::npos)
 
  217   if (idx != string::npos)
 
  219     tmp.replace(idx, 1, 1, ((localeconv())->decimal_point)[0]);
 
  222   return atof(tmp.c_str());
 
  232   string temp_string = para_string;
 
  233   if (temp_string.empty())
 
  236   const char *whitespace = 
" \b\f\n\r\t\v";
 
  237   const char *abnormal_whitespace = 
"\b\f\n\r\t\v";
 
  241        i <= temp_string.size()
 
  242        && temp_string.find_first_of(whitespace, i) == i
 
  243        && temp_string.find_first_of(whitespace, i) != string::npos;
 
  245   temp_string.erase(0, i); 
 
  247   for (i = temp_string.size() - 1;
 
  249        && (temp_string.find_last_of(whitespace, i) == i)
 
  250        && (temp_string.find_last_of(whitespace, i) != string::npos);
 
  252   temp_string.erase(i + 1, temp_string.size() - (i + 1)); 
 
  254   while ((index = temp_string.find_first_of(abnormal_whitespace)) != string::npos)
 
  256     temp_string.erase(index, 1); 
 
  265 std::string get_tmp_dir()
 
  270   var = getenv(
"TMPDIR");
 
  274   var = getenv(
"TEMP");
 
  283 int mkTempFileName(
const char *tmpl, 
char *buffer, 
unsigned int size)
 
  286   std::string tmp_dir = get_tmp_dir();
 
  288   strncpy(buffer, tmp_dir.c_str(), size);
 
  289   assert((strlen(buffer) + strlen(tmpl) + 2) < size);
 
  290   strcat(buffer, DIRSEP);
 
  291   strcat(buffer, tmpl);
 
double ofxamount_to_double(const string ofxamount)
Convert OFX amount of money to double float. 
time_t ofxdate_to_time_t(const string ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t. 
string AppendCharStringtostring(const SGMLApplication::CharString source, string &dest)
Append an OpenSP CharString to an existing C++ STL string. 
string CharStringtostring(const SGMLApplication::CharString source, string &dest)
Convert OpenSP CharString to a C++ STL string. 
Message IO functionality. 
int message_out(OfxMsgType error_type, const string message)
Message output function. 
Various simple functions for type conversion & al. 
string strip_whitespace(const string para_string)
Sanitize a string coming from OpenSP.