libepp_nicbr
StrUtil.H
Go to the documentation of this file.
1 /* ${copyright}$ */
2 /* $Id: StrUtil.H 1178 2013-07-24 20:35:03Z rafael $ */
7 #ifndef __STRUTIL_H__
8 #define __STRUTIL_H__
9 
10 #include <string>
11 #include <cstdio>
12 #include <map>
13 
14 #include "libepp_nicbr.H"
15 
16 #include <xercesc/framework/MemBufFormatTarget.hpp>
17 #include <xercesc/framework/XMLFormatter.hpp>
18 
19 using std::string;
20 using std::map;
21 using std::less;
22 
23 LIBEPP_NICBR_NS_BEGIN
24 
26 class StrUtil
27 {
28 public:
30 
37  static string parse(const string &text,
38  const map < string, string, less<string> > &to_parse,
39  string tag_begin, string tag_end);
40 
42 
48  static int gsub(string &buffer, const char *pat, const char *drp);
49 
51 
56  template<class kind>
57  static inline string to_string(const char* format, const kind &number)
58  {
59  // Max size of numeric buffer
60  const int _NUMBER_SIZE = 128;
61  char *p;
62 
63  p = new char[_NUMBER_SIZE];
64  snprintf(p, (_NUMBER_SIZE - 1), format, number);
65  string s(p);
66 
67  delete [] p;
68  return s;
69  }
70 
78  static int iso88591_to_utf8(const string &iso88591, string &utf8);
79 
88  static int utf8_to_iso88591(const string &utf8, string &iso88591);
89 
91 
95  string xml_beautifier(const string &input_txt);
96 
98 
103  static string esc_xml_markup(const string &input_txt);
104 
106 
110  static string &ltrim(string &s);
111 
113 
117  static string& rtrim(string &s);
118 
120 
124  static string& trim(string &s);
125 };
126 
127 LIBEPP_NICBR_NS_END
128 #endif //__STRUTIL_H__
StrUtil Class: String Manipulation Utilities.
Definition: StrUtil.H:26
static string to_string(const char *format, const kind &number)
Convert number to string where the format string looks like printf format.
Definition: StrUtil.H:57
static string & rtrim(string &s)
Trim from end.
Project defines.
static string & trim(string &s)
Trim from both ends.
static int iso88591_to_utf8(const string &iso88591, string &utf8)
static string parse(const string &text, const map< string, string, less< string > > &to_parse, string tag_begin, string tag_end)
Used for parsing XML Templates.
static int utf8_to_iso88591(const string &utf8, string &iso88591)
static string esc_xml_markup(const string &input_txt)
Escape &'><" characters.
string xml_beautifier(const string &input_txt)
XML Beautifier.
static int gsub(string &buffer, const char *pat, const char *drp)
Used for substitution of pat for drp within buffer.
static string & ltrim(string &s)
Trim from start.