activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1338758 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util: PrimitiveMap.cpp PrimitiveMap.h
Date Tue, 15 May 2012 15:38:57 GMT
Author: tabish
Date: Tue May 15 15:38:56 2012
New Revision: 1338758

URL: http://svn.apache.org/viewvc?rev=1338758&view=rev
Log:
Add accessor to the PrimitiveMap to get the underlying type for a value stored at the given
key.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp?rev=1338758&r1=1338757&r2=1338758&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp Tue May
15 15:38:56 2012
@@ -28,7 +28,7 @@ using namespace decaf::util;
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
-PrimitiveMap::PrimitiveMap() : converter() {
+PrimitiveMap::PrimitiveMap() : decaf::util::StlMap<std::string, PrimitiveValueNode>(),
converter() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -36,13 +36,13 @@ PrimitiveMap::~PrimitiveMap() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-PrimitiveMap::PrimitiveMap( const decaf::util::Map<std::string, PrimitiveValueNode>&
src )
-  : decaf::util::StlMap<std::string, PrimitiveValueNode>( src ), converter() {
+PrimitiveMap::PrimitiveMap(const decaf::util::Map<std::string, PrimitiveValueNode>&
src) :
+    decaf::util::StlMap<std::string, PrimitiveValueNode>(src), converter() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-PrimitiveMap::PrimitiveMap( const PrimitiveMap& src )
-  : decaf::util::StlMap<std::string, PrimitiveValueNode>( src ), converter() {
+PrimitiveMap::PrimitiveMap(const PrimitiveMap& src) :
+    decaf::util::StlMap<std::string, PrimitiveValueNode>(src), converter() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -53,9 +53,8 @@ std::string PrimitiveMap::toString() con
 
     stream << "Begin Class PrimitiveMap:" << std::endl;
 
-    for( std::size_t i = 0; i < keys.size(); ++i ) {
-        stream << "map[" << keys[i] << "] = "
-               << this->get( keys[i] ).toString() << std::endl;
+    for (std::size_t i = 0; i < keys.size(); ++i) {
+        stream << "map[" << keys[i] << "] = " << this->get(keys[i]).toString()
<< std::endl;
     }
 
     stream << "End Class PrimitiveMap:" << std::endl;
@@ -64,153 +63,137 @@ std::string PrimitiveMap::toString() con
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool PrimitiveMap::getBool( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<bool>( node );
+PrimitiveValueNode::PrimitiveType PrimitiveMap::getValueType(const std::string& key)
const {
+    PrimitiveValueNode node = this->get(key);
+    return node.getType();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setBool( const string& key, bool value ) {
+bool PrimitiveMap::getBool(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<bool> (node);
+}
 
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setBool(const string& key, bool value) {
     PrimitiveValueNode node;
-    node.setBool( value );
-
-    this->put( key, node );
+    node.setBool(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-unsigned char PrimitiveMap::getByte( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<unsigned char>( node );
+unsigned char PrimitiveMap::getByte(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<unsigned char> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setByte( const string& key, unsigned char value ) {
+void PrimitiveMap::setByte(const string& key, unsigned char value) {
     PrimitiveValueNode node;
-    node.setByte( value );
-
-    this->put( key, node );
+    node.setByte(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-char PrimitiveMap::getChar( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<char>( node );
+char PrimitiveMap::getChar(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<char> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setChar( const string& key, char value ) {
+void PrimitiveMap::setChar(const string& key, char value) {
     PrimitiveValueNode node;
-    node.setChar( value );
-
-    this->put( key, node );
+    node.setChar(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-short PrimitiveMap::getShort( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<short>( node );
+short PrimitiveMap::getShort(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<short> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setShort( const string& key, short value ) {
+void PrimitiveMap::setShort(const string& key, short value) {
     PrimitiveValueNode node;
-    node.setShort( value );
-
-    this->put( key, node );
+    node.setShort(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int PrimitiveMap::getInt( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<int>( node );
+int PrimitiveMap::getInt(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<int> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setInt( const string& key, int value ) {
+void PrimitiveMap::setInt(const string& key, int value) {
     PrimitiveValueNode node;
-    node.setInt( value );
-
-    this->put( key, node );
+    node.setInt(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long PrimitiveMap::getLong( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<long long>( node );
+long long PrimitiveMap::getLong(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<long long> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setLong( const string& key, long long value ) {
+void PrimitiveMap::setLong(const string& key, long long value) {
     PrimitiveValueNode node;
-    node.setLong( value );
-
-    this->put( key, node );
+    node.setLong(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-double PrimitiveMap::getDouble( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<double>( node );
+double PrimitiveMap::getDouble(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<double> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setDouble( const string& key, double value ) {
+void PrimitiveMap::setDouble(const string& key, double value) {
     PrimitiveValueNode node;
-    node.setDouble( value );
-
-    this->put( key, node );
+    node.setDouble(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-float PrimitiveMap::getFloat( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<float>( node );
+float PrimitiveMap::getFloat(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<float> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setFloat( const string& key, float value ) {
+void PrimitiveMap::setFloat(const string& key, float value) {
     PrimitiveValueNode node;
-    node.setFloat( value );
-
-    this->put( key, node );
+    node.setFloat(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-string PrimitiveMap::getString( const string& key ) const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert<std::string>( node );
+string PrimitiveMap::getString(const string& key) const {
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<std::string> (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setString( const string& key, const string& value ) {
+void PrimitiveMap::setString(const string& key, const string& value) {
     PrimitiveValueNode node;
-    node.setString( value );
-
-    this->put( key, node );
+    node.setString(value);
+    this->put(key, node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::vector<unsigned char> PrimitiveMap::getByteArray( const std::string& key )
const {
-
-    PrimitiveValueNode node = this->get( key );
-    return converter.convert< std::vector<unsigned char> >( node );
+std::vector<unsigned char> PrimitiveMap::getByteArray(const std::string& key) const
{
+    PrimitiveValueNode node = this->get(key);
+    return converter.convert<std::vector<unsigned char> > (node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void PrimitiveMap::setByteArray( const std::string& key, const std::vector<unsigned
char>& value ) {
-
+void PrimitiveMap::setByteArray(const std::string& key, const std::vector<unsigned
char>& value) {
     PrimitiveValueNode node;
-    node.setByteArray( value );
-
-    this->put( key, node );
+    node.setByteArray(value);
+    this->put(key, node);
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h?rev=1338758&r1=1338757&r2=1338758&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h Tue May
15 15:38:56 2012
@@ -27,8 +27,8 @@
 #include <activemq/util/PrimitiveValueNode.h>
 #include <activemq/util/PrimitiveValueConverter.h>
 
-namespace activemq{
-namespace util{
+namespace activemq {
+namespace util {
 
     /**
      * Map of named primitives.
@@ -53,7 +53,7 @@ namespace util{
          * @param source
          *      The Decaf Library Map instance whose elements will be copied into this Map.
          */
-        PrimitiveMap( const decaf::util::Map<std::string, PrimitiveValueNode>&
source );
+        PrimitiveMap(const decaf::util::Map<std::string, PrimitiveValueNode>& source);
 
         /**
          * Copy Constructor
@@ -61,7 +61,7 @@ namespace util{
          * @param source
          *      The PrimitiveMap whose elements will be copied into this Map.
          */
-        PrimitiveMap( const PrimitiveMap& source );
+        PrimitiveMap(const PrimitiveMap& source);
 
         /**
          * Converts the contents into a formatted string that can be output
@@ -72,6 +72,12 @@ namespace util{
         std::string toString() const;
 
         /**
+         * @returns the numeric type value for the given key if it exists.
+         * @throws NoSuchElementException if the key is not present in the map.
+         */
+        virtual PrimitiveValueNode::PrimitiveType getValueType(const std::string& key)
const;
+
+        /**
          * Gets the Boolean value at the given key, if the key is not
          * in the map or cannot be returned as the requested value then
          * an exception of type NoSuchElementException is thrown.
@@ -82,7 +88,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual bool getBool( const std::string& key ) const;
+        virtual bool getBool(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -90,7 +96,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setBool( const std::string& key, bool value );
+        virtual void setBool(const std::string& key, bool value);
 
         /**
          * Gets the Byte value at the given key, if the key is not
@@ -103,7 +109,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual unsigned char getByte( const std::string& key ) const;
+        virtual unsigned char getByte(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -111,7 +117,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setByte( const std::string& key, unsigned char value );
+        virtual void setByte(const std::string& key, unsigned char value);
 
         /**
          * Gets the Character value at the given key, if the key is not
@@ -124,7 +130,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual char getChar( const std::string& key ) const;
+        virtual char getChar(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -132,7 +138,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setChar( const std::string& key, char value );
+        virtual void setChar(const std::string& key, char value);
 
         /**
          * Gets the Short value at the given key, if the key is not
@@ -145,7 +151,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual short getShort( const std::string& key ) const;
+        virtual short getShort(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -153,7 +159,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setShort( const std::string& key, short value );
+        virtual void setShort(const std::string& key, short value);
 
         /**
          * Gets the Integer value at the given key, if the key is not
@@ -166,7 +172,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual int getInt( const std::string& key ) const;
+        virtual int getInt(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -174,7 +180,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setInt( const std::string& key, int value );
+        virtual void setInt(const std::string& key, int value);
 
         /**
          * Gets the Long value at the given key, if the key is not
@@ -187,7 +193,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual long long getLong( const std::string& key ) const;
+        virtual long long getLong(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -195,7 +201,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setLong( const std::string& key, long long value );
+        virtual void setLong(const std::string& key, long long value);
 
         /**
          * Gets the Float value at the given key, if the key is not
@@ -208,7 +214,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual float getFloat( const std::string& key ) const;
+        virtual float getFloat(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -216,7 +222,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setFloat( const std::string& key, float value );
+        virtual void setFloat(const std::string& key, float value);
 
         /**
          * Gets the Double value at the given key, if the key is not
@@ -229,7 +235,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual double getDouble( const std::string& key ) const;
+        virtual double getDouble(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -237,7 +243,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setDouble( const std::string& key, double value );
+        virtual void setDouble(const std::string& key, double value);
 
         /**
          * Gets the String value at the given key, if the key is not
@@ -250,7 +256,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual std::string getString( const std::string& key ) const;
+        virtual std::string getString(const std::string& key) const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -258,7 +264,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setString( const std::string& key, const std::string& value
);
+        virtual void setString(const std::string& key, const std::string& value);
 
         /**
          * Gets the Byte Array value at the given key, if the key is not
@@ -271,7 +277,7 @@ namespace util{
          * @throw UnSupportedOperationException if the value cannot be converted
          *                                      to the type this method returns
          */
-        virtual std::vector<unsigned char> getByteArray( const std::string& key
) const;
+        virtual std::vector<unsigned char> getByteArray(const std::string& key)
const;
 
         /**
          * Sets the value at key to the specified type. Overwrites any data
@@ -279,7 +285,7 @@ namespace util{
          * @param key - the map key to set or insert.
          * @param value - the new value to set at the key location.
          */
-        virtual void setByteArray( const std::string& key, const std::vector<unsigned
char>& value );
+        virtual void setByteArray(const std::string& key, const std::vector<unsigned
char>& value);
 
     };
 



Mime
View raw message