#include <OCException.h>
-namespace cereal
-{
- class access;
-}
-
namespace OC
{
DefaultChild
};
- // The consumer requires resource info to be printed in 2 different ways, both with the "oc":[]
- // and without. This enum is used to differentiate between the two situations. When the
- // serialize is called with Include OC, we encode OC, otherwise we skip it and return just the
- // contents of the array.
- enum class OCInfoFormat
- {
- IncludeOC,
- ExcludeOC
- };
-
class MessageContainer
{
public:
- void setJSONRepresentation(const std::string& payload);
+ void setPayload(const OCPayload* rep);
+
+ void setPayload(const OCDevicePayload* rep);
- void setJSONRepresentation(const char* payload);
+ void setPayload(const OCPlatformPayload* rep);
- std::string getJSONRepresentation(OCInfoFormat f) const;
+ void setPayload(const OCRepPayload* rep);
+
+ OCRepPayload* getPayload() const;
const std::vector<OCRepresentation>& representations() const;
virtual ~OCRepresentation(){}
- std::string getJSONRepresentation() const;
+ OCRepPayload* getPayload() const;
void addChild(const OCRepresentation&);
void setChildren(const std::vector<OCRepresentation>& children);
+ void setUri(const char* uri);
+
void setUri(const std::string& uri);
std::string getUri() const;
void setResourceTypes(const std::vector<std::string>& resourceTypes);
+ void addResourceType(const std::string& str);
+
const std::vector<std::string>& getResourceInterfaces() const;
void setResourceInterfaces(const std::vector<std::string>& resourceInterfaces);
+ void addResourceInterface(const std::string& str);
+
bool emptyData() const;
int numberOfAttributes() const;
const AttributeItem operator[](const std::string& key) const;
private:
friend class OCResourceResponse;
- friend class cereal::access;
-
+ friend class MessageContainer;
+
+ template<typename T>
+ void payload_array_helper(const OCRepPayloadValue* pl, size_t depth);
+ template<typename T>
+ T payload_array_helper_copy(size_t index, const OCRepPayloadValue* pl);
+ void setPayload(const OCRepPayload* payload);
+ void setPayloadArray(const OCRepPayloadValue* pl);
+ void getPayloadArray(OCRepPayload* payload,
+ const OCRepresentation::AttributeItem& item) const;
// the root node has a slightly different JSON version
// based on the interface type configured in ResourceResponse.
// This allows ResourceResponse to set it, so that the save function
m_interfaces(interfaces)
{}*/
private:
- friend class cereal::access;
- template <class Archive>
- void save(Archive& ar) const;
-
- template<class Archive>
- void load(Archive& ar);
-
std::vector<std::string>& m_types;
std::vector<std::string>& m_interfaces;
};
- template<class Archive, class Val>
- static void optional_load(Archive& ar, Val&& v);
-
- template<class Archive>
- void save(Archive& ar) const;
-
- template<class Archive>
- void load(Archive& ar);
-
private:
std::string m_uri;
std::vector<OCRepresentation> m_children;