00001
00002
00007 #ifndef __STRUTIL_H__
00008 #define __STRUTIL_H__
00009
00010 #include <string>
00011 #include <cstdio>
00012 #include <map>
00013
00014 #include "libepp_nicbr.H"
00015
00016 #include <xercesc/framework/MemBufFormatTarget.hpp>
00017 #include <xercesc/framework/XMLFormatter.hpp>
00018
00019 using std::string;
00020 using std::map;
00021 using std::less;
00022
00023 LIBEPP_NICBR_NS_BEGIN
00024
00026 class StrUtil
00027 {
00028 public:
00030
00037 static string parse(const string &text,
00038 const map < string, string, less<string> > &to_parse,
00039 string tag_begin, string tag_end);
00040
00042
00048 static int gsub(string &buffer, const char *pat, const char *drp);
00049
00051
00056 template<class kind>
00057 static inline string to_string(const char* format, const kind &number)
00058 {
00059
00060 const int _NUMBER_SIZE = 128;
00061 char *p;
00062
00063 p = new char[_NUMBER_SIZE];
00064 snprintf(p, (_NUMBER_SIZE - 1), format, number);
00065 string s(p);
00066
00067 delete [] p;
00068 return s;
00069 }
00070
00078 static int iso88591_to_utf8(const string &iso88591, string &utf8);
00079
00088 static int utf8_to_iso88591(const string &utf8, string &iso88591);
00089
00091
00095 string xml_beautifier(const string &input_txt);
00096
00098
00103 static string esc_xml_markup(const string &input_txt);
00104 };
00105
00106 LIBEPP_NICBR_NS_END
00107 #endif //__STRUTIL_H__