1 #ifndef _GEMFIRE_CACHEABLESTRING_HPP_ 2 #define _GEMFIRE_CACHEABLESTRING_HPP_ 12 #include "gfcpp_globals.hpp" 15 #include "GemfireTypeIds.hpp" 24 #define GF_STRING (int8_t)GemfireTypeIds::CacheableASCIIString 25 #define GF_STRING_HUGE (int8_t)GemfireTypeIds::CacheableASCIIStringHuge 26 #define GF_WIDESTRING (int8_t)GemfireTypeIds::CacheableString 27 #define GF_WIDESTRING_HUGE (int8_t)GemfireTypeIds::CacheableStringHuge 39 mutable int m_hashcode;
71 virtual int32_t classId()
const;
88 virtual int8_t typeId()
const;
91 virtual bool operator==(
const CacheableKey& other)
const;
94 virtual uint32_t hashcode()
const;
171 return (m_type == GF_STRING || m_type == GF_STRING_HUGE);
177 return (m_type == GF_WIDESTRING || m_type == GF_WIDESTRING_HUGE);
191 if (isWideString()) {
192 throw IllegalStateException(
"CacheableString::asChar: the string is a " 193 "wide character string; use asWChar() to obtain it.");
195 return (
const char*) m_str;
210 throw IllegalStateException(
"CacheableString::asWChar: the string is " 211 "not a wide character string; use asChar() to obtain it.");
213 return (
const wchar_t*) m_str;
235 return (
const char*) m_str;
246 return "CacheableString";
253 virtual int32_t logString(
char* buffer, int32_t maxLength)
const;
255 virtual uint32_t objectSize()
const;
260 void copyString(
const char* value, int32_t len);
262 void copyString(
const wchar_t* value, int32_t len);
264 void initString(
const char* value, int32_t len);
269 void initStringNoCopy(
char* value, int32_t len);
271 void initString(
const wchar_t* value, int32_t len);
276 void initStringNoCopy(
wchar_t* value, int32_t len);
278 char* getASCIIString(
const wchar_t* value, int32_t& len,
279 int32_t& encodedLen);
282 m_str(NULL), m_type(type), m_len(0), m_hashcode(0)
296 value).ptr()) : NULLPTR);
303 value).ptr()) : NULLPTR);
310 value).ptr()) : NULLPTR);
317 value).ptr()) : NULLPTR);
uint32_t length() const
Return the length of the contained string.
Definition: CacheableString.hpp:217
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:62
CacheableString(int8_t type=(int8_t) GemfireTypeIds::CacheableASCIIString)
Default constructor.
Definition: CacheableString.hpp:281
virtual const char * className() const
get the name of the class of this object for logging purpose
Definition: CacheableString.hpp:244
virtual CacheableStringPtr toString() const
Display this object as 'string', which depends on the implementation in the subclasses.
Definition: CacheableString.hpp:238
void initStringNoCopy(char *value, int32_t len)
Initialize the string without making a copy, given a C string and length.
static CacheableStringPtr createNoCopy(char *value, int32_t len=0)
Factory method for creating an instance of CacheableString from a C string of given length by taking ...
Definition: CacheableString.hpp:122
Represents a cacheable key.
Definition: CacheableKey.hpp:23
static CacheableStringPtr create(const char *value, int32_t len=0)
Factory method for creating an instance of CacheableString from a null terminated C string optionally...
Definition: CacheableString.hpp:102
const char * asChar() const
Return the string that backs this CacheableString as a char *.
Definition: CacheableString.hpp:189
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
Implement a immutable C string wrapper that can serve as a distributable key object for caching as we...
Definition: CacheableString.hpp:33
CacheableKeyPtr createKeyArr(const char *value)
overload of gemfire::createKeyArr to pass char*
Definition: CacheableString.hpp:293
bool isWideString() const
Returns true if the underlying string is a wide-character string.
Definition: CacheableString.hpp:175
void initString(const char *value, int32_t len)
initialize the string, given a value and length.
bool isCString() const
Returns true if the underlying string is a normal C string.
Definition: CacheableString.hpp:169
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:39
static CacheableStringPtr createNoCopy(wchar_t *value, int32_t len=0)
Factory method for creating an instance of CacheableString from a wide-character C string of given le...
Definition: CacheableString.hpp:158
#define CPPCACHE_EXPORT
Defines a GemFire CPPCACHE export.
Definition: gf_base.hpp:51
const wchar_t * asWChar() const
Return the string that backs this CacheableString as a wchar_t *.
Definition: CacheableString.hpp:207
const char * toString()
Display this object as c string.
Definition: CacheableString.hpp:233
CacheablePtr createValueArr(const char *value)
overload of gemfire::createValueArr to pass char*
Definition: CacheableString.hpp:307
static CacheableStringPtr create(const wchar_t *value, int32_t len=0)
Factory method for creating an instance of CacheableString from a wide-character null terminated C st...
Definition: CacheableString.hpp:138