string

 

Name

string

Remark

An Origin C string is a null terminated array of characters similar to objects created using the MFC CString class. The Origin C string class includes many useful methods for manipulating strings (text data).

StringArray is type defined as a vector of strings in string.h
See the vector class for a StringArray example

Hierarchy

  • string

Examples

EX1

void string_ex1()
{
        string str = "  abcdefg   ";
        str.TrimRight();//Trim leading whitespace characters from the string
        
        str.TrimLeft();//Trim trailing whitespace characters from the string
        
        int nRet;
        nRet = str.Compare("abcdefg");//Compare the trimmed string with "abcdefg"
        out_int("", nRet); //Return 0 since they are identical
        
        str = str.Left(5); //Extract the leftmost 5 characters 
        
        str = str.Mid(1, 4); //Extract a substring of 4 characters from the 2nd character
        
        nRet = str.Compare("bcde");//Compare the extracted string with "abcdefg"
        out_int("", nRet); //Return 0 since they are identical
        
        nRet = str.Find('d');//Find the index of 'd' in the string 
        out_int("", nRet); //the index is 2(zero based)

}

header to Include

origin.h

Reference

Members

Name Brief Example
Compare Perform a case-sensitive comparison of this string object with another string. Examples
CompareNoCase Perform a case-insensitive comparison of this string object with another string. Examples
Count Count number of occurances of specified character in string. Support wide characters Examples
Delete Delete a character or characters from a string starting with the character at nIndex. If nCount is longer than the string, the remainder of the string will be removed. Examples
Empty Make this string object an empty string (0 length) and free memory as appropriate. Examples
Find Search this string for the first match of a single character. Examples
FindOneOf Search this string for the first character that matches any character contained in lpszCharSet. Examples
FindToken Find a token in this string Examples
Format Format and store a series of characters and values in the string Examples
GetAt Return a single character specified by an index number. Examples
GetBuffer Retrieve a pointer to the internal character buffer for the string. Examples
GetBufferSetLength Retrieve a pointer to the internal character buffer for the string. Truncating or growing its length, if necessary, to exactly match the length specified in nNewLength. Examples
GetBytes Copy the charactors of this string into a byte vector Examples
GetLength Return the number of bytes (or number of characters) in this string object. The count does not include a null terminator. Examples
GetNumTokens Return the number of tokens in this string where a token is separated by the delimiter specified by chDelimiter. Examples
GetToken Return the token at nToken index in a string where a token is separated by the delimiter specified by chDelimiter. Examples
GetTokens Create a StringArray from this string, this process depend on code page, default is system code page,it can be changed by function set_code_page_for_string_process Examples
Insert Insert a character or substring at the given index within the string. Examples
IsEmpty Test a string object for the empty condition,check whether the string object contains any characters or not. Examples
IsFile Test to see whether the string is a valid full path file name or not. Examples
IsPath Test to see whether a string object is a valid path or not.The path should be exist. Examples
Left Extract the leftmost nCount characters from this string object and return a copy of the extracted substring.If nCount exceeds the string length,then the entire string is extracted. Examples
MakeLower Convert this string object to a lowercase string. Examples
MakeUpper Convert this string object to an uppercase string. Examples
MakeValidCName Modify a string to be a valid C identifier name. A valid C Identifier name must begin with a letter and can contain only letters, numbers, and underscore characters. Examples
Match String pattern matching, any number of wildchars are supported, which can be * or ?. Examples
Mid Extract a substring of length nCount characters from this string object, starting at position nFirst (zero-based). Examples
ReleaseBuffer Use ReleaseBuffer to end use of a buffer allocated by GetBuffer. Examples
Remove Remove instances of the input char from the string. Comparisons for the character are case-sensitive. Examples
Replace Replace a character with another. (Comparison is case-sensitive in all cases.) Examples
ReverseFind Search this string object for the last match of a character. Examples
Right Extract the rightmost nCount characters from this string object and returns a copy of the extracted substring.If nCount exceeds the string length,then the entire string is extracted. Examples
SetAt Overwrite a single character specified by an index number.SetAt will not enlarge the string if the index exceeds the bounds of the existing string. Examples
SetBytes Set the content of this string from a vector of bytes Examples
SetTokens Copy a StringArray into this string and separate them with specified delimiter Examples
SpanExcluding Search the string for the first occurrence of any character in the specified set lpszCharSet. Examples
SpanIncluding Extract characters from the string,starting with the first character,that are in the set of characters identified by lpszCharSet. Examples
string Default constructor, creates a new empty string object Examples
TrimLeft Trim leading whitespace characters from the string. It removes newline, space, and tab characters. Examples
TrimRight Trim trailing whitespace characters from the string. It removes trailing newline, space, and tab characters. Examples
Write Output the string. Examples
WriteLine Output the string adding return and newline characters automatically. Examples