SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
An identifier for RWCollectable instances. More...
#include <rw/stringid.h>
Public Member Functions | |
RWStringID () | |
RWStringID (const RWStringID &sid) | |
RWStringID (const RWCString &s) | |
RWStringID (const char *name) | |
RWStringID (RWCString &&s) | |
RWStringID (RWStringID &&sid) | |
~RWStringID () | |
RWStringID & | operator= (const RWStringID &sid) |
RWStringID & | operator= (const RWCString &s) |
RWStringID & | operator= (RWCString &&s) |
RWStringID & | operator= (RWStringID &&sid) |
operator const char * () const | |
char | operator[] (size_t t) const |
char | operator() (size_t t) const |
RWspace | binaryStoreSize () const |
const char * | data () const |
bool | isAscii () const |
bool | isNull () const |
size_t | length () 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 | firstOf (char c, size_t pos=0) const |
size_t | firstOf (const char *str, size_t pos=0) const |
unsigned | hash () 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 RWCRExpr &pat, size_t i=0) const |
size_t | index (const RWCRExpr &pat, size_t *ext, size_t i=0) 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) const |
size_t | lastOf (char c, size_t pos=RW_NPOS) const |
void | swap (RWStringID &rhs) |
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 string ID to "NoID".
RWStringID::RWStringID | ( | const RWStringID & | sid | ) | [inline] |
Copy constructor. Sets the value of the string ID to the value of sid.
RWStringID::RWStringID | ( | const RWCString & | s | ) | [inline] |
Sets the value of the string ID to the value of string s.
RWStringID::RWStringID | ( | const char * | name | ) | [inline] |
Sets the value of the string ID to the value of char name.
RWStringID::RWStringID | ( | RWCString && | s | ) | [inline] |
Move Constructor. The created string ID takes ownership of the data owned by s.
RWStringID::RWStringID | ( | RWStringID && | sid | ) | [inline] |
Move constructor. The created string ID takes ownership of the data owned by sid.
RWStringID::~RWStringID | ( | ) | [inline] |
Destructor
RWspace RWStringID::binaryStoreSize | ( | ) | const [inline] |
Returns the number of bytes necessary to store the object using the global functions:
RWFile& operator<<(RWFile&, const RWCString&); RWvostream& operator<<(RWvostream&, const RWCString&);
Reimplemented from RWCString.
size_t RWStringID::capacity | ( | size_t | cap | ) | [inline] |
A non-binding request to alter the capacity of self to cap
. The capacity is never reduced below the current number of bytes. 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.
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.
Reimplemented from RWCString.
int RWStringID::compareTo | ( | const RWCString & | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Lexicographically compares self to str. Returns the following values based on the results of the comparison:
<0 | self precedes str. |
0 | self is equal to str. |
>0 | self follows str. |
If cmp is either RWCString::ignoreCase or RWCString::ignoreCaseStrict, the strings are normalized before they are compared.
Reimplemented from RWCString.
int RWStringID::compareTo | ( | const char * | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Lexicographically compares self to str. Returns the following values based on the results of the comparison:
<0 | self precedes str. |
0 | self is equal to str. |
>0 | self follows str. |
Reimplemented from RWCString.
bool RWStringID::contains | ( | const RWCString & | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Returns false
if RWCString::index(str, cmp) returns RW_NPOS, otherwise returns true
.
Reimplemented from RWCString.
bool RWStringID::contains | ( | const char * | str, | |
caseCompare | cmp = exact | |||
) | const [inline] |
Returns false
if RWCString::index(str, cmp) returns RW_NPOS, otherwise returns true
.
Reimplemented from RWCString.
const char* RWStringID::data | ( | void | ) | const [inline] |
Provides access to the RWCString instances's data as a null-terminated string. This datum is owned by the RWCString and may not be deleted or changed. If the RWCString object itself changes or goes out of scope, the pointer value previously returned becomes invalid. While the string is null-terminated, its length is still given by the member function length(). That is, it may contain embedded nulls.
Reimplemented from RWCString.
size_t RWStringID::first | ( | const char * | str | ) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::first | ( | char | c | ) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::firstOf | ( | const char * | str, | |
size_t | pos = 0 | |||
) | const [inline] |
size_t RWStringID::firstOf | ( | char | c, | |
size_t | pos = 0 | |||
) | const [inline] |
unsigned RWStringID::hash | ( | ) | const [inline] |
Returns a suitable hash value.
size_t RWStringID::index | ( | const RWCRegexp & | re, | |
size_t * | ext, | |||
size_t | start = 0 | |||
) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCRegexp & | re, | |
size_t | start = 0 | |||
) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::index | ( | const char * | re, | |
size_t * | ext, | |||
size_t | start = 0 | |||
) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCRExpr & | re, | |
size_t * | ext, | |||
size_t | start = 0 | |||
) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCRExpr & | re, | |
size_t | start = 0 | |||
) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCString & | pat, | |
size_t | patlen, | |||
size_t | start, | |||
caseCompare | cmp | |||
) | const [inline] |
Pattern matching. Starting with index start, 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 cmp.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const char * | pat, | |
size_t | patlen, | |||
size_t | start, | |||
caseCompare | cmp | |||
) | const [inline] |
Pattern matching. Starting with index start, 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 cmp.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const RWCString & | pat, | |
size_t | start = 0 , |
|||
caseCompare | cmp = exact | |||
) | const [inline] |
Pattern matching. Starting with index start, 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 cmp.
Reimplemented from RWCString.
size_t RWStringID::index | ( | const char * | pat, | |
size_t | start = 0 , |
|||
caseCompare | cmp = exact | |||
) | const [inline] |
Pattern matching. Starting with index start, searches for the first occurrence of the null-terminated string 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 cmp.
Reimplemented from RWCString.
bool RWStringID::isAscii | ( | ) | const [inline] |
Returns true
if all bytes in self are between [0, 127].
Reimplemented from RWCString.
bool RWStringID::isNull | ( | void | ) | const [inline] |
Returns true
if this
is a zero length string (i.e., the null string).
Reimplemented from RWCString.
size_t RWStringID::last | ( | char | c, | |
size_t | ||||
) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::last | ( | char | c | ) | const [inline] |
Reimplemented from RWCString.
size_t RWStringID::lastOf | ( | char | c, | |
size_t | pos = RW_NPOS | |||
) | const [inline] |
size_t RWStringID::length | ( | ) | const [inline] |
Returns the number of bytes in self.
Reimplemented from RWCString.
RWStringID::operator const char * | ( | ) | const [inline] |
The equivalent of calling RWCString::data() on self.
Reimplemented from RWCString.
char RWStringID::operator() | ( | size_t | i | ) | const [inline] |
Returns the i th byte in self. 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/cstring.h>
.
RWBoundsErr | if RWBOUNDS_CHECK is defined and the index is out of range. |
Reimplemented from RWCString.
RWStringID& RWStringID::operator= | ( | RWStringID && | sid | ) | [inline] |
Move assignment. Self takes ownership of the data owned by sid.
RWStringID& RWStringID::operator= | ( | RWCString && | s | ) | [inline] |
Move assignment. Self takes ownership of the data owned by s.
Reimplemented from RWCString.
RWStringID& RWStringID::operator= | ( | const RWCString & | s | ) | [inline] |
Copies the data from string s. Returns a reference to self.
Reimplemented from RWCString.
RWStringID& RWStringID::operator= | ( | const RWStringID & | sid | ) | [inline] |
Assignment operator. Copies the data from string ID sid. Returns a reference to self.
char RWStringID::operator[] | ( | size_t | t | ) | const [inline] |
Returns the tth byte in self. The index t must be between 0 and the length of the string less one. Bounds checking is performed.
RWBoundsErr | if the index is out of range. |
void RWStringID::swap | ( | RWStringID & | rhs | ) | [inline] |
Swaps the contents of rhs with self.
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.