#define UTIL_STRING_H
#include "ustring.h"
+#include "util_regex.h"
#include <time.h>
#include "iconv_glue.h"
#include <iconv.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/lexical_cast.hpp>
-class MlEnv;
class UIConv {
public:
iconv_t cd;
cd = ICONV_ERR;
}
};
- virtual ustring cv (const ustring& text);
+ virtual ustring cv (const ustring& text, bool flush = false);
};
ustring c3 (const ustring& str);
-inline ustring to_ustring (int32_t v) {
- return boost::lexical_cast<ustring> (v);
-}
-inline ustring to_ustring (uint32_t v) {
- return boost::lexical_cast<ustring> (v);
-}
-inline ustring to_ustring (long int v) {
- return boost::lexical_cast<ustring> (v);
-}
-inline ustring to_ustring (unsigned long int v) {
- return boost::lexical_cast<ustring> (v);
-}
-inline ustring to_ustring (long long int v) {
- return boost::lexical_cast<ustring> (v);
-}
-inline ustring to_ustring (unsigned long long int v) {
- return boost::lexical_cast<ustring> (v);
-}
+ustring to_ustring (int32_t v);
+ustring to_ustring (uint32_t v);
+ustring to_ustring (long int v);
+ustring to_ustring (unsigned long int v);
+ustring to_ustring (long long int v);
+ustring to_ustring (unsigned long long int v);
ustring to_ustring (double val);
-inline int32_t to_int32 (const ustring& v) {
- return boost::lexical_cast<int32_t> (v);
-}
-inline uint32_t to_uint32 (const ustring& v) {
- return boost::lexical_cast<uint32_t> (v);
-}
+int32_t to_int32 (const ustring& v);
+uint32_t to_uint32 (const ustring& v);
+uint64_t to_uint64 (const ustring& v);
+ustring percentHEX (int c);
ustring urldecode_nonul (const ustring& str);
ustring omitCtrl (const ustring& str);
ustring omitCtrlX (const ustring& str);
ustring omitNL (const ustring& str);
ustring omitNonAscii (const ustring& str);
ustring omitNonAsciiWord (const ustring& str);
-bool to_bool (const ustring& v);
ustring percentEncode (uiterator b, uiterator e);
-ustring percentEncode (const ustring& str);
+inline ustring percentEncode (const ustring& str) {
+ return percentEncode (str.begin (), str.end ());
+}
ustring percentEncode_path (uiterator b, uiterator e);
-ustring percentEncode_path (const ustring& str);
+inline ustring percentEncode_path (const ustring& str) {
+ return percentEncode_path (str.begin (), str.end ());
+}
ustring percentDecode (const ustring& str);
ustring cookieencode (const ustring& text);
ustring cookiedecode (const ustring& text);
ustring clipColon (const ustring& text);
-//ustring dirPart (char* path);
ustring dirPart (const ustring& path);
ustring filePart_osSafe (const ustring& path);
void split (uiterator b, uiterator e, uregex& re, std::vector<ustring>& ans);
+void split (uiterator b, uiterator e, int ch, std::vector<ustring>& ans);
void splitE (uiterator b, uiterator e, uregex& re, std::vector<ustring>& ans);
+void splitE (uiterator b, uiterator e, int ch, std::vector<ustring>& ans);
bool splitChar (uiterator b, uiterator e, uiterator::value_type ch, uiterator& m1);
ustring filenameEncode (const ustring& text);
ustring filenameDecode (const ustring& text);
double strtod (const ustring& str);
long strtol (const ustring& str);
bool passMatch (const ustring& pass, const ustring& cpass);
-ustring passCrypt (const ustring& pass);
+typedef enum {
+ FORMAT_MD5,
+ FORMAT_BF,
+ FORMAT_SHA256,
+ FORMAT_SHA512,
+} passCryptFormat;
+ustring passCrypt (const ustring& pass, passCryptFormat format);
size_t strLength (const ustring& src);
void substring (const ustring& src, size_t idx, size_t len, int flen, ustring& ans);
ustring jsEncode (const ustring& str);
ustring clipWhite (const ustring& str);
ustring getenvString (const char* key);
ustring zeroPad (int n, const ustring& src);
-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);
-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);
-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);
ustring padEmpty (const ustring& name);
uint32_t hextoul (uiterator b, uiterator e);
+double hextod (uiterator b, uiterator e, int base = 16);
+ustring dtohex (double e, int pad = 0, int base = 16, bool upcase = false);
ustring toCRLF (const ustring& str);
-void skipSpace (uiterator& b, uiterator e);
+void skipChar (uiterator& b, uiterator e, int ch);
+inline void skipSpace (uiterator& b, uiterator e) {skipChar (b, e, ' ');}
+void skipNextToChar (uiterator& b, uiterator e, int ch);
ustring toLower (uiterator b, uiterator e);
-class MNodePtr;
-ustring formatString (const ustring& format, boost::ptr_vector<MNodePtr>& par);
-//ustring formatDateString (const ustring& format, time_t tm);
ustring formatDateString (const ustring& format, struct tm& v);
ustring toLower (const ustring& str);
ustring toUpper (const ustring& str);
-ustring hexEncode (const ustring& data);
+ustring hexEncode (const ustring& data, bool upcase = false);
+ustring hexDecode (const ustring& data);
+int octchar (uiterator b);
+ustring octchar (int c);
+
+bool findNL (uiterator& b, uiterator e, uiterator& u);
+bool findNLb (uiterator& b, uiterator e);
+bool findChar (uiterator& b, uiterator e, int ch);
+bool findChars (uiterator& b, uiterator e, const ustring& pattern);
+bool findCharFn (uiterator& b, uiterator e, bool (*fn)(int));
+bool findSepColon (uiterator& b, uiterator e, uiterator& u);
+bool matchHeadFn (uiterator& b, uiterator e, bool (*fn)(int));
+bool matchWordTbl (uiterator b, uiterator e, char* tbl);
+bool matchWordFn (uiterator b, uiterator e, bool (*fn)(int));
#endif /* UTIL_STRING_H */