File indexing completed on 2025-01-18 10:15:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_KVSTRINGPAIR_HPP)
0023 #define XERCESC_INCLUDE_GUARD_KVSTRINGPAIR_HPP
0024
0025 #include <xercesc/util/XMemory.hpp>
0026 #include <xercesc/util/PlatformUtils.hpp>
0027
0028 #include <xercesc/internal/XSerializable.hpp>
0029
0030 XERCES_CPP_NAMESPACE_BEGIN
0031
0032
0033
0034
0035
0036
0037 class XMLUTIL_EXPORT KVStringPair : public XSerializable, public XMemory
0038 {
0039 public:
0040
0041
0042
0043 KVStringPair(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0044 KVStringPair
0045 (
0046 const XMLCh* const key
0047 , const XMLCh* const value
0048 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0049 );
0050 KVStringPair
0051 (
0052 const XMLCh* const key
0053 , const XMLCh* const value
0054 , const XMLSize_t valueLength
0055 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0056 );
0057 KVStringPair
0058 (
0059 const XMLCh* const key
0060 , const XMLSize_t keyLength
0061 , const XMLCh* const value
0062 , const XMLSize_t valueLength
0063 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0064 );
0065 KVStringPair(const KVStringPair& toCopy);
0066 ~KVStringPair();
0067
0068
0069
0070
0071
0072
0073
0074 const XMLCh* getKey() const;
0075 XMLCh* getKey();
0076 const XMLCh* getValue() const;
0077 XMLCh* getValue();
0078
0079
0080
0081
0082
0083 void setKey(const XMLCh* const newKey);
0084 void setValue(const XMLCh* const newValue);
0085 void setKey
0086 (
0087 const XMLCh* const newKey
0088 , const XMLSize_t newKeyLength
0089 );
0090 void setValue
0091 (
0092 const XMLCh* const newValue
0093 , const XMLSize_t newValueLength
0094 );
0095 void set
0096 (
0097 const XMLCh* const newKey
0098 , const XMLCh* const newValue
0099 );
0100 void set
0101 (
0102 const XMLCh* const newKey
0103 , const XMLSize_t newKeyLength
0104 , const XMLCh* const newValue
0105 , const XMLSize_t newValueLength
0106 );
0107
0108
0109
0110
0111 DECL_XSERIALIZABLE(KVStringPair)
0112
0113 private :
0114
0115
0116 KVStringPair& operator=(const KVStringPair&);
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 XMLSize_t fKeyAllocSize;
0134 XMLSize_t fValueAllocSize;
0135 XMLCh* fKey;
0136 XMLCh* fValue;
0137 MemoryManager* fMemoryManager;
0138 };
0139
0140
0141
0142
0143 inline const XMLCh* KVStringPair::getKey() const
0144 {
0145 return fKey;
0146 }
0147
0148 inline XMLCh* KVStringPair::getKey()
0149 {
0150 return fKey;
0151 }
0152
0153 inline const XMLCh* KVStringPair::getValue() const
0154 {
0155 return fValue;
0156 }
0157
0158 inline XMLCh* KVStringPair::getValue()
0159 {
0160 return fValue;
0161 }
0162
0163
0164
0165
0166 inline void KVStringPair::setKey( const XMLCh* const newKey
0167 , const XMLSize_t newKeyLength)
0168 {
0169 if (newKeyLength >= fKeyAllocSize)
0170 {
0171 fMemoryManager->deallocate(fKey);
0172 fKey = 0;
0173 fKeyAllocSize = newKeyLength + 1;
0174 fKey = (XMLCh*) fMemoryManager->allocate(fKeyAllocSize * sizeof(XMLCh));
0175 }
0176
0177 memcpy(fKey, newKey, (newKeyLength+1) * sizeof(XMLCh));
0178 }
0179
0180 inline void KVStringPair::setValue( const XMLCh* const newValue
0181 , const XMLSize_t newValueLength)
0182 {
0183 if (newValueLength >= fValueAllocSize)
0184 {
0185 fMemoryManager->deallocate(fValue);
0186 fValue = 0;
0187 fValueAllocSize = newValueLength + 1;
0188 fValue = (XMLCh*) fMemoryManager->allocate(fValueAllocSize * sizeof(XMLCh));
0189 }
0190
0191 memcpy(fValue, newValue, (newValueLength+1) * sizeof(XMLCh));
0192 }
0193
0194 inline void KVStringPair::setKey(const XMLCh* const newKey)
0195 {
0196 setKey(newKey, XMLString::stringLen(newKey));
0197 }
0198
0199 inline void KVStringPair::setValue(const XMLCh* const newValue)
0200 {
0201 setValue(newValue, XMLString::stringLen(newValue));
0202 }
0203
0204 inline void KVStringPair::set( const XMLCh* const newKey
0205 , const XMLCh* const newValue)
0206 {
0207 setKey(newKey, XMLString::stringLen(newKey));
0208 setValue(newValue, XMLString::stringLen(newValue));
0209 }
0210
0211 inline void KVStringPair::set( const XMLCh* const newKey
0212 , const XMLSize_t newKeyLength
0213 , const XMLCh* const newValue
0214 , const XMLSize_t newValueLength)
0215 {
0216 setKey(newKey, newKeyLength);
0217 setValue(newValue, newValueLength);
0218 }
0219
0220
0221 XERCES_CPP_NAMESPACE_END
0222
0223 #endif