LibOFX
ofx_utilities.hh
Go to the documentation of this file.
1/***************************************************************************
2 ofx_util.h
3 -------------------
4 copyright : (C) 2002 by Benoit Gr�goire
5 email : benoitg@coeus.ca
6 ***************************************************************************/
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18#ifndef OFX_UTIL_H
19#define OFX_UTIL_H
20#include <string.h>
21#include <time.h> // for time_t
22#include <cstring>
23#include "ParserEventGeneratorKit.h"
24
25/* This file contains various simple functions for type conversion & al */
26
27/*wostream &operator<<(wostream &os, SGMLApplication::CharString s); */
28
34template <typename T>
35void STRNCPY(T& dest, const std::string& src)
36{
37 std::strncpy(dest, src.c_str(), sizeof(dest));
38}
39
45#define ASSIGN(DEST, VALUE) DEST = (VALUE); DEST ## _valid = true
46
52#define ASSIGN_STRNCPY(DEST, VALUE) STRNCPY(DEST, VALUE); DEST ## _valid = true
53
55std::string CharStringtostring(const SGMLApplication::CharString source);
56
58void AppendCharStringtostring(const SGMLApplication::CharString source, std::string &dest);
59
61time_t ofxdate_to_time_t(const std::string& ofxdate);
62
64double ofxamount_to_double(const std::string ofxamount);
65
67std::string strip_whitespace(const std::string para_string);
68
69int mkTempFileName(const char *tmpl, char *buffer, unsigned int size);
70
71#endif
std::string CharStringtostring(const SGMLApplication::CharString source)
Convert OpenSP CharString to a C++ STL string.
void STRNCPY(T &dest, const std::string &src)
std::string strip_whitespace(const std::string para_string)
Sanitize a string coming from OpenSP.
void AppendCharStringtostring(const SGMLApplication::CharString source, std::string &dest)
Append an OpenSP CharString to an existing C++ STL string.
double ofxamount_to_double(const std::string ofxamount)
Convert OFX amount of money to double float.
time_t ofxdate_to_time_t(const std::string &ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.