gemfire::CacheableString Class Reference

Inherits gemfire::CacheableKey.

Inherited by gemfire::CacheableFileName.


Detailed Description

Implement a immutable C string wrapper that can serve as a distributable key object for caching as well as being a string value.

Public Member Functions

const char * asChar () const
 Return the string that backs this CacheableString as a char *.
const wchar_t * asWChar () const
 Return the string that backs this CacheableString as a wchar_t *.
virtual int8_t classId () const
virtual SerializablefromData (DataInput &input)
virtual uint32_t hashcode () const
 return the hashcode for this key.
bool isWideString () const
 Returns true if the underlying string is a wide-character string.
uint16_t length () const
 Return the length of the contained string.
virtual size_t logString (char *buffer, size_t maxLength) const
 used to render as a string for logging.
virtual uint32_t objectSize () const
virtual bool operator== (const CacheableKey &other) const
 return true if this key matches other.
void preserveSB () const
 Atomically increment reference count.
int32_t refCount ()
 
Returns:
the reference count

void releaseSB () const
 Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.
virtual void toData (DataOutput &output) const
virtual
CacheableStringPtr 
toString () const
 Display this object as 'string', which depends on the implementation in the subclasses.
const char * toString ()
 Display this object as c string.
virtual int8_t typeId () const
virtual ~CacheableString ()
 Destructor.

Static Public Member Functions

template<class PRIM>
static CacheableKeyPtr create (const PRIM value)
 Factory method that creates the key type that matches the type of value.
static CacheableStringPtr create (const wchar_t *value, size_t len)
 Factory method for creating an instance of CacheableString from a wide-character C string of given length.
static CacheableStringPtr create (const wchar_t *value)
 Factory method for creating an instance of CacheableString from a wide-character null terminated C string.
static CacheableStringPtr create (const char *value, size_t len)
 Factory method for creating an instance of CacheableString from a C string of given length.
static CacheableStringPtr create (const char *value)
 Factory method for creating an instance of CacheableString from a null terminated C string.
static SerializablecreateDeserializable ()
static SerializablecreateNullDeserializable ()
static SerializablecreateUTFDeserializable ()
static void registerType (TypeFactoryMethod creationFunction)

Protected Member Functions

 CacheableString (int8_t type=(int8_t) GemfireTypeIds::CacheableNullString)
 Constructor, used for deserialization.
 CacheableString (const wchar_t *value, size_t len)
 Constructor, given a wide-char string and length.
 CacheableString (const wchar_t *value)
 Constructor, given a wide-char string.
 CacheableString (const char *value, size_t len)
 Constructor, given a value and length.
 CacheableString (const char *value)
 Constructor, given a value.
void copyString (const wchar_t *value, size_t len)
 Private method to populate the CacheableString.
void copyString (const char *value, size_t len)
 Private method to populate the CacheableString.

Constructor & Destructor Documentation

virtual gemfire::CacheableString::~CacheableString (  )  [virtual]

Destructor.

gemfire::CacheableString::CacheableString ( const char *  value  )  [protected]

Constructor, given a value.

gemfire::CacheableString::CacheableString ( const char *  value,
size_t  len 
) [protected]

Constructor, given a value and length.

gemfire::CacheableString::CacheableString ( const wchar_t *  value  )  [protected]

Constructor, given a wide-char string.

gemfire::CacheableString::CacheableString ( const wchar_t *  value,
size_t  len 
) [protected]

Constructor, given a wide-char string and length.

gemfire::CacheableString::CacheableString ( int8_t  type = (int8_t)GemfireTypeIds::CacheableNullString  )  [inline, protected]

Constructor, used for deserialization.


Member Function Documentation

const char* gemfire::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* gemfire::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 int8_t gemfire::CacheableString::classId (  )  const [virtual]

Return the classId byte of the instance being serialized. This is used by deserialization to determine what instance type to create and derserialize into.

Implements gemfire::Serializable.

Reimplemented in gemfire::CacheableFileName.

void gemfire::CacheableString::copyString ( const wchar_t *  value,
size_t  len 
) [protected]

Private method to populate the CacheableString.

void gemfire::CacheableString::copyString ( const char *  value,
size_t  len 
) [protected]

Private method to populate the CacheableString.

template<class PRIM>
static CacheableKeyPtr gemfire::CacheableKey::create ( const PRIM  value  )  [inline, static, inherited]

Factory method that creates the key type that matches the type of value.

For customer defined derivations of CacheableKey, the method gemfire::createKey may be overloaded. For pointer types (e.g. char*) the method gemfire::createKeyArr may be overloaded.

Reimplemented from gemfire::Serializable.

static CacheableStringPtr gemfire::CacheableString::create ( const wchar_t *  value,
size_t  len 
) [inline, static]

Factory method for creating an instance of CacheableString from a wide-character C string of given length.

Throw IllegalArgumentException if the converted value's length is greater than 64K bytes.

Reimplemented in gemfire::CacheableFileName.

static CacheableStringPtr gemfire::CacheableString::create ( const wchar_t *  value  )  [inline, static]

Factory method for creating an instance of CacheableString from a wide-character null terminated C string.

Throw IllegalArgumentException if the converted value's length is greater than 64K bytes.

Reimplemented in gemfire::CacheableFileName.

static CacheableStringPtr gemfire::CacheableString::create ( const char *  value,
size_t  len 
) [inline, static]

Factory method for creating an instance of CacheableString from a C string of given length.

Throw IllegalArgumentException if the value's length is greater than 64K bytes.

Reimplemented in gemfire::CacheableFileName.

static CacheableStringPtr gemfire::CacheableString::create ( const char *  value  )  [inline, static]

Factory method for creating an instance of CacheableString from a null terminated C string.

Throw IllegalArgumentException if the value's length is greater than 64K bytes.

Reimplemented in gemfire::CacheableFileName.

static Serializable* gemfire::CacheableString::createDeserializable (  )  [static]

creation function for strings.

Reimplemented in gemfire::CacheableFileName.

static Serializable* gemfire::CacheableString::createNullDeserializable (  )  [static]

creation function for null strings.

static Serializable* gemfire::CacheableString::createUTFDeserializable (  )  [static]

creation function for wide strings.

virtual Serializable* gemfire::CacheableString::fromData ( DataInput &  input  )  [virtual]

deserialize this object Throw IllegalArgumentException if the packed CacheableString is not less than 64K bytes.

Implements gemfire::Serializable.

Reimplemented in gemfire::CacheableFileName.

virtual uint32_t gemfire::CacheableString::hashcode (  )  const [virtual]

return the hashcode for this key.

Implements gemfire::CacheableKey.

bool gemfire::CacheableString::isWideString (  )  const [inline]

Returns true if the underlying string is a wide-character string.

uint16_t gemfire::CacheableString::length (  )  const [inline]

Return the length of the contained string.

virtual size_t gemfire::CacheableString::logString ( char *  buffer,
size_t  maxLength 
) const [virtual]

used to render as a string for logging.

Reimplemented from gemfire::CacheableKey.

Reimplemented in gemfire::CacheableFileName.

virtual uint32_t gemfire::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.

Implements gemfire::Serializable.

virtual bool gemfire::CacheableString::operator== ( const CacheableKey other  )  const [virtual]

return true if this key matches other.

Implements gemfire::CacheableKey.

void gemfire::SharedBase::preserveSB (  )  const [inherited]

Atomically increment reference count.

int32_t gemfire::SharedBase::refCount (  )  [inline, inherited]

Returns:
the reference count

static void gemfire::Serializable::registerType ( TypeFactoryMethod  creationFunction  )  [static, inherited]

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 gemfire::SharedBase::releaseSB (  )  const [inherited]

Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.

virtual void gemfire::CacheableString::toData ( DataOutput &  output  )  const [virtual]

serialize this object

Implements gemfire::Serializable.

Reimplemented in gemfire::CacheableFileName.

virtual CacheableStringPtr gemfire::CacheableString::toString (  )  const [inline, virtual]

Display this object as 'string', which depends on the implementation in the subclasses.

The default implementation renders the classname.

Reimplemented from gemfire::Serializable.

const char* gemfire::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.

virtual int8_t gemfire::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 derserialize into.

For a CacheableString this shall return GemfireTypeIds::CacheableNullString if the underlying string is null, GemfireTypeIds::CacheableStringByte if the underlying string is a char*, and GemfireTypeIds::CacheableString if it is a wchar_t*.

Reimplemented from gemfire::Serializable.

Reimplemented in gemfire::CacheableFileName.


GemFire C++ Cache API Documentation