version 1.94.2.1, 2006/02/10 16:09:38
|
version 1.101, 2008/11/24 18:52:15
|
|
|
class String; | class String; |
struct StringRep; | struct StringRep; |
| |
/** The CString class provides access to an 8-bit String representation. |
/** |
|
The CString class provides access to an 8-bit String representation. |
*/ | */ |
class PEGASUS_COMMON_LINKAGE CString | class PEGASUS_COMMON_LINKAGE CString |
{ | { |
public: | public: |
| |
/** Constructs a CString object with null values (default constructor). |
/** |
|
Constructs a CString object with a null string value. |
*/ | */ |
CString(); | CString(); |
| |
/** REVIEWERS: Describe method here. |
/** |
@param cstr Specifies the name of the CString instance to copy. |
Constructs an independent copy of a CString object. |
|
@param cstr The CString instance to copy. |
*/ | */ |
CString(const CString& cstr); | CString(const CString& cstr); |
| |
/** CString destructor. |
/** |
|
Destructs a CString object. |
*/ | */ |
~CString(); | ~CString(); |
| |
/** Assigns the values of one CString instance to another. |
/** |
@param cstr Specifies the name of the CString instance whose values |
Copies the value of another CString object. |
are assigned to CString. |
@param cstr The CString object from which to copy the value. |
|
@return A reference to the target CString object with its newly |
|
assigned value. |
*/ | */ |
CString& operator=(const CString& cstr); | CString& operator=(const CString& cstr); |
| |
/** Gets a pointer to the CString's data. |
/** |
|
Gets the CString's data as a C string pointer. IMPORTANT: The |
|
returned pointer refers to memory owned by the CString object. The |
|
caller must not free this memory. The returned pointer is valid only |
|
until the CString object is destructed or reassigned. Use of this |
|
operator on a temporary CString object may result in a memory error. |
|
For example, this usage is invalid: |
|
|
|
const char* cstr = String("Hello").getCString(); |
|
printf(cstr); |
|
|
@return Returns a const char pointer to the CString's data. | @return Returns a const char pointer to the CString's data. |
*/ | */ |
operator const char*() const; | operator const char*() const; |
|
|
}; | }; |
| |
/** | /** |
The Pegasus String C++ Class implements the CIM string type. |
This class implements the CIM string type. The intrinsic string format |
REVIEWERS: We need more definition here. |
is UTF-16, which is a superset of the UCS-2 characters allowed in CIM |
|
strings. Facilities are provided for converting to and from UTF-8 |
|
character strings. |
|
|
|
Many of the method interfaces refer to a number of characters. In all |
|
cases, these characters are counted as 8- or 16-bit memory chunks rather |
|
than logical UTF-8 or UTF-16 character chains. |
*/ | */ |
class PEGASUS_COMMON_LINKAGE String | class PEGASUS_COMMON_LINKAGE String |
{ | { |
public: | public: |
| |
/** This member is used to represent an empty string. Using this |
/** |
member avoids construction of an empty string (for example, String()). |
Represents an empty string. This value may be used as a convenience |
|
to avoid construction of an empty String object. |
*/ | */ |
static const String EMPTY; | static const String EMPTY; |
| |
/** Default constructor without parameters. This constructor creates a |
/** |
null string. For example, |
Constructs an empty String. |
<pre> |
|
String test; |
|
</pre> |
|
@exception bad_alloc Thrown if there is insufficient memory. |
|
*/ | */ |
String(); | String(); |
| |
/** Copy constructor. |
/** |
@param str Specifies the name of the String instance. |
Constructs a String with the value of another String. |
@exception bad_alloc Thrown if there is insufficient memory. |
@param str The String from which to copy the value. |
*/ | */ |
String(const String& str); | String(const String& str); |
| |
/** Initialize with first <TT>n</TT> characters from <TT>str</TT>. |
/** |
@param str Specifies the name of the String instance. |
Constructs a String with a specified number of characters of the |
@param n Specifies Uint32 size to use for the length of the string object. |
value of another String. |
@exception bad_alloc Thrown if there is insufficient memory. |
@param str The String from which to copy the value. |
|
@param n A Uint32 specifying the number of characters to copy. |
|
@exception IndexOutOfBoundsException If the specified String does not |
|
contain the specified number of characters. |
|
@exception bad_alloc If the construction fails because of a memory |
|
allocation failure. |
*/ | */ |
String(const String& str, Uint32 n); | String(const String& str, Uint32 n); |
| |
/** Initialize with str. |
/** |
@param str Specifies the name of the String instance. |
Constructs a String with the value from a Char16 buffer. |
@exception NullPointer Thrown if str is NULL. |
@param str The Char16 buffer from which to copy the value. |
@exception bad_alloc Thrown if there is insufficient memory. |
@exception NullPointer If the buffer pointer is NULL. |
|
@exception bad_alloc If the construction fails because of a memory |
|
allocation failure. |
*/ | */ |
String(const Char16* str); | String(const Char16* str); |
| |
/** Initialize with first n characters of str. |
/** |
@param str Specifies the name of the String instance. |
Constructs a String with a specified number of characters of the |
@param n Specifies the Uint32 size. |
value from a Char16 buffer. |
@exception NullPointer Thrown if str is NULL. |
@param str The Char16 buffer from which to copy the value. |
@exception bad_alloc Thrown if there is insufficient memory. |
@param n A Uint32 specifying the number of characters to copy. |
|
@exception NullPointer If the buffer pointer is NULL. |
|
@exception bad_alloc If the construction fails because of a memory |
|
allocation failure. |
*/ | */ |
String(const Char16* str, Uint32 n); | String(const Char16* str, Uint32 n); |
| |
/** Initialize from a plain C-String: |
/** |
@param str Specifies the name of the String instance. |
Constructs a String with the value from a C string in UTF-8 format. |
API supports UTF8 |
@param str The C string from which to copy the value. |
@exception NullPointer Thrown if str is NULL. |
@exception NullPointer If the C string pointer is NULL. |
@exception bad_alloc Thrown if there is insufficient memory. |
@exception bad_alloc If the construction fails because of a memory |
|
allocation failure. |
|
@exception Exception If the C string contains invalid UTF-8. |
*/ | */ |
String(const char* str); | String(const char* str); |
| |
/** Initialize from the first <TT>n</TT> characters of a plain C-String: |
/** |
@param str Specifies the name of the String instance. |
Constructs a String with a specified number of characters of the |
@param u Specifies the Uint32 size. |
value from a C string in UTF-8 format. |
API supports UTF8 |
@param str The C string from which to copy the value. |
@exception NullPointer Thrown if str is NULL. |
@param n A Uint32 specifying the number of characters to copy. |
@exception bad_alloc Thrown if there is insufficient memory. |
@exception NullPointer If the C string pointer is NULL. |
|
@exception bad_alloc If the construction fails because of a memory |
|
allocation failure. |
|
@exception Exception If the C string contains invalid UTF-8. |
*/ | */ |
String(const char* str, Uint32 n); | String(const char* str, Uint32 n); |
| |
/** String destructor. |
/** |
|
Destructs a String object. |
*/ | */ |
~String(); | ~String(); |
| |
/** Assign this string with str. For example, |
/** |
<pre> |
Assigns the value of a String to the value of another String. |
String t1 = "abc"; |
@param str The String from which to copy the value. |
String t2 = t1; |
@return A reference to the target String object with its newly |
</pre> |
assigned value. |
String t2 is assigned the value of t1. |
@exception bad_alloc If the assignment fails because of a memory |
@param str Specifies the name of the String to assign to another |
allocation failure. |
String instance. |
|
@exception bad_alloc Thrown if there is insufficient memory. |
|
*/ | */ |
String& operator=(const String& str); | String& operator=(const String& str); |
| |
/** Assign this string with String str. |
/** |
@param str String to assign. |
Assigns the value of a String to the value of another String. |
@return Returns the String. |
@param str The String from which to copy the value. |
API supports UTF8 |
@return A reference to the target String object with its newly |
@exception bad_alloc Thrown if there is insufficient memory. |
assigned value. |
|
@exception bad_alloc If the assignment fails because of a memory |
|
allocation failure. |
*/ | */ |
String& assign(const String& str); | String& assign(const String& str); |
| |
/** Assign this string with str. |
/** |
@exception NullPointer Thrown if str is NULL. |
Assigns the value of a String to the value in a Char16 buffer. |
@exception bad_alloc Thrown if there is insufficient memory. |
@param str The Char16 buffer from which to copy the value. |
|
@return A reference to the target String object with its newly |
|
assigned value. |
|
@exception NullPointer If the buffer pointer is NULL. |
|
@exception bad_alloc If the assignment fails because of a memory |
|
allocation failure. |
*/ | */ |
String& assign(const Char16* str); | String& assign(const Char16* str); |
| |
/** Assign this string with first n characters of str. |
/** |
@param n REVIEWERS: Insert text here. |
Assigns the value of a String with a specified number of characters |
@param str REVIEWERS: Insert text here. |
of the value from a Char16 buffer. |
@exception NullPointer Thrown if str is NULL. |
@param str The Char16 buffer from which to copy the value. |
@exception bad_alloc Thrown if there is insufficient memory. |
@param n A Uint32 specifying the number of characters to copy. |
|
@return A reference to the target String object with its newly |
|
assigned value. |
|
@exception NullPointer If the buffer pointer is NULL. |
|
@exception bad_alloc If the assignment fails because of a memory |
|
allocation failure. |
*/ | */ |
String& assign(const Char16* str, Uint32 n); | String& assign(const Char16* str, Uint32 n); |
| |
/** Assign this string with the plain C-String str. |
/** |
@param str REVIEWERS: Insert text here. |
Assigns the value of a String to the value from a C string in UTF-8 |
API supports UTF8 |
format. |
@exception NullPointer Thrown if str is NULL. |
@param str The C string from which to copy the value. |
@exception bad_alloc Thrown if there is insufficient memory. |
@return A reference to the target String object with its newly |
|
assigned value. |
|
@exception NullPointer If the C string pointer is NULL. |
|
@exception bad_alloc If the assignment fails because of a memory |
|
allocation failure. |
|
@exception Exception If the C string contains invalid UTF-8. |
*/ | */ |
String& assign(const char* str); | String& assign(const char* str); |
| |
/** Assign this string with first n characters of the plain C-String str. |
/** |
@param str REVIEWERS: Insert text here. |
Assigns the value of a String with a specified number of characters |
@param n REVIEWERS: Insert text here. |
of the value from a C string in UTF-8 format. |
API supports UTF8 |
@param str The C string from which to copy the value. |
@exception NullPointer Thrown if str is NULL. |
@param n A Uint32 specifying the number of characters to copy. |
@exception bad_alloc Thrown if there is insufficient memory. |
@return A reference to the target String object with its newly |
|
assigned value. |
|
@exception NullPointer If the C string pointer is NULL. |
|
@exception bad_alloc If the assignment fails because of a memory |
|
allocation failure. |
|
@exception Exception If the C string contains invalid UTF-8. |
*/ | */ |
String& assign(const char* str, Uint32 n); | String& assign(const char* str, Uint32 n); |
| |
/** Clear this string. After calling clear(), size() will return 0. |
/** |
<pre> |
Sets a String value to the empty String. |
String test = "abc"; |
|
test.clear(); |
|
</pre> |
|
*/ | */ |
void clear(); | void clear(); |
| |
/** Reserves memory for capacity characters. Notice |
/** |
that this does not change the size of the string (size() returns |
Reserves memory for a specified number of (16-bit) characters. |
what it did before). If the capacity of the string is already |
This method does not change the size() of the string or any other |
greater or equal to the capacity argument, this method has no |
external behavior. If the capacity of the string is already greater |
effect. The capacity of a String object has no bearing on its |
than or equal to the specified size, this method has no effect. The |
external behavior. The capacity of a String is set only for |
capacity of a String is set only for performance reasons. |
performance reasons. |
@param capacity A Uint32 specifying the number of characters the |
@param capacity Defines the capacity in characters to reserve. |
String should be prepared to hold. |
*/ | */ |
void reserveCapacity(Uint32 capacity); | void reserveCapacity(Uint32 capacity); |
| |
/** Returns the length of the String object. |
/** |
@return Length of the String in characters. For example, |
Returns the number of characters in a String value. No termination |
<pre> |
character is included in the count. For example, String("abcd").size() |
String s = "abcd"; |
returns 4. |
assert(s.size() == 4); |
|
</pre> |
|
returns a value of 4 for the length. |
|
*/ | */ |
Uint32 size() const; | Uint32 size() const; |
| |
/** Returns a pointer to the first character in the |
/** |
null-terminated Char16 buffer of the String object. |
Gets a null-terminated Char16 buffer containing the String value. |
@return Pointer to the first character of the String object. For example, |
The buffer is valid until the original String object is modified or |
<pre> |
destructed. |
String test = "abc"; |
@return A pointer to a null-terminated Char16 buffer containing the |
const Char16* q = test.getChar16Data(); |
String value. |
</pre> |
|
points to the first character in the String instance named test. |
|
*/ | */ |
const Char16* getChar16Data() const; | const Char16* getChar16Data() const; |
| |
/** Create an 8-bit representation of this String object. For example, |
/** |
|
Gets a CString object containing the String value in UTF-8 format. |
@return CString object that provides access to the UTF8 String |
Important: A character pointer extracted from a CString object is |
representation. |
only valid while the CString object exists and is unmodified. (See |
|
the CString documentation.) Thus, in the following example, the |
|
variable p holds a dangling (invalid) pointer: |
<pre> | <pre> |
String test = "abc"; |
|
printf("test = %s\n", (const char*)test.getCString()); |
|
|
|
USAGE WARNING: Do not do the following: |
|
|
|
const char * p = (const char *)test.getCString(); | const char * p = (const char *)test.getCString(); |
|
|
The pointer p will be invalid. This is because |
|
the Compiler casues the CString object to be created on the |
|
callers stack as a temporary object. The deletion is therefore |
|
also the responsibility of the Compiler. The Compiler may cause |
|
it to be deleted at anytime after the return. Typically it is |
|
done at the closeof the next scope. When it is deleted the |
|
"const char *p" above will become a dangling pointer. |
|
|
|
The correct usage to achieve the "const char * p" is |
|
as follows: |
|
|
|
String str = "hello"; |
|
... |
|
CString cstr = str.getCString(); |
|
|
|
const char* p = (const char*)cstr; |
|
|
|
This tells the compiler to create a CString object on the callers |
|
stack that is the deleted at the discretion of the caller rather |
|
than the compiler. The "const char *p" above will be good until |
|
the caller explicity deletes the CString object. |
|
|
|
|
|
</pre> | </pre> |
@exception bad_alloc Thrown if there is insufficient memory. |
This situation can be corrected by declaring a CString variable in |
|
the same scope. |
|
|
|
@return A CString object containing the String value in UTF-8 format. |
|
@exception bad_alloc If the operation fails because of a memory |
|
allocation failure. |
*/ | */ |
CString getCString() const; | CString getCString() const; |
| |
/** Returns the specified character of the String object. |
/** |
|
Gets a specified character from the String value. |
@param index Index of the character to access. | @param index Index of the character to access. |
@return Specified character of the String object. |
@return The Char16 character at the specified index. |
@exception IndexOutOfBoundsException If <TT>index</TT> |
@exception IndexOutOfBoundsException If the String does not contain a |
is outside the bounds of the String. |
character at the specified index. |
<pre> |
|
String test = "abc; |
|
Char16 c = test[1]; |
|
</pre> |
|
*/ | */ |
Char16& operator[](Uint32 index); | Char16& operator[](Uint32 index); |
| |
/** Returns the specified character of the String object (const version). |
/** |
|
Gets a specified character from the String value. |
@param index Index of the character to access. | @param index Index of the character to access. |
@return Specified character of the String object. |
@return The Char16 character at the specified index. |
@exception IndexOutOfBoundsException If <TT>index</TT> |
@exception IndexOutOfBoundsException If the String does not contain a |
is outside the bounds of the String. |
character at the specified index. |
*/ | */ |
const Char16 operator[](Uint32 index) const; | const Char16 operator[](Uint32 index) const; |
| |
/** Append the given character to this String. |
/** |
@param c Character to append. |
Appends a character to the String. |
@return This String. |
@param c The Char16 character to append. |
<pre> |
@return A reference to the String object containing the newly appended |
String test = "abc"; |
character. |
test.append(Char16('d')); |
@exception bad_alloc If the append fails because of a memory |
assert(test == "abcd"); |
allocation failure. |
</pre> |
|
@exception bad_alloc Thrown if there is insufficient memory. |
|
*/ | */ |
String& append(const Char16& c); | String& append(const Char16& c); |
| |
/** Append n characters from str to this String. |
/** |
@param str REVIEWERS: Insert text here. |
Appends a specified number of characters to the String from a Char16 |
@param n REVIEWERS: Insert text here. |
buffer. |
@exception NullPointer Thrown if str is NULL. |
@param str The Char16 buffer from which to append the characters. |
@exception bad_alloc Thrown if there is insufficient memory. |
@param n A Uint32 specifying the number of characters to append from |
|
the buffer. |
|
@return A reference to the String object containing the newly appended |
|
characters. |
|
@exception NullPointer If the buffer pointer is NULL. |
|
@exception bad_alloc If the append fails because of a memory |
|
allocation failure. |
*/ | */ |
String& append(const Char16* str, Uint32 n); | String& append(const Char16* str, Uint32 n); |
| |
/** Append the given String to this String. |
/** |
@param str String to append. |
Appends a String value to the String. |
@return This String. |
@param str The String to append. |
<pre> |
@return A reference to the String object containing the newly appended |
String test = "abc"; |
characters. |
test.append("def"); |
@exception bad_alloc If the append fails because of a memory |
assert(test == "abcdef"); |
allocation failure. |
</pre> |
|
@exception bad_alloc Thrown if there is insufficient memory. |
|
*/ | */ |
String& append(const String& str); | String& append(const String& str); |
| |
/** Remove size characters from the string starting at the given |
/** |
index. If size is PEG_NOT_FOUND, then all characters after |
Removes a specified number of characters from the String starting at a |
<TT>index</TT> are removed. |
given index. If the number of characters to remove is specified as |
@param index Position in string to start remove. |
PEG_NOT_FOUND, then all characters from the index to the end of the |
@param size Number of characters to remove. Default is PEG_NOT_FOUND |
String are removed. |
which causes all characters after <TT>index</TT> to be removed. |
@param index Uint32 position in String from which to remove characters. |
<pre> |
@param size A Uint32 specifying the number of characters to remove. |
String s; |
The default value is PEG_NOT_FOUND, which means all characters |
s = "abc"; |
from the index to the end of the String are to be removed. |
s.remove(0, 1); |
@exception IndexOutOfBoundsException If the index plus the size (if not |
assert(String::equal(s, "bc")); |
PEG_NOT_FOUND) is greater than the number of characters in the |
assert(s.size() == 2); |
String. |
s.remove(0); |
|
assert(String::equal(s, "")); |
|
assert(s.size() == 0); |
|
</pre> |
|
@exception IndexOutOfBoundsException If size is greater than |
|
length of String plus starting index for remove. |
|
*/ | */ |
void remove(Uint32 index, Uint32 size = PEG_NOT_FOUND); | void remove(Uint32 index, Uint32 size = PEG_NOT_FOUND); |
| |
/** Return a new String which is initialzed with <TT>length</TT> |
/** |
characters from this string starting at <TT>index</TT>. |
Creates a new String containing up to the specified number of |
@param index Specifies the index in string to start getting the |
characters from the specified index in the String. |
substring. |
@param index A Uint32 specifying the index at which to copy characters |
@param length Specifies the number of characters to get. If length |
into the new String. |
is PEG_NOT_FOUND, then all characters after index are added to the new |
@param n A Uint32 specifying the maximum number of characters to copy |
string. |
into the new String. If the value is PEG_NOT_FOUND or is greater |
@return String Specifies the Sting with the defined substring. |
than the number of characters from the index to the end of the |
@exception bad_alloc Thrown if there is insufficient memory. |
String, the new String contains all characters from the index to |
*/ |
the end of the String. |
String subString(Uint32 index, Uint32 length = PEG_NOT_FOUND) const; |
@return A new String containing up to the specified number of |
|
characters from the specified index in the String. |
/** Find the index of the first occurrence of the character c. |
@exception bad_alloc If the operation fails because of a memory |
If the character is not found, PEG_NOT_FOUND is returned. |
allocation failure. |
@param c Char to be found in the String. |
*/ |
@return Position of the character in the string or PEG_NOT_FOUND if not |
String subString(Uint32 index, Uint32 n = PEG_NOT_FOUND) const; |
found. |
|
|
/** |
|
Finds the index of the first occurrence of a specified character in |
|
the String. If the character is not found, PEG_NOT_FOUND is returned. |
|
@param c The Char16 value to find in the String. |
|
@return The Uint32 index of the character in the String if found, |
|
PEG_NOT_FOUND otherwise. |
*/ | */ |
Uint32 find(Char16 c) const; | Uint32 find(Char16 c) const; |
| |
/** Find the index of the first occurence of the character c. |
/** |
If the character is not found, PEG_NOT_FOUND is returned. |
Finds the index of the first occurrence of a specified character in |
Searching begins from the specified index. |
the String beginning at a specified index. If the character is not |
@param c Char to be found in the String. |
found, PEG_NOT_FOUND is returned. |
@return Position of the character in the string or PEG_NOT_FOUND if the |
@param c The Char16 value to find in the String. |
character is not found. |
@param index The Uint32 index at which to start the search. |
|
@return The Uint32 index of the character in the String if found, |
|
PEG_NOT_FOUND otherwise. |
*/ | */ |
Uint32 find(Uint32 index, Char16 c) const; | Uint32 find(Uint32 index, Char16 c) const; |
| |
/** Find the index of the first occurence of the string object. |
/** |
This function finds one string inside another. |
Finds the index of the first occurrence of a specified String value in |
If the matching substring is not found, PEG_NOT_FOUND is returned. |
the String. If the String value is not found, PEG_NOT_FOUND is |
@param s String object to be found in the String. |
returned. |
@return Position of the substring in the String or PEG_NOT_FOUND if the |
@param s The String value to find in the String. |
substring is not found. |
@return The Uint32 index of the beginning of the String value if found, |
|
PEG_NOT_FOUND otherwise. |
*/ | */ |
Uint32 find(const String& s) const; | Uint32 find(const String& s) const; |
| |
/** Same as find() but start looking in reverse (last character first). |
/** |
@param c Char16 character to find in String. |
Finds the index of the last occurrence of a specified character in |
@return Position of the character in the string or PEG_NOT_FOUND if the |
the String. If the character is not found, PEG_NOT_FOUND is returned. |
character is not found. |
@param c The Char16 value to find in the String. |
|
@return The Uint32 index of the character in the String if found, |
|
PEG_NOT_FOUND otherwise. |
*/ | */ |
Uint32 reverseFind(Char16 c) const; | Uint32 reverseFind(Char16 c) const; |
| |
/** Converts all characters in this string to lowercase characters, |
/** |
|
Converts all characters in the String to lower case. |
*/ | */ |
void toLower(); | void toLower(); |
| |
#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES | #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES |
/** <I><B>Experimental Interface</B></I><BR> |
/** |
Converts all characters in this string to uppercase characters. |
<I><B>Experimental Interface</B></I><BR> |
|
Converts all characters in the String to upper case. |
*/ | */ |
void toUpper(); | void toUpper(); |
#endif | #endif |
|
|
@param s1 The first String to compare. | @param s1 The first String to compare. |
@param s2 The second String to compare. | @param s2 The second String to compare. |
@param n The maximum number of characters to compare. | @param n The maximum number of characters to compare. |
@return Returns a negative integer if the first n characters of s1 |
@return A negative integer if the first n characters of s1 are |
are lexographically less than s2, 0 if the first n characters of s1 |
lexographically less than s2, 0 if the first n characters of s1 |
and s2 are equal, and a positive integer otherwise. | and s2 are equal, and a positive integer otherwise. |
*/ | */ |
static int compare(const String& s1, const String& s2, Uint32 n); | static int compare(const String& s1, const String& s2, Uint32 n); |
| |
/** | /** |
Compares two String objects. |
Compares two String objects. (Note: Use the comparison |
|
operators < <= > >= to compare String objects.) |
@param s1 The first String to compare. | @param s1 The first String to compare. |
@param s2 The second String to compare. | @param s2 The second String to compare. |
@return Returns a negative integer if s1 is lexographically less |
@return A negative integer if s1 is lexographically less than s2, |
than s2, 0 if s1 and s2 are equal, and a positive integer otherwise. |
0 if s1 and s2 are equal, and a positive integer otherwise. |
|
|
NOTE: Use the comparison operators <,<= > >= to compare |
|
String objects. |
|
*/ | */ |
static int compare(const String& s1, const String& s2); | static int compare(const String& s1, const String& s2); |
| |
|
|
Compares two String objects, ignoring case differences. | Compares two String objects, ignoring case differences. |
@param s1 The first String to compare. | @param s1 The first String to compare. |
@param s2 The second String to compare. | @param s2 The second String to compare. |
@return Returns a negative integer if s1 is lexographically less |
@return A negative integer if s1 is lexographically less than s2, |
than s2, 0 if s1 and s2 are equal, and a positive integer otherwise. |
0 if s1 and s2 are equal, and a positive integer otherwise. |
(Case differences are ignored in all cases.) | (Case differences are ignored in all cases.) |
*/ | */ |
static int compareNoCase(const String& s1, const String& s2); | static int compareNoCase(const String& s1, const String& s2); |
| |
/** Compare two String objects for equality. |
/** |
@param s1 First <TT>String</TT> for comparison. |
Compares two String objects for equality. For example, |
@param s2 Second <TT>String</TT> for comparison. |
|
|
|
@return true If the two strings are equal; otherwise, false. For example, |
|
<pre> | <pre> |
String s1 = "Hello World"; | String s1 = "Hello World"; |
String s2 = s1; | String s2 = s1; |
String s3(s2); |
assert(String::equal(s1, s2)); |
assert(String::equal(s1, s3)); |
|
</pre> | </pre> |
|
@param s1 The first String to compare. |
|
@param s2 The second String to compare. |
|
@return True if the two strings are equal, false otherwise. |
*/ | */ |
static Boolean equal(const String& str1, const String& str2); |
static Boolean equal(const String& s1, const String& s2); |
| |
/** Compares two strings and returns true if they |
/** |
are equal indepedent of case of the characters. |
Compares two strings and returns true if they are equal independent of |
@param str1 First String parameter. |
the case of the characters. |
@param str2 Second String parameter. |
@param s1 The first String to compare. |
@return true If strings are equal independent of case, flase |
@param s2 The second String to compare. |
|
@return true if the strings are equal independent of case, false |
otherwise. | otherwise. |
*/ | */ |
static Boolean equalNoCase(const String& str1, const String& str2); |
static Boolean equalNoCase(const String& s1, const String& s2); |
| |
#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES | #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES |
| |
|
|
StringRep* _rep; | StringRep* _rep; |
}; | }; |
| |
/** String operator == tests for equality between two strings of any of the |
/** |
types String or char*. |
Compares two String objects for equality. |
@return true If the strings are equal; otherwise, false. |
@param str1 The first String to compare. |
@param str1 REVIEWERS: Insert description here. |
@param str2 The second String to compare. |
@param str2 REVIEWERS: Insert description here. |
@return True if the strings are equal, false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator==( | PEGASUS_COMMON_LINKAGE Boolean operator==( |
const String& str1, | const String& str1, |
const String& str2); | const String& str2); |
| |
/** String operator ==. Test for equality between two strings. |
/** |
@param str1 REVIEWERS: Insert description here. |
Compares a String and a C string for equality. |
@param str2 REVIEWERS: Insert description here. |
@param str1 The String to compare. |
|
@param str2 The C string to compare. |
|
@return True if the strings are equal, false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator==(const String& str1, const char* str2); | PEGASUS_COMMON_LINKAGE Boolean operator==(const String& str1, const char* str2); |
| |
/** String operator ==. Test for equality between two strings. |
/** |
@param str1 REVIEWERS: Insert description here. |
Compares a String and a C string for equality. |
@param str2 REVIEWERS: Insert description here. |
@param str1 The C string to compare. |
|
@param str2 The String to compare. |
|
@return True if the strings are equal. false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator==(const char* str1, const String& str2); | PEGASUS_COMMON_LINKAGE Boolean operator==(const char* str1, const String& str2); |
| |
/** String operator ==. Test for equality between two strings. |
/** |
@param str1 REVIEWERS: Insert description here. |
Compares two String objects for inequality. |
@param str2 REVIEWERS: Insert description here. |
@param str1 The first String to compare. |
|
@param str2 The second String to compare. |
|
@return False if the strings are equal, true otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator!=( | PEGASUS_COMMON_LINKAGE Boolean operator!=( |
const String& str1, | const String& str1, |
const String& str2); | const String& str2); |
| |
/** REVIEWERS: Insert description here. |
/** |
@param str REVIEWERS: Insert description here. |
Writes a String value to an output stream. Characters with a zero value or |
@param os REVIEWERS: Insert description here. |
with a non-zero high-order byte are written in a hexadecimal encoding. |
|
@param os The output stream to which the String value is written. |
|
@param str The String to write to the output stream. |
|
@return A reference to the output stream. |
*/ | */ |
PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<( | PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<( |
PEGASUS_STD(ostream)& os, | PEGASUS_STD(ostream)& os, |
const String& str); | const String& str); |
| |
/** This overload operator (+) concatenates String objects. For example, |
/** |
|
Concatenates String objects. For example, |
<pre> | <pre> |
String t1 = "abc"; | String t1 = "abc"; |
String t2; | String t2; |
t2 = t1 + "def" | t2 = t1 + "def" |
assert(t2 == "abcdef"); | assert(t2 == "abcdef"); |
</pre> | </pre> |
|
@param str1 The first String to concatenate. |
|
@param str2 The second String to concatenate. |
|
@return The concatenated String. |
*/ | */ |
PEGASUS_COMMON_LINKAGE String operator+(const String& str1, const String& str2); | PEGASUS_COMMON_LINKAGE String operator+(const String& str1, const String& str2); |
| |
/** The overload operator (<) compares String obects. |
/** |
<pre> |
Compares two String objects. |
String t1 = "def"; |
@param s1 The first String to compare. |
String t2 = "a"; |
@param s2 The second String to compare. |
assert (t2 < t1); |
@return True if s1 is lexographically less than s2, false otherwise. |
</pre> |
|
@param str1 REVIEWERS: Insert description here. |
|
@param str2 REVIEWERS: Insert description here. |
|
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator<( | PEGASUS_COMMON_LINKAGE Boolean operator<( |
const String& str1, | const String& str1, |
const String& str2); | const String& str2); |
| |
/** The overload operator (<=) compares String objects. |
/** |
@param str1 REVIEWERS: Insert description here. |
Compares two String objects. |
@param str2 REVIEWERS: Insert description here. |
@param s1 The first String to compare. |
|
@param s2 The second String to compare. |
|
@return True if s1 is lexographically less than or equal to s2, |
|
false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator<=( | PEGASUS_COMMON_LINKAGE Boolean operator<=( |
const String& str1, | const String& str1, |
const String& str2); | const String& str2); |
| |
/** The overload operator (>) compares String objects. |
/** |
@param str1 REVIEWERS: Insert description here. |
Compares two String objects. |
@param str2 REVIEWERS: Insert description here. |
@param s1 The first String to compare. |
|
@param s2 The second String to compare. |
|
@return True if s1 is lexographically greater than s2, false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator>( | PEGASUS_COMMON_LINKAGE Boolean operator>( |
const String& str1, | const String& str1, |
const String& str2); | const String& str2); |
| |
/** The overload operator (>=) compares String objects. |
/** |
@param str1 REVIEWERS: Insert description here. |
Compares two String objects. |
@param str2 REVIEWERS: Insert description here. |
@param s1 The first String to compare. |
|
@param s2 The second String to compare. |
|
@return True if s1 is lexographically greater than or equal to s2, |
|
false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator>=( | PEGASUS_COMMON_LINKAGE Boolean operator>=( |
const String& str1, | const String& str1, |
|
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#if defined(PEGASUS_INTERNALONLY) && !defined(PEGASUS_DISABLE_INTERNAL_INLINES) |
#if defined(PEGASUS_INTERNALONLY) |
# include "StringInline.h" | # include "StringInline.h" |
#endif | #endif |
| |