Wtx ~ Wt Extension Library
WtxLib
Util.h
1 
2 #ifndef __WTX_UTIL_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
3 #define __WTX_UTIL_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
4 
5 #include <string>
6 #include <vector>
7 
8 #include <Wt/WItemDelegate.h>
9 #include <Wt/WTemplate.h>
10 
11 namespace Wtx {
12  namespace Dbo {
13  class Session;
14  }
15 
16  namespace Util {
17  namespace Money {
19  : public Wt::WItemDelegate
20  {
21  public:
22 
24 
25  virtual std::unique_ptr<Wt::WWidget> update( Wt::WWidget * widget, const Wt::WModelIndex & index, Wt::WFlags< Wt::ViewItemRenderFlag > flags );
26 
27  static Wt::WItemDelegate * create( Wtx::Dbo::Session * s );
28 
29  Wtx::Dbo::Session * session();
30  Wtx::Dbo::Session * m_session;
31 
32  };
33  }
34  }
35 
80 std::string json_number_to_string( const std::string & key, const std::string & data );
81 
82 std::string makeFileName( const std::string & value );
83 
89 bool fileExists( const std::string & fileName );
90 
97 int system_command( const std::string & cmd, bool show = false );
98 
105 std::vector<std::string> fileList( const std::string & folder );
106 
114 std::vector<std::string> findFiles( const std::string & folder, const std::string & match );
115 
120 int stoi( const std::string & value );
121 
126 std::string itos( int value );
127 
132 double stof( const std::string & value );
133 
138 std::string ftos( double value, int decimals = 2 );
139 std::string ftos( double value, const std::string & suffix, int decimals = 2 );
140 std::string ftos( const std::string & prefix, double value, int decimals = 2 );
141 std::string ftom( double value, int decimals = 2 );
142 std::string ftom( const std::string & prefix, double value, int decimals = 2 );
143 
148 bool ends_with( const std::string & value, const std::string & ending );
149 
157 std::string append( const std::string & s, const std::string & append, const std::string & separator );
158 
167 std::string prepend( const std::string & s, int length = 0, char pad = '0' );
168 
174 std::string ucase( const std::string & value );
175 
181 std::string lcase( const std::string & value );
182 
189 int roundUp( float value );
190 
197 int roundDown( float value );
198 
206 float roundCurrency( float value );
207 
214 std::string replace( const std::string & string, const std::string & before, const std::string & after );
215 
216 void ltrim(std::string &s);
217 void rtrim(std::string &s);
218 void trim(std::string &s);
219 std::string ltrim_copy(std::string s);
220 std::string rtrim_copy(std::string s);
221 std::string trim_copy(std::string s);
222 
223 std::vector<std::string> readCSVRow( const std::string & row );
224 
229 bool feq( double a, double b, double epsilon = 0.005f, bool trace = false );
230 
231 std::string to_string( Wt::WTemplate & templt );
232 std::string to_string( Wt::WTemplate * templt );
233 
234 bool to_htmlfile( Wt::WTemplate & templt, const std::string & folderName, const std::string & fileName );
235 bool to_htmlfile( Wt::WTemplate * templt, const std::string & folderName, const std::string & fileName );
236 
237 std::string hexDump( const std::string & data, int start = -1, int end = -1 );
238 
239 typedef struct CharConv
240 {
241  const char * symbol;
242  const char * html;
243  const char * utf8;
244  const char * pdf;
245  const char * description;
246 
247 } CharConv_t;
248 
249 extern const CharConv_t g_iso8859Conv[256];
250 
251 } // endnamespace Wtx
252 
253 #endif // #ifndef __WTX_UTIL_H___
254 
255 
std::string append(const std::string &s, const std::string &append, const std::string &separator)
Append a string to string.
Definition: Util.cpp:404
std::string ucase(const std::string &value)
Upper Case a string.
Definition: Util.cpp:441
std::string prepend(const std::string &s, int length=0, char pad= '0')
Prepend some number of characters in front of another string.
Definition: Util.cpp:431
int roundUp(float value)
Round a number up.
Definition: Util.cpp:455
int stoi(const std::string &value)
Convert a String to an Integer.
Definition: Util.cpp:295
double stof(const std::string &value)
Convert a String to Float.
Definition: Util.cpp:320
bool feq(double a, double b, double epsilon=0.005f, bool trace=false)
Definition: Util.cpp:710
std::string ftos(double value, int decimals=2)
Convert a Float to String with decimal precision.
Definition: Util.cpp:344
std::string json_number_to_string(const std::string &key, const std::string &data)
Convert a number to a string.
Definition: Util.cpp:17
std::string replace(const std::string &string, const std::string &before, const std::string &after)
Replace a String.
Definition: Util.cpp:480
std::string itos(int value)
Convert an Integer to a String.
Definition: Util.cpp:311
std::vector< std::string > fileList(const std::string &folder)
File Listing.
Definition: Util.cpp:201
std::vector< std::string > findFiles(const std::string &folder, const std::string &match)
Find File.
Definition: Util.cpp:278
bool ends_with(const std::string &value, const std::string &ending)
Check if a string ends with another string.
Definition: Util.cpp:396
witty extension library
Definition: Activity.h:51
std::string makeFileName(const std::string &value)
Make File Name.
Definition: Util.cpp:85
std::string lcase(const std::string &value)
Lower Case a string.
Definition: Util.cpp:448
int system_command(const std::string &cmd, bool show=false)
Execute a system command.
Definition: Util.cpp:153
bool fileExists(const std::string &fileName)
Check if a File or Folder exists.
Definition: Util.cpp:289
int roundDown(float value)
Round a number down.
Definition: Util.cpp:464
float roundCurrency(float value)
Round a number for Currency.
Definition: Util.cpp:469