|
activemq-cpp-3.4.0
|
00001 00018 #ifndef _ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_ 00019 #define _ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <decaf/util/NoSuchElementException.h> 00023 #include <decaf/util/Map.h> 00024 #include <decaf/util/List.h> 00025 00026 namespace activemq{ 00027 namespace util{ 00028 00038 class AMQCPP_API PrimitiveValueNode { 00039 public: 00040 00044 enum PrimitiveType{ 00045 NULL_TYPE = 0, 00046 BOOLEAN_TYPE = 1, 00047 BYTE_TYPE = 2, 00048 CHAR_TYPE = 3, 00049 SHORT_TYPE = 4, 00050 INTEGER_TYPE = 5, 00051 LONG_TYPE = 6, 00052 DOUBLE_TYPE = 7, 00053 FLOAT_TYPE = 8, 00054 STRING_TYPE = 9, 00055 BYTE_ARRAY_TYPE = 10, 00056 MAP_TYPE = 11, 00057 LIST_TYPE = 12, 00058 BIG_STRING_TYPE = 13 00059 }; 00060 00064 union PrimitiveValue { 00065 00066 bool boolValue; 00067 unsigned char byteValue; 00068 char charValue; 00069 short shortValue; 00070 int intValue; 00071 long long longValue; 00072 double doubleValue; 00073 float floatValue; 00074 std::string* stringValue; 00075 std::vector<unsigned char>* byteArrayValue; 00076 decaf::util::List<PrimitiveValueNode>* listValue; 00077 decaf::util::Map<std::string, PrimitiveValueNode>* mapValue; 00078 00079 }; 00080 00081 private: 00082 00083 PrimitiveType valueType; 00084 PrimitiveValue value; 00085 00086 public: 00087 00091 PrimitiveValueNode(); 00092 00097 PrimitiveValueNode( bool value ); 00098 00103 PrimitiveValueNode( unsigned char value ); 00104 00109 PrimitiveValueNode( char value ); 00110 00115 PrimitiveValueNode( short value ); 00116 00121 PrimitiveValueNode( int value ); 00122 00127 PrimitiveValueNode( long long value ); 00128 00133 PrimitiveValueNode( float value ); 00134 00139 PrimitiveValueNode( double value ); 00140 00145 PrimitiveValueNode( const char* value ); 00146 00151 PrimitiveValueNode( const std::string& value ); 00152 00157 PrimitiveValueNode( const std::vector<unsigned char>& value ); 00158 00163 PrimitiveValueNode( const decaf::util::List<PrimitiveValueNode>& value ); 00164 00169 PrimitiveValueNode( 00170 const decaf::util::Map<std::string, PrimitiveValueNode>& value ); 00171 00177 PrimitiveValueNode( const PrimitiveValueNode& node ); 00178 00179 ~PrimitiveValueNode(){ 00180 clear(); 00181 } 00182 00189 PrimitiveValueNode& operator =( const PrimitiveValueNode& node ); 00190 00195 bool operator==( const PrimitiveValueNode& node ) const; 00196 00201 PrimitiveType getType() const { return valueType; } 00202 00207 PrimitiveValue getValue() const { 00208 return this->value; 00209 } 00210 00220 void setValue( const PrimitiveValue& value, PrimitiveType valueType ); 00221 00226 void clear(); 00227 00234 void setBool( bool value ); 00235 00242 bool getBool() const; 00243 00250 void setByte( unsigned char value ); 00251 00258 unsigned char getByte() const; 00259 00266 void setChar( char value ); 00267 00274 char getChar() const; 00275 00282 void setShort( short value ); 00283 00290 short getShort() const; 00291 00298 void setInt( int value ); 00299 00306 int getInt() const; 00307 00314 void setLong( long long value ); 00315 00322 long long getLong() const; 00323 00330 void setFloat( float value ); 00331 00338 float getFloat() const; 00339 00346 void setDouble( double value ); 00347 00354 double getDouble() const; 00355 00362 void setString( const std::string& value ); 00363 00370 std::string getString() const; 00371 00378 void setByteArray( const std::vector<unsigned char>& value ); 00379 00386 std::vector<unsigned char> getByteArray() const; 00387 00394 void setList( const decaf::util::List<PrimitiveValueNode>& value ); 00395 00402 const decaf::util::List<PrimitiveValueNode>& getList() const; 00403 00410 void setMap( const decaf::util::Map<std::string, PrimitiveValueNode>& value ); 00411 00418 const decaf::util::Map<std::string, PrimitiveValueNode>& getMap() const; 00419 00424 std::string toString() const; 00425 00426 }; 00427 00428 }} 00429 00430 #endif /*_ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_*/