34 static const char CHARS[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
35 static const size_t CHARS_COUNT =
sizeof( CHARS ) /
sizeof(
char );
39 for(; 0 < length; --length)
47 return 0 != isdigit( c );
67 for(; len > 0; ++str, --len)
71 if( !seenDec &&
'.' == *str )
83 return IsNumber( str.c_str(), str.length() );
88 return 0 != isxdigit( c );
119 for(; len > 0; ++str, --len)
136 const unsigned char _c = c;
138 return ( isgraph( _c ) || isspace( _c ) );
143 for(; len > 0; ++str, --len)
157 #define _ITOA_BUFLEN 21
169 void ListToINString(
const std::vector<int32>& ints, std::string& into,
const char* if_empty )
185 size_t format_index = into.size();
186 into.resize( format_index + ints.size() * ( 10 + 1 ) );
188 std::vector<int32>::const_iterator cur, end;
191 for(; cur != end; ++cur)
193 if( ( cur + 1 ) != end )
194 format_index +=
snprintf( &into[ format_index ], 12,
"%i,", *cur );
197 format_index +=
snprintf( &into[ format_index ], 11,
"%i", *cur );
206 for(; *source; ++target, ++source )
207 *target = toupper( *source );
217 for(; *source; ++target, ++source )
218 *target = tolower( *source );
225 const size_t len = strlen( str );
226 const char*
const end = str + len;
232 into.
Append<
char >( *str++ );
245 case '\\': into.
Append<
char >(
'\\' );
break;
246 case '\'': into.
Append<
char >(
'\'' );
break;
247 case '\"': into.
Append<
char >(
'\"' );
break;
248 case 'b': into.
Append<
char >(
'\b' );
break;
249 case 'f': into.
Append<
char >(
'\014' );
break;
250 case 't': into.
Append<
char >(
'\t' );
break;
251 case 'n': into.
Append<
char >(
'\n' );
break;
252 case 'r': into.
Append<
char >(
'\r' );
break;
253 case 'v': into.
Append<
char >(
'\013' );
break;
254 case 'a': into.
Append<
char >(
'\007' );
break;
265 if(
'0' <= *str && *str <=
'7' )
267 c = ( c << 3 ) + *str++ -
'0';
268 if(
'0' <= *str && *str <=
'7' )
269 c = ( c << 3 ) + *str++ -
'0';
275 if( isxdigit( str[0] ) && isxdigit( str[1] ) )
282 else if( islower(c) )
292 else if( islower(c) )
311 void SearchReplace( std::string& subject,
const std::string& search,
const std::string& replace )
313 std::string::size_type pos = 0;
314 while( ( pos = subject.find( search, pos ) ) != std::string::npos )
316 subject.replace( pos, search.length(), replace );
317 pos += replace.length();
321 void SplitPath(
const std::string& path, std::vector<std::string>& into )
323 const char* p = path.c_str();
324 const char* begin = p;
327 for(; *p !=
'\0'; ++p)
329 if( *p ==
'/' || *p ==
'\\' )
331 into.push_back( std::string( begin, len ) );
342 into.push_back( std::string( begin, len ) );
void Append(const T &value)
Appends a single value to buffer.
bool PyDecodeEscape(const char *str, Buffer &into)
Decodes string escapes into actual characters.
void SplitPath(const std::string &path, std::vector< std::string > &into)
Splits path to its components.
bool IsPrintable(char c)
Checks whether character is printable.
Generic class for buffers.
void MakeLowerString(const char *source, char *target)
tolower() for strings.
bool IsHexNumber(char c)
Checks whether character is a hexadecimal number.
void MakeUpperString(const char *source, char *target)
toupper() for strings.
const std::string NULL_STRING
std::string to use where you would use NULL for const char*.
bool IsNumber(char c)
Checks whether character is a number.
int64 MakeRandomInt(int64 low, int64 high)
Generates random integer from interval [low; high].
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
std::string GenerateKey(size_t length)
Generates random key.
void SearchReplace(std::string &subject, const std::string &search, const std::string &replace)
Does search & replace on subject.
void ListToINString(const std::vector< int32 > &ints, std::string &into, const char *if_empty)
const char * itoa(int64 num)
Convers num to string.