String
String 类用于处理字符串。
以下列出了 String 提供的方法:
body
char * body( void )
获取字符串主体。返回构成字符串主体的字符数组,不以空字符结尾。
compare
int compare( char const * str )
将当前 Value (this
) 与参数str
进行比较。
- 如果
this
小于str
则为负整数值; - 如果它们相等则为零;
- 如果
this
大于str
则为正整数值。
concat
String* concat( String * head, String * tail )
将两个字符串连接起来并返回连接后的字符串结果。
create
String* create( int len )
创建一个指定长度的空String。String* create( char const * str )
创建一个包含指定内容的String。String* create( char const * str, int len )
创建一个具有指定内容和长度的String。
cstr
char * cstr( void )
将String转换为以空结尾的字符串。
format
String* format( char const * fmt, … )
用指定的内容和占位符替换指定的值创建一个String。
indexOf
int indexOf( String * s )
在String中查找指定子字符串的位置。
startsWith
bool startsWith( String * prefix )
检查该String是否以指定的前缀开头。
substr
String* substr( int pos, int len )
从这个String中的起始位置pos提取指定长度的子字符串。
toLowerCase
String* toLowerCase( void )
将String转换为小写。
toUpperCase
String* toUpperCase( void )
将String转换为大写。