API Documentation
Node.h
1 // Node.h
3 //
5 
6 namespace nkExport
7 {
11  enum class NODE_VALUE_TYPE
12  {
14  BOOL_TYPE,
15  STRING_TYPE,
16  INT_TYPE,
17  UINT_TYPE,
18  LONG_TYPE,
19  ULONG_TYPE,
20  FLOAT_TYPE,
22  } ;
23 
27  enum class NODE_NATURE
28  {
29  EMPTY_NATURE = 0,
30  VALUE_NATURE,
33  } ;
34 }
35 
36 namespace nkExport
37 {
41  class Node final
42  {
43  public :
44 
45  // Getters
46  // Globals
55  // Utils
59  bool isValueTypeNumber () const ;
72  // Value
84  int getValueAsInt () const ;
90  unsigned int getValueAsUint () const ;
96  long long getValueAsLong () const ;
102  unsigned long long getValueAsUlong () const ;
108  float getValueAsFloat () const ;
114  double getValueAsDouble () const ;
120  bool getValueAsBool () const ;
121  // Object
125  unsigned int getMemberCount () const ;
133  nkMemory::StringView getMemberKey (unsigned int index) const ;
140  Node* getMemberValue (unsigned int index) const ;
179  unsigned int getArraySize () const ;
184  Node* getArrayElement (unsigned int index) const ;
190  Node* getArrayElement (unsigned int index, NODE_VALUE_TYPE valueType) const ;
196  Node* getArrayElement (unsigned int index, NODE_NATURE nodeNature) const ;
200  void* getUserData () const ;
201 
202  // Setters
214  void setAsInt (int value) ;
220  void setAsUint (unsigned int value) ;
226  void setAsLong (long long value) ;
232  void setAsUlong (unsigned long long value) ;
238  void setAsFloat (float value) ;
244  void setAsDouble (double value) ;
250  void setAsBool (bool value) ;
282  void setUserData (void* value) ;
283 
284  // Operators
290  Node& operator= (const Node&) noexcept ;
296  Node& operator= (Node&&) noexcept ;
297 
298  public :
299 
300  // Statics
306  static nkMemory::UniquePtr<Node> create () noexcept ;
313  static nkMemory::UniquePtr<Node> create (const Node& other) noexcept ;
320  static nkMemory::UniquePtr<Node> create (Node&& other) noexcept ;
321  } ;
322 }
nkExport::Node::getArrayElement
Node * getArrayElement(unsigned int index, NODE_NATURE nodeNature) const
nkExport::NODE_VALUE_TYPE::NOT_VALUE_TYPE
@ NOT_VALUE_TYPE
A node which is an object or an array will have no value attached. In such case, this value is return...
nkExport::NODE_VALUE_TYPE::FLOAT_TYPE
@ FLOAT_TYPE
A node holding a float.
nkExport::Node::getValueAsUint
unsigned int getValueAsUint() const
nkExport::Node::getArrayElement
Node * getArrayElement(unsigned int index) const
nkExport::Node::getMemberValue
Node * getMemberValue(unsigned int index) const
nkExport::Node::getMemberValue
Node * getMemberValue(nkMemory::StringView key, NODE_VALUE_TYPE valueType) const
nkExport::Node::hasChild
bool hasChild(nkMemory::StringView key, NODE_NATURE nature)
nkExport::Node::setAsFloat
void setAsFloat(float value)
nkExport::NODE_VALUE_TYPE::DOUBLE_TYPE
@ DOUBLE_TYPE
A node holding a double.
nkExport::Node::create
static nkMemory::UniquePtr< Node > create() noexcept
nkExport::Node::operator=
Node & operator=(const Node &) noexcept
nkExport::Node::setAsBool
void setAsBool(bool value)
nkExport::Node::getMemberValue
Node * getMemberValue(nkMemory::StringView key) const
nkExport::NODE_VALUE_TYPE::ULONG_TYPE
@ ULONG_TYPE
A node holding an unsigned long (8 bytes).
nkExport::Node::getValueAsFloat
float getValueAsFloat() const
nkExport::NODE_NATURE::OBJECT_NATURE
@ OBJECT_NATURE
Represents a node holding references to other nodes, via the named member accessors.
nkExport::Node::setAsUint
void setAsUint(unsigned int value)
nkExport
Encompasses all API of component NilkinsExport.
Definition: Base64Encoder.h:7
nkExport::Node::addElement
Node * addElement()
nkExport::NODE_NATURE::EMPTY_NATURE
@ EMPTY_NATURE
Represents an empty node.
nkExport::Node::isValueTypeNumber
bool isValueTypeNumber() const
nkExport::Node::getMemberCount
unsigned int getMemberCount() const
nkExport::Node::getValueAsBool
bool getValueAsBool() const
nkExport::Node::getValueAsDouble
double getValueAsDouble() const
nkExport::Node::getUserData
void * getUserData() const
nkExport::Node::getArrayElement
Node * getArrayElement(unsigned int index, NODE_VALUE_TYPE valueType) const
nkExport::NODE_VALUE_TYPE::UINT_TYPE
@ UINT_TYPE
A node holding an unsigned integer.
nkExport::Node::setAsLong
void setAsLong(long long value)
nkExport::Node::setAsString
void setAsString(nkMemory::StringView value)
nkExport::Node::getMemberKey
nkMemory::StringView getMemberKey(unsigned int index) const
nkExport::NODE_VALUE_TYPE
NODE_VALUE_TYPE
Describes the kind of value a node holds.
Definition: Node.h:12
nkExport::Node
A node in the tree structure representing the data to export / import.
Definition: Node.h:42
nkExport::Node::getValueAsLong
long long getValueAsLong() const
nkExport::Node::getNodeNature
NODE_NATURE getNodeNature() const
nkExport::NODE_NATURE::ARRAY_NATURE
@ ARRAY_NATURE
Represents a node holding references to other nodes, via the indexed array accessors.
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkExport::Node::hasChild
bool hasChild(nkMemory::StringView key, NODE_VALUE_TYPE valueType)
nkExport::Node::getValueAsString
nkMemory::StringView getValueAsString() const
nkExport::Node::getValueAsUlong
unsigned long long getValueAsUlong() const
nkExport::Node::setAsDouble
void setAsDouble(double value)
nkExport::NODE_VALUE_TYPE::INT_TYPE
@ INT_TYPE
A node holding an integer.
nkExport::NODE_NATURE
NODE_NATURE
Describes the nature of a node.
Definition: Node.h:28
nkExport::Node::setAsInt
void setAsInt(int value)
nkExport::Node::getNodeValueType
NODE_VALUE_TYPE getNodeValueType() const
nkExport::Node::getMemberValue
Node * getMemberValue(nkMemory::StringView key, NODE_NATURE nodeNature) const
nkExport::Node::addMember
Node * addMember(nkMemory::StringView key)
nkExport::NODE_VALUE_TYPE::LONG_TYPE
@ LONG_TYPE
A node holding a long (8 bytes).
nkExport::Node::deleteMember
void deleteMember(nkMemory::StringView key)
nkExport::NODE_NATURE::VALUE_NATURE
@ VALUE_NATURE
Represents a leaf node, holding a final value being either a bool, string, int, uint,...
nkExport::Node::getValueAsInt
int getValueAsInt() const
nkExport::NODE_VALUE_TYPE::STRING_TYPE
@ STRING_TYPE
A node holding a string.
nkExport::Node::setAsUlong
void setAsUlong(unsigned long long value)
nkExport::Node::setUserData
void setUserData(void *value)
nkExport::Node::getArraySize
unsigned int getArraySize() const
nkExport::NODE_VALUE_TYPE::BOOL_TYPE
@ BOOL_TYPE
A node holding a boolean.
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7