implements of string function More...
#include "stdafx.h"#include "StringFunctions.h"#include "CoreMacros.h"#include <stdio.h>#include <stdarg.h>#include <stdlib.h>#include <set>#include <list>#include <boost/regex.hpp>
Go to the source code of this file.
Macros | |
| #define | TMP_STRING "MaSs2pLus0PlUs1tMp1sTrInG" |
Functions | |
| std::string | strfmt (const char *fmt,...) |
| get formated string More... | |
| std::string | wstr2str (std::wstring &ws) |
| convert wstring to string More... | |
| std::wstring | str2wstr (std::string &s) |
| convert string to wstring More... | |
| std::string | tolowercase (const char *s) |
| convert all of the characters in the string given to lower case More... | |
| std::string | touppercase (const char *s) |
| convert all of the characters int the string given to upper case More... | |
| int | compareignorecase (const char *s1, const char *s2) |
| compare two strings ignoring case considerations More... | |
| unsigned int | stringtoken (const char *s, const char *delim, std::vector< std::string > &tokens) |
| get tokens from string More... | |
| unsigned int | stringseparate (const char *s, const char *separator, std::vector< std::string > &tokens) |
| separates string More... | |
| bool | isint (const char *s, const int radix, int *val) |
| judge whether sutisfied character string shows integer number. More... | |
| int | toint (const char *s, const int radix, const int dfval) |
| convert string into integer More... | |
| bool | isint64 (const char *s, const int radix, long long *val) |
| judge whether sutisfied character string shows 64 bit integer number. More... | |
| long long | toint64 (const char *s, const int radix, const long long dfval) |
| convert string into 64 bit integer More... | |
| bool | isdouble (const char *s, double *val) |
| judge whether sutisfied character string shows real number. More... | |
| double | todouble (const char *s, const double dfval) |
| convert string into double More... | |
| bool | tobool (const char *s, bool dfVal) |
| get true or false from character string. More... | |
| std::string | trimstring (const char *s) |
| remove white spaces from both ends of specified string More... | |
| bool | startswith (const char *s, const char *prefix) |
| judges whether there is a sub-string at the start of string More... | |
| bool | endswith (const char *s, const char *suffix) |
| judge whether there is a sub-string at the end of string More... | |
| std::string | replacestring (const char *s, const char *oldStr, const char *newStr) |
| replaces specified substring with another one More... | |
| std::string | shortenstring (const char *s, const unsigned int len, const bool cutTail) |
| shorten the specified string More... | |
| std::string | regexsearch (const char *s, const char *regex) |
| search string using regular expression. More... | |
Variables | |
| const char * | g_whiteSpaces = " \t\r\n" |
| white spaces | |
| std::set< char > | g_whiteSpacesSet |
| white spaces set | |
implements of string function
Copyright(C) 2006-2014 Eisai Co., Ltd. All rights reserved.
Definition in file StringFunctions.cpp.
| int compareignorecase | ( | const char * | s1, |
| const char * | s2 | ||
| ) |
compare two strings ignoring case considerations
| [in] | s1 | the string to compare |
| [in] | s2 | the string to be compared |
Definition at line 159 of file StringFunctions.cpp.

| bool endswith | ( | const char * | s, |
| const char * | suffix | ||
| ) |
judge whether there is a sub-string at the end of string
| [in] | s | string to test |
| [in] | suffix | sub-string to be checked |
Definition at line 536 of file StringFunctions.cpp.
| bool isdouble | ( | const char * | s, |
| double * | val = NULL |
||
| ) |
judge whether sutisfied character string shows real number.
| [in] | s | character string |
| [out] | val | If sutisfied characgter string is real number, the number is stored in val. If val is NULL, the number is not stored. |
Definition at line 406 of file StringFunctions.cpp.
| bool isint | ( | const char * | s, |
| const int | radix = 10, |
||
| int * | val = NULL |
||
| ) |
judge whether sutisfied character string shows integer number.
| [in] | s | character string |
| [in] | radix | radix |
| [out] | val | If sutisfied character string is integer number, the number is stored in val. If val is NULL, the number is not stored. |
Definition at line 308 of file StringFunctions.cpp.
| bool isint64 | ( | const char * | s, |
| const int | radix = 10, |
||
| long long * | val = NULL |
||
| ) |
judge whether sutisfied character string shows 64 bit integer number.
| [in] | s | character string |
| [in] | radix | radix |
| [out] | val | If sutisfied character string is integer number, the number is stored in val. If val is NULL, the number is not stored. |
Definition at line 354 of file StringFunctions.cpp.
| std::string regexsearch | ( | const char * | s, |
| const char * | regex | ||
| ) |
search string using regular expression.
| [in] | s | string |
| [in] | regex | regular expression |
Definition at line 606 of file StringFunctions.cpp.
| std::string replacestring | ( | const char * | s, |
| const char * | oldStr, | ||
| const char * | newStr | ||
| ) |
replaces specified substring with another one
| [in] | s | character string to be replaced substring |
| [in] | oldStr | character string to be replaced |
| [in] | newStr | character string to replace |
Definition at line 548 of file StringFunctions.cpp.

| std::string shortenstring | ( | const char * | s, |
| const unsigned int | len, | ||
| const bool | cutTail | ||
| ) |
shorten the specified string
| [in] | s | source string |
| [in] | len | maximum the length of string |
| [in] | cutTail | If true, the tail of the string is cut, otherwise the head of the string is cut. |
Definition at line 578 of file StringFunctions.cpp.
| bool startswith | ( | const char * | s, |
| const char * | prefix | ||
| ) |
judges whether there is a sub-string at the start of string
| [in] | s | string to test |
| [in] | prefix | sub-string to be checked |
Definition at line 524 of file StringFunctions.cpp.
| std::wstring str2wstr | ( | std::string & | s | ) |
convert string to wstring
| [in] | s | string |
Definition at line 97 of file StringFunctions.cpp.
| std::string strfmt | ( | const char * | fmt, |
| ... | |||
| ) |
get formated string
| [in] | fmt | format |
Definition at line 42 of file StringFunctions.cpp.
| unsigned int stringseparate | ( | const char * | s, |
| const char * | separator, | ||
| std::vector< std::string > & | tokens | ||
| ) |
separates string
| [in] | s | string |
| [in] | separator | separator |
| [out] | tokens | the array to store tokens |
Definition at line 242 of file StringFunctions.cpp.
| unsigned int stringtoken | ( | const char * | s, |
| const char * | delim, | ||
| std::vector< std::string > & | tokens | ||
| ) |
get tokens from string
| [in] | s | string |
| [in] | delim | delimiters |
| [out] | tokens | the array to store tokens |
Definition at line 164 of file StringFunctions.cpp.
| bool tobool | ( | const char * | s, |
| bool | dfVal = false |
||
| ) |
get true or false from character string.
| [in] | s | character string |
| [in] | dfVal | defaultvalue |
Definition at line 450 of file StringFunctions.cpp.

| double todouble | ( | const char * | s, |
| const double | dfval = 0.0 |
||
| ) |
convert string into double
| [in] | s | character string converted into double |
| [in] | dfval | default value |
Definition at line 433 of file StringFunctions.cpp.
| int toint | ( | const char * | s, |
| const int | radix = 10, |
||
| const int | dfval = 0 |
||
| ) |
convert string into integer
| [in] | s | character string converted into integer. |
| [in] | radix | radix |
| [in] | dfval | default value |
Definition at line 336 of file StringFunctions.cpp.
| long long toint64 | ( | const char * | s, |
| const int | radix = 10, |
||
| const long long | dfval = 0 |
||
| ) |
convert string into 64 bit integer
| [in] | s | character string converted into integer. |
| [in] | radix | radix |
| [in] | dfval | default value |
Definition at line 382 of file StringFunctions.cpp.
| std::string tolowercase | ( | const char * | s | ) |
convert all of the characters in the string given to lower case
| [in] | s | string before converted to lower case |
Definition at line 121 of file StringFunctions.cpp.
| std::string touppercase | ( | const char * | s | ) |
convert all of the characters int the string given to upper case
| [in] | s | string before converted to upper case |
Definition at line 140 of file StringFunctions.cpp.
| std::string trimstring | ( | const char * | s | ) |
remove white spaces from both ends of specified string
| [in] | s | character string to be trimmed |
Definition at line 467 of file StringFunctions.cpp.
| std::string wstr2str | ( | std::wstring & | ws | ) |
convert wstring to string
| [in] | ws | wstring |
Definition at line 73 of file StringFunctions.cpp.
1.8.6