Value.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <etk/types.hpp>
9 #include <ememory/memory.hpp>
10 #include <ejson/FilePos.hpp>
11 #include <ejson/valueType.hpp>
12 #include <ejson/internal/Value.hpp>
13 
17 namespace ejson {
18  class Document;
19  class Array;
20  class Object;
21  class Boolean;
22  class Null;
23  class Number;
24  class String;
25  namespace internal {
26  class Value;
27  }
31  class Value {
32  friend class ejson::Array;
33  friend class ejson::Object;
34  protected:
36  public:
41  enum ejson::valueType getType() const;
42  public:
51  Value();
52  public:
56  virtual ~Value() = default;
57  public:
61  void display() const;
67  bool exist() const;
77  const ejson::Document toDocument() const;
87  const ejson::Array toArray() const;
97  const ejson::Object toObject() const;
107  const ejson::String toString() const;
117  const ejson::Number toNumber() const;
127  const ejson::Boolean toBoolean() const;
137  const ejson::Null toNull() const;
138 
143  bool isDocument() const;
148  bool isArray() const;
153  bool isObject() const;
158  bool isString() const;
163  bool isNumber() const;
168  bool isBoolean() const;
173  bool isNull() const;
177  void clear();
184  bool transfertIn(ejson::Value& _obj);
189  ejson::Value clone() const;
190  public:
201  };
203  std::ostream& operator <<(std::ostream& _os, const ejson::Value& _obj);
209 }
210 
211 #include <ejson/Array.hpp>
212 #include <ejson/Boolean.hpp>
213 #include <ejson/Null.hpp>
214 #include <ejson/Number.hpp>
215 #include <ejson/Object.hpp>
216 #include <ejson/String.hpp>
217 
218 
ememory::SharedPtr< ejson::internal::Value > m_data
internal reference on a Value
Definition: Value.hpp:35
bool isString() const
check if the node is a ejson::String
bool isBoolean() const
check if the node is a ejson::Boolean
ejson::Number toNumber()
Cast the element in a Number if it is possible.
enum ejson::valueType getType() const
Get Value type.
std::string generateHumanString() const
generate a string that contain the created JSON
std::string generateMachineString() const
generate a string that contain the created JSON
the element "..."
virtual void clear()
clear the Node
ejson namespace containing all function for JSON interpretor
Definition: Array.hpp:12
ejson Boolean interface: true/false.
Definition: Boolean.hpp:15
ejson::Array toArray()
Cast the element in a Array if it is possible.
ejson String interface.
Definition: String.hpp:15
bool isObject() const
check if the node is a ejson::Object
ejson Object interface { ... }.
Definition: Object.hpp:18
Value()
basic element of a xml structure
Definition: Value.hpp:55
bool isNumber() const
check if the node is a ejson::Number
ejson::Boolean toBoolean()
Cast the element in a Boolean if it is possible.
ejson Array interface [ ... ].
Definition: Array.hpp:16
ejson Number interface.
Definition: Number.hpp:15
ejson::Null toNull()
Cast the element in a Null if it is possible.
valueType
Type of the JSON elements.
Definition: valueType.hpp:14
void display() const
Display the Document on console.
ejson::Object toObject()
Cast the element in a Object if it is possible.
const char32_t Null
virtual ememory::SharedPtr< ejson::internal::Value > clone() const
Copy the curent node and all the child in the curent one.
bool isNull() const
check if the node is a ejson::Null
Basic main object of all json elements.
Definition: Value.hpp:31
ejson Null interface: &#39;null&#39;.
Definition: Null.hpp:15
bool isArray() const
check if the node is a ejson::Array
ejson Document interface (acces with the file and stream).
Definition: Document.hpp:19
bool isDocument() const
check if the node is a ejson::Document
virtual ~Value()
Virtualize destructor.
virtual bool transfertIn(ememory::SharedPtr< ejson::internal::Value > _obj)
Tranfert all element in the element set in parameter.
bool exist() const
Check if the element exit.
ejson::String toString()
Cast the element in a String if it is possible.
ejson::Value empty()
create an empty Value (that does not exist ...
ejson::Document toDocument()
Cast the element in a Document if it is possible.