version 1.50, 2002/06/01 00:56:39
|
version 1.51, 2002/07/17 18:52:23
|
|
|
#include <cstring> | #include <cstring> |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Char16.h> | #include <Pegasus/Common/Char16.h> |
#include <Pegasus/Common/Array.h> |
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
class StringRep; |
|
|
/** | /** |
The Pegasus String C++ Class implements the CIM string type. | The Pegasus String C++ Class implements the CIM string type. |
This class is based on the general handle/representation pattern | This class is based on the general handle/representation pattern |
|
|
*/ | */ |
String& operator=(const String& str); | String& operator=(const String& str); |
| |
/// Assign this string with Char16 str. |
|
String& operator=(const Char16* str); |
|
|
|
/** Assign this string with String str | /** Assign this string with String str |
@param str String to assign | @param str String to assign |
@return Returns the String | @return Returns the String |
|
|
void clear(); | void clear(); |
| |
| |
/** reserve - Reserves memory for capacity characters. Notice that this does |
/** reserve - Reserves memory for capacity characters. Notice that this |
not |
does not change the size of the string (size() returns what it did |
change the size of the string (size() returns what it did before). |
before). If the capacity of the string is already greater or equal |
If the capacity of the string is already greater or equal to the |
to the capacity argument, this method has no effect. The capacity |
capacity argument, this method has no effect. After calling reserve(), |
of a String object has no bearing on its external behavior. The |
getCapicty() returns a value which is greater or equal to the |
capacity of a String is set only for performance reasons. |
capacity argument. |
|
@param capacity defines the capacity in characters to reserve. | @param capacity defines the capacity in characters to reserve. |
*/ | */ |
void reserve(Uint32 capacity); |
void reserveCapacity(Uint32 capacity); |
| |
/** Returns the length of the String object. | /** Returns the length of the String object. |
@return Length of the string in characters. | @return Length of the string in characters. |
|
|
*/ | */ |
Uint32 find(const String& s) const; | Uint32 find(const String& s) const; |
| |
/** Find substring |
|
@ param 16 bit character pointer |
|
@seealso find |
|
@return Position of the substring in the String or PEG_NOT_FOUND if not |
|
found. |
|
*/ |
|
Uint32 find(const Char16* s) const; |
|
|
|
/** find substring |
|
@param s char* to substring |
|
@return Position of the substring in the String or PEG_NOT_FOUND if not |
|
found. |
|
*/ |
|
Uint32 find(const char* s) const; |
|
|
|
/** reverseFind - Same as find() but start looking in reverse (last | /** reverseFind - Same as find() but start looking in reverse (last |
character first). | character first). |
@param c Char16 character to find in String. | @param c Char16 character to find in String. |
|
|
static void toLower(char* str); | static void toLower(char* str); |
#endif | #endif |
| |
/** Translate any occurences of fromChar to toChar. |
|
*/ |
|
void translate(Char16 fromChar, Char16 toChar); |
|
|
|
/** Method for printing a string. |
|
*/ |
|
void print() const; |
|
|
|
/** Compare the first n characters of the two strings.. | /** Compare the first n characters of the two strings.. |
@param s1 First null-terminated string for the comparison. | @param s1 First null-terminated string for the comparison. |
@param s2 Second null-terminated string for the comparison. | @param s2 Second null-terminated string for the comparison. |
|
|
@return Return -1 if s1 is lexographically less than s2. If they are | @return Return -1 if s1 is lexographically less than s2. If they are |
equavalent return 0. Otherwise return 1. | equavalent return 0. Otherwise return 1. |
*/ | */ |
static int compare(const Char16* s1, const Char16* s2, Uint32 n); |
static int compare(const String& s1, const String& s2, Uint32 n); |
| |
/** Compare two null-terminated strings. | /** Compare two null-terminated strings. |
@param s1 First null-terminated string for the comparison. | @param s1 First null-terminated string for the comparison. |
|
|
NOTE: Use the comparison operators <,<= > >= to compare | NOTE: Use the comparison operators <,<= > >= to compare |
String objects. | String objects. |
*/ | */ |
static int compare(const Char16* s1, const Char16* s2); |
static int compare(const String& s1, const String& s2); |
| |
/** Just like one above except ignores case differences. | /** Just like one above except ignores case differences. |
*/ | */ |
|
|
*/ | */ |
static Boolean equal(const String& str1, const String& str2); | static Boolean equal(const String& str1, const String& str2); |
| |
/// Return true if the two strings are equal. |
|
static Boolean equal(const String& str1, const Char16* str2); |
|
|
|
/// Return true if the two strings are equal. |
|
static Boolean equal(const Char16* str1, const String& str2); |
|
|
|
/// Return true if the two strings are equal. |
|
static Boolean equal(const String& str1, const char* str2); |
|
|
|
/// Return true if the two strings are equal. |
|
static Boolean equal(const char* str1, const String& str2); |
|
|
|
/** equalNoCase - Compares two strings and returuns true if they | /** equalNoCase - Compares two strings and returuns true if they |
are equal indpedent of case of the characters. | are equal indpedent of case of the characters. |
@param str1 First String parameter | @param str1 First String parameter |
|
|
| |
private: | private: |
| |
Array<Char16> _rep; |
StringRep* _rep; |
}; | }; |
| |
/** String operator ==. Test for equality between two strings of any of the | /** String operator ==. Test for equality between two strings of any of the |
|
|
}; | }; |
#endif | #endif |
| |
#define PEGASUS_ARRAY_T String |
|
#include <Pegasus/Common/ArrayInter.h> |
|
#undef PEGASUS_ARRAY_T |
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_String_h */ | #endif /* Pegasus_String_h */ |