Number.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <etk/types.hpp>
10 
11 namespace ejson {
12  namespace internal {
16  class Number : public ejson::internal::Value {
17  protected:
22  Number(uint64_t _value=0);
23  Number(int64_t _value);
24  Number(double _value);
25  public:
31  static ememory::SharedPtr<Number> create(uint64_t _value=0);
32  static ememory::SharedPtr<Number> create(int64_t _value);
33  static ememory::SharedPtr<Number> create(double _value);
34  public:
35  enum class type {
36  tDouble,
37  tInt,
38  tUint,
39  };
40  protected:
41  type m_typeNumber;
42  union {
43  double m_value;
44  uint64_t m_valueU64;
45  int64_t m_valueI64;
46  };
47  public:
48  ejson::internal::Number::type getType() const {
49  return m_typeNumber;
50  }
51  public:
56  void set(double _value);
61  void set(int64_t _value);
66  void set(uint64_t _value);
71  double get() const;
76  uint64_t getU64() const;
81  int64_t getI64() const;
82  public:
83  bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override;
84  bool iGenerate(std::string& _data, size_t _indent) const override;
85  void iMachineGenerate(std::string& _data) const override;
88  };
89  }
90 }
91 
92 
bool transfertIn(ememory::SharedPtr< ejson::internal::Value > _obj) override
Tranfert all element in the element set in parameter.
double m_value
value of the node
Definition: Number.hpp:43
void iMachineGenerate(std::string &_data) const override
generate a string with the tree of the json (not human readable ==> for computer transfer) ...
the element "..."
bool iParse(const std::string &_data, size_t &_pos, ejson::FilePos &_filePos, ejson::internal::Document &_doc) override
parse the Current node [pure VIRUAL]
int64_t m_valueI64
value of the node
Definition: Number.hpp:45
ejson namespace containing all function for JSON interpretor
Definition: Array.hpp:12
Position in the file of the original data.
Definition: FilePos.hpp:14
int64_t getI64() const
Get the current element Value.
uint64_t m_valueU64
value of the node
Definition: Number.hpp:44
ejson Number internal data implementation.
Definition: Number.hpp:16
uint64_t getU64() const
Get the current element Value.
ejson Document internal data implementation.
Definition: Document.hpp:20
Number(uint64_t _value=0)
basic element of a xml structure
ememory::SharedPtr< ejson::internal::Value > clone() const override
Copy the curent node and all the child in the curent one.
static ememory::SharedPtr< Number > create(uint64_t _value=0)
Create factory on the ejson::internal::Number.
Basic main object of all json data.
Definition: Value.hpp:42
bool iGenerate(std::string &_data, size_t _indent) const override
generate a string with the tree of the json