3 #ifndef GEODE_CACHEABLESTRING_H_ 4 #define GEODE_CACHEABLESTRING_H_ 23 #include "geode_globals.hpp" 26 #include "GeodeTypeIds.hpp" 36 #define GF_STRING (int8_t) GeodeTypeIds::CacheableASCIIString 37 #define GF_STRING_HUGE (int8_t) GeodeTypeIds::CacheableASCIIStringHuge 38 #define GF_WIDESTRING (int8_t) GeodeTypeIds::CacheableString 39 #define GF_WIDESTRING_HUGE (int8_t) GeodeTypeIds::CacheableStringHuge 50 mutable int m_hashcode;
82 virtual int32_t classId()
const;
99 virtual int8_t typeId()
const;
102 virtual bool operator==(
const CacheableKey& other)
const;
105 virtual int32_t hashcode()
const;
177 return (m_type == GF_STRING || m_type == GF_STRING_HUGE);
182 return (m_type == GF_WIDESTRING || m_type == GF_WIDESTRING_HUGE);
195 if (isWideString()) {
196 throw IllegalStateException(
197 "CacheableString::asChar: the string is a " 198 "wide character string; use asWChar() to obtain it.");
200 return reinterpret_cast<const char*
>(m_str);
214 throw IllegalStateException(
215 "CacheableString::asWChar: the string is " 216 "not a wide character string; use asChar() to obtain it.");
218 return reinterpret_cast<const wchar_t*
>(m_str);
222 inline uint32_t
length()
const {
return m_len; }
235 const char*
toString() {
return reinterpret_cast<const char*
>(m_str); }
242 virtual const char*
className()
const {
return "CacheableString"; }
248 virtual int32_t logString(
char* buffer, int32_t maxLength)
const;
250 virtual uint32_t objectSize()
const;
254 void copyString(
const char* value, int32_t len);
256 void copyString(
const wchar_t* value, int32_t len);
258 void initString(
const char* value, int32_t len);
263 void initStringNoCopy(
char* value, int32_t len);
265 void initString(
const wchar_t* value, int32_t len);
270 void initStringNoCopy(
wchar_t* value, int32_t len);
272 char* getASCIIString(
const wchar_t* value, int32_t& len, int32_t& encodedLen);
275 : m_str(NULL), m_type(type), m_len(0), m_hashcode(0) {}
310 #endif // GEODE_CACHEABLESTRING_H_ 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:166
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:147
bool isCString() const
Returns true if the underlying string is a normal C string.
Definition: CacheableString.hpp:176
CacheablePtr createValueArr(const char *value)
overload of apache::geode::client::createValueArr to pass char*
Definition: CacheableString.hpp:296
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
virtual const char * className() const
get the name of the class of this object for logging purpose
Definition: CacheableString.hpp:242
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:113
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
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:132
const char * toString()
Display this object as c string.
Definition: CacheableString.hpp:235
const char * asChar() const
Return the string that backs this CacheableString as a char *.
Definition: CacheableString.hpp:194
const wchar_t * asWChar() const
Return the string that backs this CacheableString as a wchar_t *.
Definition: CacheableString.hpp:212
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:74
CacheableString(int8_t type=(int8_t) GeodeTypeIds::CacheableASCIIString)
Default constructor.
Definition: CacheableString.hpp:274
Implement a immutable C string wrapper that can serve as a distributable key object for caching as we...
Definition: CacheableString.hpp:45
bool isWideString() const
Returns true if the underlying string is a wide-character string.
Definition: CacheableString.hpp:181
void initStringNoCopy(char *value, int32_t len)
Initialize the string without making a copy, given a C string and length.
virtual CacheableStringPtr toString() const
Display this object as 'string', which depends on the implementation in the subclasses.
Definition: CacheableString.hpp:237
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:53
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:56
Represents a cacheable key.
Definition: CacheableKey.hpp:36
uint32_t length() const
Return the length of the contained string.
Definition: CacheableString.hpp:222
CacheableKeyPtr createKeyArr(const char *value)
overload of apache::geode::client::createKeyArr to pass char*
Definition: CacheableString.hpp:284
This namespace contains all the Geode C++ API classes, enumerations and globals.
void initString(const char *value, int32_t len)
initialize the string, given a value and length.