OSDN Git Service

getarray wiki function.
[hmh/hhml.git] / lib / util_string.h
1 #ifndef UTIL_STRING_H
2 #define UTIL_STRING_H
3
4 #include "ustring.h"
5 #include <time.h>
6 #include "iconv_glue.h"
7 #include <iconv.h>
8 #include <vector>
9 #include <boost/ptr_container/ptr_vector.hpp>
10 #include <boost/lexical_cast.hpp>
11
12 class  MlEnv;
13 class  UIConv {
14  public:
15     iconv_t  cd;
16
17     UIConv (const char* in, const char* out);
18     virtual  ~UIConv () {
19         if (cd != ICONV_ERR) {
20             iconv_close (cd);
21             cd = ICONV_ERR;
22         }
23     };
24     virtual ustring  cv (const ustring& text);
25 };
26
27 ustring  c3 (const ustring& str);
28 inline ustring  to_ustring (int32_t v) {
29     return boost::lexical_cast<ustring> (v);
30 }
31 inline ustring  to_ustring (uint32_t v) {
32     return boost::lexical_cast<ustring> (v);
33 }
34 inline ustring  to_ustring (long int v) {
35     return boost::lexical_cast<ustring> (v);
36 }
37 inline ustring  to_ustring (unsigned long int v) {
38     return boost::lexical_cast<ustring> (v);
39 }
40 inline ustring  to_ustring (long long int v) {
41     return boost::lexical_cast<ustring> (v);
42 }
43 inline ustring  to_ustring (unsigned long long int v) {
44     return boost::lexical_cast<ustring> (v);
45 }
46 ustring  to_ustring (double val);
47 inline int32_t  to_int32 (const ustring& v) {
48     return boost::lexical_cast<int32_t> (v);
49 }
50 inline uint32_t  to_uint32 (const ustring& v) {
51     return boost::lexical_cast<uint32_t> (v);
52 }
53 ustring  urldecode_nonul (const ustring& str);
54 ustring  omitPattern (const ustring& text, uregex& re);
55 ustring  omitCtrl (const ustring& str);
56 ustring  omitCtrlX (const ustring& str);
57 ustring  omitNul (const ustring& str);
58 ustring  omitNL (const ustring& str);
59 ustring  omitNonAscii (const ustring& str);
60 ustring  omitNonAsciiWord (const ustring& str);
61 ustring  percentEncode (uiterator b, uiterator e);
62 ustring  percentEncode (const ustring& str);
63 ustring  percentEncode_path (uiterator b, uiterator e);
64 ustring  percentEncode_path (const ustring& str);
65 ustring  percentDecode (const ustring& str);
66 ustring  cookieencode (const ustring& text);
67 ustring  cookiedecode (const ustring& text);
68 ustring  clipColon (const ustring& text);
69 ustring  dirPart (const ustring& path);
70 ustring  filePart_osSafe (const ustring& path);
71 void  split (uiterator b, uiterator e, uregex& re, std::vector<ustring>& ans);
72 void  splitE (uiterator b, uiterator e, uregex& re, std::vector<ustring>& ans);
73 bool  splitChar (uiterator b, uiterator e, uiterator::value_type ch, uiterator& m1);
74 ustring  filenameEncode (const ustring& text);
75 ustring  filenameDecode (const ustring& text);
76 ustring  escape_re (const ustring& text);
77 ustring  slashEncode (const ustring& text);
78 ustring  slashDecode (const ustring& text);
79 unsigned long  strtoul (const ustring& str);
80 unsigned long  strtoul (const uiterator& b);
81 double  strtod (const ustring& str);
82 long  strtol (const ustring& str);
83 bool  passMatch (const ustring& pass, const ustring& cpass);
84 ustring  passCrypt (const ustring& pass);
85 size_t  strLength (const ustring& src);
86 void  substring (const ustring& src, size_t idx, size_t len, int flen, ustring& ans);
87 ustring  jsEncode (const ustring& str);
88 bool  matchSkip (uiterator& b, uiterator e, const char* t, size_t s);
89 bool  matchHead (uiterator& b, uiterator e, const char* t, size_t s);
90 bool  matchHead (const ustring& str, const char* t, size_t s);
91 bool  matchHead (const ustring& str, const ustring& head);
92 bool  match (uiterator b, uiterator e, const char* t, size_t s);
93 bool  match (const ustring& str, const char* t, size_t s);
94 bool  match (uiterator b, uiterator e, const ustring& str);
95 bool  match (const ustring& str, const char* t, size_t s, const char* t2, size_t s2);
96 ustring  clipWhite (uiterator b, uiterator e);
97 ustring  clipWhite (const ustring& str);
98 ustring  getenvString (const char* key);
99 ustring  zeroPad (int n, const ustring& src);
100 bool  wsearch (const ustring& text, boost::wsmatch& m, const ustring& reg, boost::wregex::flag_type reg_flags = boost::regex_constants::normal, boost::match_flag_type search_flags = boost::regex_constants::match_single_line);
101 bool  wsearch_env (MlEnv* mlenv, const ustring& text, const ustring& reg, boost::wregex::flag_type reg_flags = boost::regex_constants::normal, boost::match_flag_type search_flags = boost::regex_constants::match_single_line);
102 ustring  wreplace (const ustring& text, const ustring& reg, const ustring& fmt, boost::wregex::flag_type reg_flags = boost::regex_constants::normal, boost::match_flag_type match_flags = boost::regex_constants::match_single_line);
103 ustring  padEmpty (const ustring& name);
104 uint32_t  hextoul (uiterator b, uiterator e);
105 ustring  toCRLF (const ustring& str);
106 void  skipSpace (uiterator& b, uiterator e);
107 ustring  toLower (uiterator b, uiterator e);
108
109 class  MNodePtr;
110 ustring  formatString (const ustring& format, boost::ptr_vector<MNodePtr>& par);
111 ustring  formatDateString (const ustring& format, struct tm& v);
112 ustring  toLower (const ustring& str);
113 ustring  toUpper (const ustring& str);
114 ustring  hexEncode (const ustring& data);
115
116 #endif /* UTIL_STRING_H */