OSDN Git Service

fix file structures.
[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  UIConv {
13  public:
14     iconv_t  cd;
15
16     UIConv (const char* in, const char* out);
17     virtual  ~UIConv () {
18         if (cd != ICONV_ERR) {
19             iconv_close (cd);
20             cd = ICONV_ERR;
21         }
22     };
23     virtual ustring  cv (const ustring& text);
24 };
25
26 ustring  c3 (const ustring& str);
27 inline ustring  to_ustring (int32_t v) {
28     return boost::lexical_cast<ustring> (v);
29 }
30 inline ustring  to_ustring (uint32_t v) {
31     return boost::lexical_cast<ustring> (v);
32 }
33 inline ustring  to_ustring (long int v) {
34     return boost::lexical_cast<ustring> (v);
35 }
36 inline ustring  to_ustring (unsigned long int v) {
37     return boost::lexical_cast<ustring> (v);
38 }
39 inline ustring  to_ustring (long long int v) {
40     return boost::lexical_cast<ustring> (v);
41 }
42 inline ustring  to_ustring (unsigned long long int v) {
43     return boost::lexical_cast<ustring> (v);
44 }
45 ustring  to_ustring (double val);
46 inline int32_t  to_int32 (const ustring& v) {
47     return boost::lexical_cast<int32_t> (v);
48 }
49 inline uint32_t  to_uint32 (const ustring& v) {
50     return boost::lexical_cast<uint32_t> (v);
51 }
52 ustring  percentHEX (int c);
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 ustring  padEmpty (const ustring& name);
101 uint32_t  hextoul (uiterator b, uiterator e);
102 ustring  toCRLF (const ustring& str);
103 void  skipSpace (uiterator& b, uiterator e);
104 ustring  toLower (uiterator b, uiterator e);
105
106 ustring  formatDateString (const ustring& format, struct tm& v);
107 ustring  toLower (const ustring& str);
108 ustring  toUpper (const ustring& str);
109 ustring  hexEncode (const ustring& data);
110
111 #endif /* UTIL_STRING_H */