20 #ifndef COIL_STRINGUTIL_H 21 #define COIL_STRINGUTIL_H 31 #if defined (_MSC_VER) && (_MSC_VER <=1500) // VC2008(VC9.0) or before 36 #if defined(Cygwin) && ( __GNUC__ < 4 ) 39 typedef basic_string<wchar_t> wstring;
46 typedef std::map<std::string, std::string>
mapstring;
106 void toUpper(std::string& str);
125 void toLower(std::string& str);
178 bool isEscaped(
const std::string& str, std::string::size_type pos);
212 std::string
escape(
const std::string str);
250 std::string
unescape(
const std::string str);
382 unsigned int replaceString(std::string& str,
const std::string from,
383 const std::string to);
408 vstring
split(
const std::string& input,
409 const std::string& delimiter,
410 bool ignore_empty =
false);
440 bool toBool(std::string str, std::string yes, std::string no,
441 bool default_value =
true);
465 bool includes(
const vstring& list, std::string value,
466 bool ignore_case =
true);
491 bool includes(
const std::string& list, std::string value,
492 bool ignore_case =
true);
550 bool isURL(
const std::string& str);
551 bool isIPv4(
const std::string& str);
552 bool isIPv6(
const std::string& str);
601 template <
class Pr
intable>
604 std::stringstream str_stream;
606 return str_stream.str();
632 template <
typename To>
635 if (str == 0) {
return false; }
638 if ((s << str).fail()) {
return false; }
639 if ((s >> val).fail()) {
return false; }
667 bool stringTo<std::string>(std::string& val,
const char* str);
720 std::stringstream ss;
721 ss << std::hex << std::showbase;
722 ss << reinterpret_cast<uintptr_t>(n);
754 if ((s << std::hex << str).fail()) {
return false; }
756 if ((s >> intval).fail()) {
return false; }
757 ptr =
reinterpret_cast<T*
>(intval);
758 if (ptr == NULL) {
return false; }
811 std::string
flatten(vstring sv, std::string delimiter =
", ");
836 char**
toArgv(
const vstring& args);
860 std::string
sprintf(
char const * __restrict fmt, ...);
887 #endif // COIL_STRINGUTIL_H std::string normalize(std::string &str)
文字列を正規化する
void toUpper(std::string &str)
大文字への変換
std::string otos(Printable n)
与えられたオブジェクトをstd::stringに変換
Definition: stringutil.h:602
bool stringTo(To &val, const char *str)
与えられたstd::stringをオブジェクトに変換
Definition: stringutil.h:633
void eraseBlank(std::string &str)
文字列の空白文字を削除する
void eraseHeadBlank(std::string &str)
文字列の先頭の空白文字を削除する
std::string flatten(vstring sv, std::string delimiter=", ")
与えられた文字列リストからCSVを生成
bool isIPv4(const std::string &str)
vstring unique_sv(vstring sv)
与えられた文字列リストから重複を削除
void eraseBothEndsBlank(std::string &str)
文字列の先頭・末尾の空白文字を削除する
bool isAbsolutePath(const std::string &str)
与えられた文字列が絶対パスかどうかを判断する
std::vector< std::string > vstring
Definition: stringutil.h:45
char ** toArgv(const vstring &args)
与えられた文字列リストを引数リストに変換
void eraseTailBlank(std::string &str)
文字列の末尾の空白文字を削除する
bool toBool(std::string str, std::string yes, std::string no, bool default_value=true)
与えられた文字列をbool値に変換する
bool isURL(const std::string &str)
与えられた文字列がURLかどうかを判断する
unsigned int replaceString(std::string &str, const std::string from, const std::string to)
文字列を置き換える
bool stringTo< bool >(bool &val, const char *str)
与えられた文字列リストから重複を削除
std::map< std::string, std::string > mapstring
Definition: stringutil.h:46
std::string ptrToHex(T *n)
ポインタを16進数文字列に変換する
Definition: stringutil.h:718
bool includes(const std::string &list, std::string value, bool ignore_case=true)
文字列リスト中にある文字列が含まれるかどうかを判断する
void toLower(std::string &str)
小文字への変換
coil::mapstring urlparam2map(const std::string &str)
与えられた文字列がURLかどうかを判断する
std::string wstring2string(std::wstring wstr)
wstring から string への変換
int getlinePortable(std::istream &istr, std::string &line)
入力ストリームから1行読み込む
std::string sprintf(char const *__restrict fmt,...)
指定された書式に変換
std::wstring string2wstring(std::string str)
string から wstring への変換
bool isEscaped(const std::string &str, std::string::size_type pos)
文字列がエスケープされているか判断する
bool hexToPtr(T *&ptr, const std::string str)
16進数文字列をポインタに変換する
Definition: stringutil.h:751
std::string unescape(const std::string str)
文字列のエスケープを戻す
std::string replaceEnv(std::string str)
文字列中の環境変数を置き換える
std::string escape(const std::string str)
文字列をエスケープする
bool isIPv6(const std::string &str)
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty=false)
文字列を分割文字で分割する
Common Object Interface Layer.
Definition: Affinity.h:28