Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsArrayDeserializer.cpp
Go to the documentation of this file.
1 
14 #include "WsArrayDeserializer.h"
15 using namespace Json;
16 
18  m_json(json)
19 {
20 }
21 
23 {
24  /* Parse the received Json */
25  if (parse() == ErrorCode::Failure) {
26  return ErrorCode::Failure;
27  }
28  /* Deserialize each item and put it in vector*/
29  for (int i = 0; i < m_root["array"].size(); ++i) {
30  m_contents.insert(m_root["array"][i].asString());
31  }
32  return ErrorCode::Success;
33 }
34 
36 {
37  return m_contents;
38 }
39 
40 
42 {
43  if (!m_reader.parse(m_json, m_root, false)) {
44  LOG(ERROR) << "WsArrayDeserializer::parse() : Could not parse received input" << endl;
45  return ErrorCode::Failure;
46  }
47  return ErrorCode::Success;
48 }
int deserialize()
Deserialize contents serialized by WsArraySerialize::serialize.
std::set< std::string > m_contents
const int Failure
Deserializes contents of a directory sent.
std::string m_json
Json code.
#define LOG
Definition: WsLogger.h:22
Json::Reader m_reader
Json reader.
int parse()
parse the Json
WsArrayDeserializer(const std::string &json)
Constructor.
Json::Value m_root
Root of the Json tree.
const int Success
#define ERROR
Definition: WsLogger.h:42
const std::set< std::string > getContents()
returns the set serialized The method deserialize must be called prior to this method ...