SourcePro 11.1 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
An identifier for RWCollectable instances. More...
#include <rw/stringid.h>
Public Member Functions | |
RWStringID () | |
RWStringID & | operator= (const RWCString &s) |
char | operator() (size_t t) const |
size_t | capacity () const |
size_t | capacity (size_t N) |
int | collate (const char *cs) const |
int | collate (const RWCString &st) const |
int | compareTo (const char *cs, caseCompare cmp=exact) const |
int | compareTo (const RWCString &st, caseCompare cmp=exact) const |
bool | contains (const char *pat, caseCompare cmp=exact) const |
bool | contains (const RWCString &pat, caseCompare cmp=exact) const |
size_t | first (char c) const |
size_t | first (const char *cs) const |
size_t | index (const char *pat, size_t i=0, caseCompare cmp=exact) const |
size_t | index (const RWCString &s, size_t i=0, caseCompare cmp=exact) const |
size_t | index (const char *pat, size_t patlen, size_t i, caseCompare cmp) const |
size_t | index (const RWCString &s, size_t patlen, size_t i, caseCompare cmp) const |
size_t | index (const char *pat, size_t *ext, size_t i=0) const |
size_t | index (const RWCRegexp &pat, size_t i=0) const |
size_t | index (const RWCRegexp &pat, size_t *ext, size_t i=0) const |
size_t | last (char c) const |
size_t | last (char c, size_t i) const |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const RWStringID &lhs, const RWStringID &rhs) |
bool | operator== (const RWStringID &lhs, const char *rhs) |
bool | operator== (const char *lhs, const RWStringID &rhs) |
bool | operator!= (const RWStringID &lhs, const char *rhs) |
bool | operator!= (const char *lhs, const RWStringID &rhs) |
bool | operator< (const RWStringID &lhs, const RWStringID &rhs) |
bool | operator!= (const RWStringID &lhs, const RWStringID &rhs) |
bool | operator> (const RWStringID &lhs, const RWStringID &rhs) |
bool | operator<= (const RWStringID &lhs, const RWStringID &rhs) |
bool | operator>= (const RWStringID &lhs, const RWStringID &rhs) |
RWvostream & | operator<< (RWvostream &vos, const RWStringID &sid) |
RWvistream & | operator>> (RWvistream &vis, RWStringID &sid) |
RWFile & | operator<< (RWFile &file, const RWStringID &sid) |
RWFile & | operator>> (RWFile &file, RWStringID &sid) |
std::ostream & | operator<< (std::ostream &os, const RWStringID &sid) |
std::istream & | operator>> (std::istream &is, RWStringID &sid) |
Class RWStringID is an identifier for RWCollectable instances. It is derived from RWCString, and may be manipulated by any of the const RWCString methods. The non-const methods have been hidden to prevent the disaster that could occur if the RWStringID of a class changed at run time.
You can associate an RWStringID with an RWCollectable class in one of two ways: pick the RWStringID for the class, or allow the library to automatically generate an RWStringID that is the same sequence of characters as the name of the class; for example, class MyColl : public RWCollectable would get the automatic RWStringID "MyColl".
You specify a class with a fixed RWClassID and generated RWStringID by using the macro RW_DEFINE_COLLECTABLE_CLASS_BY_ID as follows:
RW_DEFINE_COLLECTABLE_CLASS_BY_ID(USER_MODULE,ClassName, ClassID)
RW_DEFINE_COLLECTABLE_CLASS_BY_ID(USER_MODULE,MyCollectable1,0x1000) // for example
You specify a class with a fixed RWStringID and a generated RWClassID by using the new macro RW_DEFINE_COLLECTABLE_CLASS_BY_NAME as follows:
RW_DEFINE_COLLECTABLE_CLASS_BY_NAME(USER_MODULE, ClassName, StringID)
RW_DEFINE_COLLECTABLE_CLASS_BY_NAME(USER_MODULE, MyCollectable2, "Second Collectable") // for example
#include <rw/collect.h> // See the section in the Essential Tools Module User's Guide // about exporting symbols for more information about this macro. #define EXPORT class MyCollectable1 : public RWCollectable { RW_DECLARE_COLLECTABLE_CLASS(EXPORT, MyCollectable1); }; RW_DEFINE_COLLECTABLE_CLASS_BY_ID(EXPORT,MyCollectable1,0x1000) class MyCollectable2 : public RWCollectable { RW_DECLARE_COLLECTABLE_CLASS(EXPORT, MyCollectable2); }; RW_DEFINE_COLLECTABLE_CLASS_BY_NAME(EXPORT, MyCollectable2, "Second Collectable") int main () { // First set up the experiment MyCollectable1 one; MyCollectable2 two; // All running RWClassIDs are guaranteed distinct one.isA() != two.isA(); // Every RWCollectable has an RWStringID one.stringID() == "MyCollectable1"; // There are several ways to find ids two.isA(); RWCollectable::classID("Second Collectable"); return 0; }
RWStringID::RWStringID | ( | ) | [inline] |
Default constructor. Sets the value of the ID string to "NoID".
size_t RWStringID::capacity | ( | size_t | capac | ) | [inline] |
Hints to the implementation to change the capacity of self to capac. Returns the actual capacity.
Reimplemented from RWCString.
size_t RWStringID::capacity | ( | ) | const [inline] |
Returns the current capacity of self. This is the number of bytes the string can hold without resizing.
Reimplemented from RWCString.
int RWStringID::collate | ( | const RWCString & | str | ) | const [inline] |
Returns an int
less than, greater than, or equal to zero, according to the result of calling the Standard C Library function strcoll()
on self and the argument str. This supports locale-dependent collation. Provided only on platforms that provide strcoll()
. This function is incompatible with strings with embedded nulls.
Reimplemented from RWCString.
int RWStringID::collate | ( | const char * | str | ) | const [inline] |
Returns an int
less than, greater than, or equal to zero, according to the result of calling the Standard C Library function strcoll()
on self and the argument str. This supports locale-dependent collation. Provided only on platforms that provide strcoll()
. This function is incompatible with strings with embedded nulls.
Reimplemented from RWCString.
int RWStringID::compareTo | ( | const RWCString & | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Returns an int
less than, greater than, or equal to zero, according to the result of calling the Standard C Library function memcmp()
on self and the argument str. Case sensitivity is according to the caseCompare argument, and may be RWCString::exact or RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char*
strings with embedded nulls. This function may be incompatible with const char*
MBCS strings.
Reimplemented from RWCString.
int RWStringID::compareTo | ( | const char * | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Returns an int
less than, greater than, or equal to zero, according to the result of calling the Standard C Library function memcmp()
on self and the argument str. Case sensitivity is according to the caseCompare argument, and may be RWCString::exact or RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char*
strings with embedded nulls. This function may be incompatible with const char*
MBCS strings.
Reimplemented from RWCString.
bool RWStringID::contains | ( | const RWCString & | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Pattern matching. Returns true
if str occurs in self. Case sensitivity is according to the caseCompare argument, and may be RWCString::exact or RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char*
strings with embedded nulls. This function may be incompatible with const char*
MBCS strings.
Reimplemented from RWCString.
bool RWStringID::contains | ( | const char * | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Pattern matching. Returns true
if str occurs in self. Case sensitivity is according to the caseCompare argument, and may be RWCString::exact or RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char*
strings with embedded nulls. This function may be incompatible with const char*
MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::first | ( | const char * | str | ) | const [inline] |
Returns the index of the first occurrence in self of any character in str. Returns RW_NPOS if there is no match or if there is an embedded null prior to finding any character from str. This function is incompatible with strings with embedded nulls and may be incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::first | ( | char | c | ) | const [inline] |
size_t RWStringID::index | ( | const RWCRegexp & | re, | |
size_t * | ext, | |||
size_t | i = 0 | |||
) | const [inline] |
Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern. This function returns the length of the matching pattern in the variable pointed to by ext. This function is incompatible with strings with embedded nulls and may be incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCRegexp & | re, | |
size_t | i = 0 | |||
) | const [inline] |
size_t RWStringID::index | ( | const char * | re, | |
size_t * | ext, | |||
size_t | i = 0 | |||
) | const [inline] |
Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern. This function returns the length of the matching pattern in the variable pointed to by ext. This function is incompatible with strings with embedded nulls and may be incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCString & | pat, | |
size_t | patlen, | |||
size_t | i, | |||
caseCompare | cmp | |||
) | const [inline] |
Pattern matching. Starting with index i, searches for the first occurrence of the first patlen bytes from pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const char * | pat, | |
size_t | patlen, | |||
size_t | i, | |||
caseCompare | cmp | |||
) | const [inline] |
Pattern matching. Starting with index i, searches for the first occurrence of the first patlen bytes from pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCString & | pat, | |
size_t | i = 0 , |
|||
caseCompare | cmp = exact | |||
) | const [inline] |
Pattern matching. Starting with index i, searches for the first occurrence of pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument; it defaults to RWCString::exact. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const char * | pat, | |
size_t | i = 0 , |
|||
caseCompare | cmp = exact | |||
) | const [inline] |
Pattern matching. Starting with index i, searches for the first occurrence of pat in self and returns the index of the start of the match. Returns RW_NPOS if there is no such pattern. Case sensitivity is according to the caseCompare argument; it defaults to RWCString::exact. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings.
Reimplemented from RWCString.
size_t RWStringID::last | ( | char | c, | |
size_t | N | |||
) | const [inline] |
size_t RWStringID::last | ( | char | c | ) | const [inline] |
Returns the index of the last occurrence in the string of the character c. Returns RW_NPOS if there is no such character or if there is an embedded null to the right of c in self. This function is incompatible with strings with embedded nulls and may be incompatible with MBCS strings.
Reimplemented from RWCString.
char RWStringID::operator() | ( | size_t | i | ) | const [inline] |
Returns the i th character. The index i must be between 0 and the length of the string less one. Bounds checking is performed if the pre-processor macro RWBOUNDS_CHECK
has been defined before including <rw/wstring.h>
.
RWBoundsErr | if the index is out of range. |
Reimplemented from RWCString.
RWStringID& RWStringID::operator= | ( | const RWCString & | str | ) | [inline] |
Assignment operator. The string copies the str values's data. Returns a reference to self.
Reimplemented from RWCString.
bool operator!= | ( | const RWStringID & | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator!= | ( | const char * | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator!= | ( | const RWStringID & | lhs, | |
const char * | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator< | ( | const RWStringID & | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
std::ostream& operator<< | ( | std::ostream & | os, | |
const RWStringID & | sid | |||
) | [friend] |
Output an RWStringID on ostream os.
RWFile& operator<< | ( | RWFile & | file, | |
const RWStringID & | sid | |||
) | [friend] |
Saves string sid to an RWFile.
RWvostream& operator<< | ( | RWvostream & | vos, | |
const RWStringID & | sid | |||
) | [friend] |
Saves string sid to a virtual stream.
bool operator<= | ( | const RWStringID & | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member RWStringID::collate() for locale sensitivity. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator== | ( | const char * | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator== | ( | const RWStringID & | lhs, | |
const char * | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator== | ( | const RWStringID & | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Logical equality and inequality. Case sensitivity is exact. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator> | ( | const RWStringID & | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member RWStringID::collate() for locale sensitivity. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
bool operator>= | ( | const RWStringID & | lhs, | |
const RWStringID & | rhs | |||
) | [friend] |
Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member RWStringID::collate() for locale sensitivity. This function is incompatible with const
char*
strings with embedded nulls. This function may be incompatible with const
char*
MBCS strings.
std::istream& operator>> | ( | std::istream & | is, | |
RWStringID & | sid | |||
) | [friend] |
Calls RWCString::readToken(std::istream&). That is, a token is read from the input stream is. This function is incompatible with MBCS strings.
RWFile& operator>> | ( | RWFile & | file, | |
RWStringID & | sid | |||
) | [friend] |
Restores a string into sid from an RWFile, replacing the previous contents of sid. If the file produce an error on extraction, the operator returns the original string contents unmodified. Be sure to check the file to determine if an extraction error occurred.
RWvistream& operator>> | ( | RWvistream & | vis, | |
RWStringID & | sid | |||
) | [friend] |
Restores a string into sid from a virtual stream, replacing the previous contents of sid. If the virtual stream produces an error on extraction, the operator returns the original string contents unmodified. Be sure to check the virtual stream to determine if an extraction error occurred.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.