SEString is basic char* based string class. More...
#include <skype-string.h>
Inheritance diagram for SEString:Public Types | |
| typedef unsigned long long | uint64 |
Public Member Functions | |
| SEString () | |
| SEString (const char *str) | |
| SEString (const SEString &str) | |
| ~SEString () | |
| operator const char * () const | |
| const char * | data () const |
| size_t | size () const |
| size_t | length () const |
| bool | isNull () const |
| bool | isEmpty () const |
| bool | isBinary () const |
| bool | startWith (const SEString &str) const |
| SEString | right (unsigned int len) const |
| SEString | trim (const SEString &str) const |
| SEString | substr (int from, int to) const |
| SEString | deepCopy () const |
| unsigned int | hash (unsigned int size=1) const |
| bool | equals (const SEString &str) const |
| bool | equals (const char *str) const |
| int | find (char c) const |
| int | find (int startpos, char c) const |
| SEString & | operator+= (const SEString &str) |
| SEString & | operator+= (const char *str) |
| SEString & | operator= (const SEString &str) |
| SEString & | operator= (const char *str) |
| bool | toBool () const |
| int | toInt () const |
| unsigned int | toUInt () const |
| uint64 | toUInt64 () const |
| size_t | toBinary (char *bin) const |
| SEString | getHexRepresentation () const |
| void | Format (const char *format, va_list arglist) |
| void | Format (const char *format,...) |
Static Public Member Functions | |
| static const SEString | from (int n) |
| static const SEString | from (uint64 n) |
| static const SEString | from (unsigned int u, unsigned int base=10) |
| static const SEString | from (bool b) |
| static const SEString | from (char *bin, unsigned int len) |
| static const SEString | from (unsigned char chr) |
| static const SEString | Compose (const char *format,...) |
SEString is basic char* based string class.
SEString uses implicit sharing (i.e. reference counting). In all of the SEString methods that take const char * parameters, the const char * is interpreted as a classic C-style '\0'-terminated ASCII string. A SEString that has not been assigned to anything is null, i.e. both the length and data pointer is 0. A SEString that references the empty string ("", a single '\0' char) is empty. Use if ( !str.isNull() ) to check for a non-null string.
This class is not thread-safe. Make sure to use deepCopy() when passing between threads.
tutorial_1.cpp, tutorial_10.cpp, tutorial_11.cpp, tutorial_12.cpp, tutorial_13.cpp, tutorial_14.cpp, tutorial_15.cpp, tutorial_16.cpp, tutorial_2.cpp, tutorial_3.cpp, tutorial_4.cpp, tutorial_5.cpp, tutorial_6.cpp, tutorial_7.cpp, tutorial_8.cpp, and tutorial_9.cpp.
Definition at line 25 of file skype-string.h.
| typedef unsigned long long SEString::uint64 |
Definition at line 187 of file skype-string.h.
| SEString::SEString | ( | ) | [inline] |
Constructs a null string, i.e. both the length and data pointer are 0. See also isNull().
Definition at line 313 of file skype-string.h.
| SEString::SEString | ( | const char * | str | ) | [inline] |
Constructs a string that is a deep copy of str, interpreted as a classic C string. If str is 0, then a null string is created.
Definition at line 319 of file skype-string.h.
| SEString::SEString | ( | const SEString & | str | ) | [inline] |
Constructs an implicitly shared copy of str. This is very fast since it only involves incrementing a reference count.
| str | is a string to copy |
Definition at line 325 of file skype-string.h.
| SEString::~SEString | ( | ) | [inline] |
Destroys the string and frees the string's data if this is the last reference to the string.
Definition at line 331 of file skype-string.h.
| static const SEString SEString::Compose | ( | const char * | format, | |
| ... | ||||
| ) | [inline, static] |
Definition at line 233 of file skype-string.h.
References Format().
| const char* SEString::data | ( | void | ) | const [inline] |
Definition at line 105 of file skype-string.h.
References operator const char *().
| SEString SEString::deepCopy | ( | ) | const |
Creates a copy of the string that can be passed between threads.
Definition at line 571 of file skype-string.cpp.
| bool SEString::equals | ( | const SEString & | str | ) | const |
Returns true if str is equal to the string; otherwise returns false. Note that a null string is not equal to a not-null empty string.
Definition at line 606 of file skype-string.cpp.
References isNull().
| bool SEString::equals | ( | const char * | str | ) | const |
Returns true if str is equal to the string; otherwise returns false. Note that a null string is not equal to a not-null empty string.
Definition at line 617 of file skype-string.cpp.
References isNull().
| int SEString::find | ( | char | c | ) | const |
Finds the first occurrence of the character.
Definition at line 628 of file skype-string.cpp.
References isNull().
| int SEString::find | ( | int | startpos, | |
| char | c | |||
| ) | const |
Definition at line 641 of file skype-string.cpp.
References isNull().
| void SEString::Format | ( | const char * | format, | |
| va_list | arglist | |||
| ) |
Definition at line 667 of file skype-string.cpp.
| void SEString::Format | ( | const char * | format, | |
| ... | ||||
| ) | [inline] |
Definition at line 214 of file skype-string.h.
References Format().
Converts an integer into a SEString.
Definition at line 259 of file skype-string.cpp.
References SEString().
| const SEString SEString::from | ( | unsigned int | u, | |
| unsigned int | base = 10 | |||
| ) | [static] |
Converts an integer into a SEString using the given base. Only base 10 and 16 are supported.
Definition at line 278 of file skype-string.cpp.
References SEString().
| const SEString SEString::from | ( | bool | b | ) | [static] |
Converts a boolean into a SEString.
Definition at line 290 of file skype-string.cpp.
References SEString().
| const SEString SEString::from | ( | char * | bin, | |
| unsigned int | len | |||
| ) | [static] |
Converts a binary into a SEString.
Definition at line 304 of file skype-string.cpp.
| const SEString SEString::from | ( | int | n | ) | [static] |
Converts an integer into a SEString.
Definition at line 250 of file skype-string.cpp.
References SEString().
| const SEString SEString::from | ( | unsigned char | chr | ) | [static] |
Definition at line 268 of file skype-string.cpp.
References SEString().
| SEString SEString::getHexRepresentation | ( | ) | const |
For binaries returns a string with the hexa representation
Definition at line 406 of file skype-string.cpp.
References isBinary(), length(), SEString(), and toBinary().
| unsigned int SEString::hash | ( | unsigned int | size = 1 |
) | const |
Returns a hashed value of the string. For internal use.
Definition at line 580 of file skype-string.cpp.
References isNull().
| bool SEString::isBinary | ( | ) | const |
Checks if the string contains binary data
Definition at line 173 of file skype-string.cpp.
| bool SEString::isEmpty | ( | ) | const [inline] |
Returns true if the string is empty, i.e. if length() == 0; otherwise returns false. Null strings are also empty. SEString a(""); a.isEmpty(); // TRUE a.isNull(); // FALSE
SEString b; b.isEmpty(); // TRUE b.isNull(); // TRUE
See also isNull() and length().
Definition at line 341 of file skype-string.h.
References length().
| bool SEString::isNull | ( | ) | const [inline] |
Returns true if the string is null; otherwise returns false. A null string is always empty. See also isEmpty() and length().
Definition at line 336 of file skype-string.h.
| size_t SEString::length | ( | ) | const |
Returns the length of the string. Null strings and empty strings have zero length. See also isNull() and isEmpty().
Definition at line 165 of file skype-string.cpp.
References isNull().
| SEString::operator const char * | ( | void | ) | const |
Returns a pointer to the string storing the data. If the string is null (as defined by isNull() == true), returns an empty string.
If you need to keep this string after the SEString object gets deleted, make a copy. In other words, the char* pointer is valid ONLY AS LONG as the corresponding SEString is valid. When the SEString gets deleted, the data get freed and the pointer is invalid.
Some examples:
// Works: SEString skypeName = me->GetProp(Contact::P_SKYPENAME); printf("CONTACT %s\n", (const char*)skypeName);
// Doesn't work, segmentation fault:
const char * skypeName = (const char *) me->GetProp(Contact::P_SKYPENAME);
printf("CONTACT %s\n", skypeName); // Doesn't work:
const char * skypeName;
if (1) {
SEString skypeName_1 = me->GetProp(Contact::P_SKYPENAME);
skypeName = (const char *) skypeName_1;
} // skypeName_1 deleted here
printf("CONTACT %s\n", skypeName); // skypeName_1 has been deleted and the correponding data too// Works: SEString skypeName_1 = me->GetProp(Contact::P_SKYPENAME); const char * skypeName = (const char *) skypeName_1; printf("CONTACT %s\n", skypeName);
NB: The example above uses SEObject::GetProp() but in UI it is strongly discouraged to use GetProp(). SEObject::GetProps() or Skype::GetMultipleObjectsProps() should be used instead.
Definition at line 155 of file skype-string.cpp.
References isNull().
Appends str to the string and returns a reference to the string.
Definition at line 428 of file skype-string.cpp.
| SEString & SEString::operator+= | ( | const char * | str | ) |
Appends str to the string and returns a reference to the string.
Definition at line 450 of file skype-string.cpp.
Assigns a shallow copy of s to this string and returns a reference to this string. This is very fast because the string isn't actually copied.
Definition at line 473 of file skype-string.cpp.
| SEString & SEString::operator= | ( | const char * | str | ) |
Assigns a deep copy of str, interpreted as a classic C string to this string and returns a reference to this string. If str is 0, then a null string is created. See also isNull().
Definition at line 482 of file skype-string.cpp.
| SEString SEString::right | ( | unsigned int | len | ) | const |
Returns a string that contains the len rightmost characters of the string. If len is greater than the length of the string then the whole string is returned.
Definition at line 224 of file skype-string.cpp.
| size_t SEString::size | ( | ) | const [inline] |
Returns the length of the string. Null strings and empty strings have zero length. See also isNull() and isEmpty().
Definition at line 113 of file skype-string.h.
References length().
| bool SEString::startWith | ( | const SEString & | str | ) | const |
Returns true if the string starts with str; otherwise returns false.
Definition at line 178 of file skype-string.cpp.
| SEString SEString::substr | ( | int | from, | |
| int | to | |||
| ) | const |
Returns a section of the string. The returned string consists of the characters from position start to position end inclusive. If end is not specified, all fields from position start to the end of the string are included.
Definition at line 191 of file skype-string.cpp.
| size_t SEString::toBinary | ( | char * | bin | ) | const |
Converts the string to a binary.
| bin | Initialized array to store the binary (use length() to get a big enough array) |
Definition at line 375 of file skype-string.cpp.
References isBinary(), isNull(), and length().
| bool SEString::toBool | ( | ) | const |
Converts the string to a boolean (works like atoi). Returns false on null strings.
Definition at line 343 of file skype-string.cpp.
References isNull().
| int SEString::toInt | ( | ) | const |
DEPRECATED: Use toUInt instead.
Definition at line 351 of file skype-string.cpp.
References isNull().
| unsigned int SEString::toUInt | ( | ) | const |
Converts the string to an unsigned integer (like strtoul(.. 10). Returns 0 on null strings.
Definition at line 359 of file skype-string.cpp.
References isNull().
| SEString::uint64 SEString::toUInt64 | ( | ) | const |
Converts the string to an unsigned 64 bits integer (like strtoul(.. 10). Returns 0 on null strings.
Definition at line 367 of file skype-string.cpp.
References isNull().
Removes str from the string.
Definition at line 240 of file skype-string.cpp.
References length(), right(), and startWith().
(c) Skype Technologies S.A. Confidential/Proprietary
Last updated: Fri Jan 27 2012