Object.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <etk/types.hpp>
9 #include <etk/Hash.hpp>
10 #include <algorithm>
11 #include <ejson/internal/Value.hpp>
12 
13 namespace ejson {
14  namespace internal {
18  class Object : public ejson::internal::Value {
19  protected:
23  Object() {
25  };
26  public:
37  static ememory::SharedPtr<Object> create(const std::string& _data);
38  protected:
39  // TODO : Change this with a generic methode ...
41  public:
47  bool exist(const std::string& _name) const;
59  const ememory::SharedPtr<ejson::internal::Value> get(const std::string& _name) const;
60  public:
65  std::vector<std::string> getKeys() const;
70  size_t size() const;
82  const ememory::SharedPtr<ejson::internal::Value> get(size_t _id) const;
88  std::string getKey(size_t _id) const;
89  public:
101  void remove(const std::string& _name);
106  void remove(size_t _id);
118  public:
119  bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override;
120  bool iGenerate(std::string& _data, size_t _indent) const override;
121  void iMachineGenerate(std::string& _data) const override;
122  void clear() override;
125  };
126  }
127 }
128 
void iMachineGenerate(std::string &_data) const override
generate a string with the tree of the json (not human readable ==> for computer transfer) ...
bool exist(const std::string &_name) const
check if an element exist.
void clear() override
clear the Node
std::string getKey(size_t _id) const
Get the element name (key).
the element "..."
bool iGenerate(std::string &_data, size_t _indent) const override
generate a string with the tree of the json
bool iParse(const std::string &_data, size_t &_pos, ejson::FilePos &_filePos, ejson::internal::Document &_doc) override
parse the Current node [pure VIRUAL]
ejson namespace containing all function for JSON interpretor
Definition: Array.hpp:12
bool transfertIn(ememory::SharedPtr< ejson::internal::Value > _obj) override
Tranfert all element in the element set in parameter.
std::vector< std::string > getKeys() const
Get all the element name (keys).
Position in the file of the original data.
Definition: FilePos.hpp:14
bool cloneIn(ememory::SharedPtr< ejson::internal::Object > &_obj) const
Clone the current object in an other Object.
Object()
basic element of a xml structure
Definition: Object.hpp:23
etk::Hash< ememory::SharedPtr< ejson::internal::Value > > m_value
value of the node (for element this is the name, for text it is the inside text ...)
Definition: Object.hpp:40
ejson Document internal data implementation.
Definition: Document.hpp:20
enum ejson::valueType m_type
Type of the element.
Definition: Value.hpp:44
ememory::SharedPtr< ejson::internal::Object > cloneObj() const
Clone the current object.
bool add(const std::string &_name, ememory::SharedPtr< ejson::internal::Value > _value)
add an element in the Object
static ememory::SharedPtr< Object > create()
Create factory on the ejson::internal::Object.
ejson Object internal data implementation.
Definition: Object.hpp:18
Basic main object of all json data.
Definition: Value.hpp:42
size_t size() const
get the number of sub element in the current one
ememory::SharedPtr< ejson::internal::Value > clone() const override
Copy the curent node and all the child in the curent one.
the element { ... }