Merge "New APIs : hasAttribute, numberOfAttributes, erase in OCRepresentation."
authorErich Keane <erich.keane@intel.com>
Mon, 29 Sep 2014 17:46:55 +0000 (10:46 -0700)
committerGerrit Code Review <gerrit@oicreview.vlan14.01.org>
Mon, 29 Sep 2014 17:46:55 +0000 (10:46 -0700)
1  2 
include/OCApi.h

diff --combined include/OCApi.h
@@@ -36,7 -36,6 +36,7 @@@
  
  namespace OC
  {
 +    class OCPlatform;
      class OCResource;
      class OCResourceRequest;
      class OCResourceResponse;
@@@ -142,6 -141,11 +142,11 @@@ namespace O
          public:
          OCRepresentation() {}
  
+         bool erase(const std::string& str)
+         {
+             return m_attributeMap.erase(str) != 0;
+         }
          std::string getUri(void) const
          {
              return m_uri;
          template <typename T>
          bool getValue(const std::string& str, T& val) const;
  
+         template <typename T>
+         T getValue(const std::string& str) const;
+         bool hasAttribute(const std::string& str) const
+         {
+             return m_attributeMap.find(str) != m_attributeMap.end();
+         }
+         int numberOfAttributes() const
+         {
+             return m_attributeMap.size();
+         }
          void setUri(std::string uri)
          {
              m_uri = uri;
          m_attributeMap[str] = getJSON(val);
      }
  
+     template <typename T>
+     T OCRepresentation::getValue(const std::string& str) const
+     {
+         T val;
+         auto x = m_attributeMap.find(str);
+         if(m_attributeMap.end() != x)
+         {
+             AttributeValue v = val;
+             parseJSON(v, x->second);
+             val = boost::get<T>(v);
+         }
+         return val;
+     }
  
      template <typename T>
      bool OCRepresentation::getValue(const std::string& str, T& val) const