version 1.59, 2002/08/29 00:27:52
|
version 1.73, 2002/10/07 17:42:04
|
|
|
#ifndef Pegasus_String_h | #ifndef Pegasus_String_h |
#define Pegasus_String_h | #define Pegasus_String_h |
| |
|
#ifdef PEGASUS_OS_HPUX |
|
# ifdef HPUX_IA64_NATIVE_COMPILER |
#include <iostream> | #include <iostream> |
#include <fstream> |
# else |
#include <cstring> |
# include <iostream.h> |
|
# endif |
|
#else |
|
# include <iostream> |
|
#endif |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Char16.h> | #include <Pegasus/Common/Char16.h> |
#include <Pegasus/Common/Linkage.h> | #include <Pegasus/Common/Linkage.h> |
|
|
| |
/** The CString class provides access to an 8-bit String representation. | /** The CString class provides access to an 8-bit String representation. |
*/ | */ |
class CString |
class PEGASUS_COMMON_LINKAGE CString |
{ | { |
public: | public: |
| |
|
|
| |
~CString(); | ~CString(); |
| |
|
CString& operator=(const CString& cstr); |
|
|
operator const char*() const; | operator const char*() const; |
| |
private: | private: |
|
|
| |
friend class String; | friend class String; |
| |
char* _rep; |
void* _rep; |
}; | }; |
| |
/** | /** |
|
|
*/ | */ |
Uint32 size() const; | Uint32 size() const; |
| |
/** getData Returns a pointer to the first character in the |
/** getChar16Data Returns a pointer to the first character in the |
null-terminated string of the String object. |
null-terminated Char16 buffer of the String object. |
@return Pointer to the first character of the String object | @return Pointer to the first character of the String object |
<pre> | <pre> |
String t1 = "abc"; | String t1 = "abc"; |
const Char16* q = t1.getData(); |
const Char16* q = t1.getChar16Data(); |
</pre> | </pre> |
*/ | */ |
const Char16* getData() const; |
const Char16* getChar16Data() const; |
| |
/** getCString - Create an 8-bit representation of this String object. | /** getCString - Create an 8-bit representation of this String object. |
| |
|
|
@return This String | @return This String |
<pre> | <pre> |
String t1 = "abc"; | String t1 = "abc"; |
t1 += Char16('d') |
t1.append (Char16('d')); |
assert(t1 == "abcd"); | assert(t1 == "abcd"); |
</pre> | </pre> |
*/ | */ |
|
|
*/ | */ |
Uint32 reverseFind(Char16 c) const; | Uint32 reverseFind(Char16 c) const; |
| |
#ifdef PEGASUS_INTERNALONLY |
|
// ATTN-RK-P3-20020509: Define case-sensitivity for non-English characters |
|
/** Converts all characters in this string to lower case. | /** Converts all characters in this string to lower case. |
*/ | */ |
void toLower(); | void toLower(); |
#endif |
|
| |
/** 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. |
|
|
*/ | */ |
static int compare(const String& s1, const String& s2); | static int compare(const String& s1, const String& s2); |
| |
#ifdef PEGASUS_INTERNALONLY |
|
/** Just like one above except ignores case differences. | /** Just like one above except ignores case differences. |
*/ | */ |
static int compareNoCase(const String& s1, const String& s2); | static int compareNoCase(const String& s1, const String& s2); |
#endif |
|
| |
/** Compare two String objects for equality. | /** Compare two String objects for equality. |
@param s1 First <TT>String</TT> for comparison. | @param s1 First <TT>String</TT> for comparison. |
|
|
*/ | */ |
static Boolean equalNoCase(const String& str1, const String& str2); | static Boolean equalNoCase(const String& str1, const String& str2); |
| |
/** match matches a string against a GLOB style pattern. |
|
Return trues if the String parameter matches the pattern. C-Shell style |
|
glob matching is used. |
|
@param str String to be matched against the pattern |
|
@param pattern Pattern to use in the match |
|
@return Boolean true if str matches pattern |
|
The pattern definition is as follows: |
|
<pre> |
|
* Matches any number of any characters |
|
? Match exactly one character |
|
[chars] Match any character in chars |
|
[chara-charb] Match any character in the range between chara and charb |
|
</pre> |
|
The literal characters *, ?, [, ] can be included in a string by |
|
escaping them with backslash "\". Ranges of characters can be concatenated. |
|
<pre> |
|
examples: |
|
Boolean result = String::match("This is a test", "*is*"); |
|
Boolean works = String::match("abcdef123", "*[0-9]"); |
|
</pre> |
|
*/ |
|
static Boolean match(const String& str, const String& pattern); |
|
|
|
/** matchNoCase Matches a String against a GLOB style pattern independent |
|
of case. |
|
Returns true if the str parameter matches the pattern. C-Shell style |
|
glob matching is used. Ignore case in all comparisons. Case is |
|
ignored in the match. |
|
@parm str String containing the string to be matched\ |
|
@parm pattern GLOB style patterh to use in the match. |
|
@return Boolean true if str matches patterh |
|
@SeeAlso match |
|
*/ |
|
static Boolean matchNoCase(const String& str, const String& pattern); |
|
|
|
private: | private: |
| |
StringRep* _rep; | StringRep* _rep; |
|
|
const String& str1, | const String& str1, |
const String& str2); | const String& str2); |
| |
|
#ifndef PEGASUS_REMOVE_DEPRECATED |
/** Compare two strings but ignore any case differences. | /** Compare two strings but ignore any case differences. |
*/ | */ |
PEGASUS_COMMON_LINKAGE int CompareNoCase(const char* s1, const char* s2); | PEGASUS_COMMON_LINKAGE int CompareNoCase(const char* s1, const char* s2); |
|
#endif |
PEGASUS_COMMON_LINKAGE int EqualNoCase(const char* s1, const char* s2); |
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |