Implement a immutable C string wrapper that can serve as a distributable key object for caching as well as being a string value.
More...
Inherits apache::geode::client::CacheableKey.
Inherited by apache::geode::client::CacheableFileName.
|
| CacheableString (int8_t type=(int8_t) GeodeTypeIds::CacheableASCIIString) |
| Default constructor. More...
|
|
void | copyString (const char *value, int32_t len) |
| Private method to populate the CacheableString . More...
|
|
void | copyString (const wchar_t *value, int32_t len) |
| Private method to populate the CacheableString . More...
|
|
char * | getASCIIString (const wchar_t *value, int32_t &len, int32_t &encodedLen) |
| Private method to get ASCII string for wide-string if possible. More...
|
|
void | initString (const char *value, int32_t len) |
| initialize the string, given a value and length. More...
|
|
void | initString (const wchar_t *value, int32_t len) |
| initialize the string, given a wide-char string and length. More...
|
|
void | initStringNoCopy (char *value, int32_t len) |
| Initialize the string without making a copy, given a C string and length. More...
|
|
void | initStringNoCopy (wchar_t *value, int32_t len) |
| Initialize the string without making a copy, given a wide-char string and length. More...
|
|
Implement a immutable C string wrapper that can serve as a distributable key object for caching as well as being a string value.
virtual apache::geode::client::CacheableString::~CacheableString |
( |
| ) |
|
|
virtual |
apache::geode::client::CacheableString::CacheableString |
( |
int8_t |
type = (int8_t) GeodeTypeIds::CacheableASCIIString | ) |
|
|
inlineprotected |
const char* apache::geode::client::CacheableString::asChar |
( |
| ) |
const |
|
inline |
Return the string that backs this CacheableString as a char *.
This shall throw an exception if the underlying string is a wchar_t* – the caller should use typeId
to determine the actual type, or isWideString
to find whether this is a wide-character string.
- Exceptions
-
IllegalStateException | if the underlying string is a wchar_t * |
const wchar_t* apache::geode::client::CacheableString::asWChar |
( |
| ) |
const |
|
inline |
Return the string that backs this CacheableString as a wchar_t *.
This shall throw an exception if the underlying string is a char* – the caller should use typeId
to determine the actual type, or isWideString
to find whether this is indeed a wide-character string.
- Exceptions
-
IllegalStateException | if the underlying string is a char * |
virtual int32_t apache::geode::client::CacheableString::classId |
( |
| ) |
const |
|
virtual |
virtual const char* apache::geode::client::CacheableString::className |
( |
| ) |
const |
|
inlinevirtual |
void apache::geode::client::CacheableString::copyString |
( |
const char * |
value, |
|
|
int32_t |
len |
|
) |
| |
|
protected |
void apache::geode::client::CacheableString::copyString |
( |
const wchar_t * |
value, |
|
|
int32_t |
len |
|
) |
| |
|
protected |
template<class PRIM >
static CacheableKeyPtr apache::geode::client::CacheableKey::create |
( |
const PRIM |
value | ) |
|
|
inlinestaticinherited |
Factory method that creates the key type that matches the type of value.
For customer defined derivations of CacheableKey, the method apache::geode::client::createKey may be overloaded. For pointer types (e.g. char*) the method apache::geode::client::createKeyArr may be overloaded.
static CacheableStringPtr apache::geode::client::CacheableString::create |
( |
const char * |
value, |
|
|
int32_t |
len = 0 |
|
) |
| |
|
inlinestatic |
Factory method for creating an instance of CacheableString from a null terminated C string optionally giving the length.
This should be used only for ASCII strings.
static CacheableStringPtr apache::geode::client::CacheableString::create |
( |
const wchar_t * |
value, |
|
|
int32_t |
len = 0 |
|
) |
| |
|
inlinestatic |
Factory method for creating an instance of CacheableString from a wide-character null terminated C string optionally giving the length.
This should be used for non-ASCII strings.
static Serializable* apache::geode::client::CacheableString::createDeserializable |
( |
| ) |
|
|
static |
creation function for strings
static Serializable* apache::geode::client::CacheableString::createDeserializableHuge |
( |
| ) |
|
|
static |
creation function for strings > 64K length
static CacheableStringPtr apache::geode::client::CacheableString::createNoCopy |
( |
char * |
value, |
|
|
int32_t |
len = 0 |
|
) |
| |
|
inlinestatic |
Factory method for creating an instance of CacheableString from a C string of given length by taking ownership of the string without making a copy.
The string should have been allocated using the standard C++ new operator.
This should be used only for ASCII strings.
CAUTION: use this only when you really know what you are doing.
static CacheableStringPtr apache::geode::client::CacheableString::createNoCopy |
( |
wchar_t * |
value, |
|
|
int32_t |
len = 0 |
|
) |
| |
|
inlinestatic |
Factory method for creating an instance of CacheableString from a wide-character C string of given length by taking ownership of the string without making a copy.
The string should have been allocated using the standard C++ new operator.
This should be used for non-ASCII strings.
CAUTION: use this only when you really know what you are doing.
static Serializable* apache::geode::client::CacheableString::createUTFDeserializable |
( |
| ) |
|
|
static |
creation function for wide strings
static Serializable* apache::geode::client::CacheableString::createUTFDeserializableHuge |
( |
| ) |
|
|
static |
creation function for wide strings > 64K length in UTF8 encoding
virtual int8_t apache::geode::client::Serializable::DSFID |
( |
| ) |
const |
|
virtualinherited |
char* apache::geode::client::CacheableString::getASCIIString |
( |
const wchar_t * |
value, |
|
|
int32_t & |
len, |
|
|
int32_t & |
encodedLen |
|
) |
| |
|
protected |
Private method to get ASCII string for wide-string if possible.
virtual int32_t apache::geode::client::CacheableString::hashcode |
( |
| ) |
const |
|
virtual |
void apache::geode::client::CacheableString::initString |
( |
const char * |
value, |
|
|
int32_t |
len |
|
) |
| |
|
protected |
initialize the string, given a value and length.
void apache::geode::client::CacheableString::initString |
( |
const wchar_t * |
value, |
|
|
int32_t |
len |
|
) |
| |
|
protected |
initialize the string, given a wide-char string and length.
void apache::geode::client::CacheableString::initStringNoCopy |
( |
char * |
value, |
|
|
int32_t |
len |
|
) |
| |
|
protected |
Initialize the string without making a copy, given a C string and length.
void apache::geode::client::CacheableString::initStringNoCopy |
( |
wchar_t * |
value, |
|
|
int32_t |
len |
|
) |
| |
|
protected |
Initialize the string without making a copy, given a wide-char string and length.
bool apache::geode::client::CacheableString::isCString |
( |
| ) |
const |
|
inline |
Returns true if the underlying string is a normal C string.
bool apache::geode::client::CacheableString::isWideString |
( |
| ) |
const |
|
inline |
Returns true if the underlying string is a wide-character string.
uint32_t apache::geode::client::CacheableString::length |
( |
| ) |
const |
|
inline |
Return the length of the contained string.
virtual int32_t apache::geode::client::CacheableString::logString |
( |
char * |
buffer, |
|
|
int32_t |
maxLength |
|
) |
| const |
|
virtual |
virtual uint32_t apache::geode::client::CacheableString::objectSize |
( |
| ) |
const |
|
virtual |
return the size in bytes of the instance being serialized.
This is used to determine whether the cache is using up more physical memory than it has been configured to use. The method can return zero if the user does not require the ability to control cache memory utilization. Note that you must implement this only if you use the HeapLRU feature.
Reimplemented from apache::geode::client::Serializable.
virtual bool apache::geode::client::CacheableString::operator== |
( |
const CacheableKey & |
other | ) |
const |
|
virtual |
void apache::geode::client::SharedBase::preserveSB |
( |
| ) |
const |
|
inherited |
Atomically increment reference count.
int32_t apache::geode::client::SharedBase::refCount |
( |
| ) |
|
|
inlineinherited |
- Returns
- the reference count
static void apache::geode::client::Serializable::registerPdxSerializer |
( |
PdxSerializerPtr |
pdxSerializer | ) |
|
|
staticinherited |
Register the PDX serializer which can handle serialization for instances of user domain classes.
- See also
- PdxSerializer
static void apache::geode::client::Serializable::registerPdxType |
( |
TypeFactoryMethodPdx |
creationFunction | ) |
|
|
staticinherited |
register an Pdx instance factory method for a given type.
- Exceptions
-
IllegalStateException | if the typeName has already been registered, or there is an error in registering the type; check errno for more information in the latter case. |
static void apache::geode::client::Serializable::registerType |
( |
TypeFactoryMethod |
creationFunction | ) |
|
|
staticinherited |
register an instance factory method for a given type.
During registration the factory will be invoked to extract the typeId to associate with this function.
- Exceptions
-
IllegalStateException | if the typeId has already been registered, or there is an error in registering the type; check errno for more information in the latter case. |
void apache::geode::client::SharedBase::releaseSB |
( |
| ) |
const |
|
inherited |
Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.
virtual void apache::geode::client::CacheableString::toData |
( |
DataOutput & |
output | ) |
const |
|
virtual |
const char* apache::geode::client::CacheableString::toString |
( |
| ) |
|
|
inline |
Display this object as c string.
In this case, it returns the same value as asChar() when underlying type is a char* and returns the same value as asWChar() cast to char* when the underlying type is a wchar_t*. To handle this correctly the user should find the actual type by calling typeId() or isWideString() and cast to the correct type accordingly. Note: this is a debugging API, not intended for getting the exact value of the CacheableString. In a future release this may return a more summary representation. This is historical. It is preferred that the user call logString or asChar/asWChar, depending on the need.
Display this object as 'string', which depends on the implementation in the subclasses.
The default implementation renders the classname.
The return value may be a temporary, so the caller has to ensure that the SharedPtr count does not go down to zero by storing the result in a variable or otherwise.
Reimplemented from apache::geode::client::Serializable.
virtual int8_t apache::geode::client::CacheableString::typeId |
( |
| ) |
const |
|
virtual |
Return the typeId byte of the instance being serialized.
This is used by deserialization to determine what instance type to create and deserialize into.
For a CacheableString
this shall return GeodeTypeIds::CacheableNullString
if the underlying string is null, GeodeTypeIds::CacheableASCIIString
if the underlying string is a char*, and GeodeTypeIds::CacheableString
if it is a wchar_t*. For strings larger than 64K it will return GeodeTypeIds::CacheableASCIIStringHuge
and GeodeTypeIds::CacheableStringHuge
for char* and wchar_t* respectively.
Reimplemented from apache::geode::client::Serializable.
Reimplemented in apache::geode::client::CacheableFileName.