34#include <NDEVR/Scanner.h>
35#include <NDEVR/String.h>
36#include <NDEVR/Buffer.h>
37#include <NDEVR/Dictionary.h>
38#include <NDEVR/Time.h>
45 class TranslatedString;
46 template<
class t_type>
52 return value.
getAs<t_type>();
55 template<
class t_type>
90 return Time(value,
false,
"YYYY/MM/DDTHH:mm:ss.fffZ");
92 return Time(value,
false,
"YYYY/MM/DDTHH:mm:ss");
94 if (!
isNaN(sub_value))
122 static const uint04 s_number_of_decimals = 10;
215 NodeType type()
const;
229 void write(
String& stream)
const;
243 void write(
File& file);
245 void write(std::ostream& file);
261 void writePretty(
String& stream,
const uint04 tab_indention = 0)
const;
274 void writePretty(
File& file);
275 void writePretty(std::ostream& file);
285 template<
class t_type>
305 return *m_json_children[child_node];
338 return m_sorted_json_children;
342 return m_json_children.hasKey(child_node);
350 void remove(
const String& child_node);
351 JSONNode& createChildNode(
const String& child_node, NodeType type);
365 if (node.
m_type == e_root)
369 for (
const auto& iter : m_sorted_json_children)
373 m_sorted_json_children.clear();
374 m_json_children.clear();
377 m_sorted_json_children.add(
new JSONNode(*iter));
378 if (!m_json_children.hasKey(iter->nodeName()))
379 m_json_children.add(iter->nodeName(), m_sorted_json_children.last());
391 template<
class t_type>
395 m_value =
String(value.template as<DEGREES>());
411 m_value = time.
toString(
false,
"YYYY/MM/DDTHH:mm:ss.fffZ");;
415 template<
class t_type,
class t_allocator>
423 template<u
int01 t_dims,
class t_type>
442 return m_value.size() == 0 && m_json_children.size() == 0;
454 template<
class t_type>
482 return cast<uint04>(m_json_children.size());
485 [[nodiscard]]
decltype(
auto)
begin()
487 return m_json_children.begin();
489 [[nodiscard]]
decltype(
auto)
begin()
const
491 return m_json_children.begin();
494 [[nodiscard]]
decltype(
auto)
end()
496 return m_json_children.end();
498 [[nodiscard]]
decltype(
auto)
end()
const
500 return m_json_children.end();
521 bool parseJSONContent(
char start,
Scanner& scan);
554 void readChildrenNodes(
Scanner& scan);
599 static void WriteTabs(
String& stream,
uint04 tab_indention);
600 static void ConvertToJSONString(
String&
string);
601 static void ConvertFromJSONString(
String&
string);
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Stores an angle in an optimized format.
Definition StringStream.h:352
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
bool contains(const t_type &element) const
Definition Buffer.hpp:674
Definition Dictionary.h:48
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:121
Buffer< JSONNode * > m_sorted_json_children
Definition JSONParser.h:607
JSONNode & operator=(const t_type &value)
Definition JSONParser.h:455
JSONNode & operator=(const String &value)
Definition JSONParser.h:385
JSONNode & operator=(const Buffer< t_type, t_allocator > &buffer)
Definition JSONParser.h:416
Dictionary< String, JSONNode * > m_json_children
Definition JSONParser.h:608
const String m_name
Definition JSONParser.h:609
JSONNode & operator=(const Time &time)
Definition JSONParser.h:408
decltype(auto) end()
Definition JSONParser.h:494
JSONNode & operator=(const JSONNode &node)
Definition JSONParser.h:362
String m_value
Definition JSONParser.h:610
decltype(auto) getAs() const
Definition JSONParser.h:286
uint04 size()
Definition JSONParser.h:480
JSONNode & operator=(const Vector< t_dims, t_type > &buffer)
Definition JSONParser.h:424
bool hasNode(const String &child_node) const
Definition JSONParser.h:340
decltype(auto) begin()
Definition JSONParser.h:485
const String & nodeName() const
Definition JSONParser.h:345
const JSONNode & get(const String &child_node) const
Definition JSONParser.h:303
NodeType
Definition JSONParser.h:125
decltype(auto) begin() const
Definition JSONParser.h:489
bool isEmpty() const
Definition JSONParser.h:440
JSONNode & operator=(const Angle< t_type > &value)
Definition JSONParser.h:392
NodeType m_type
Definition JSONParser.h:611
decltype(auto) end() const
Definition JSONParser.h:498
const Buffer< JSONNode * > & children() const
Definition JSONParser.h:336
static Angle< t_type > Convert(const String &value)
Definition JSONParser.h:59
static const String & Convert(const String &value)
Definition JSONParser.h:68
static Time Convert(const String &value)
Template specialization for time, as the format for time in JSON is not entirely specified,...
Definition JSONParser.h:85
Definition JSONParser.h:48
static t_type Convert(const String &value)
Definition JSONParser.h:50
NDEVR_BASE_API String substr(uint04 start) const
Definition String.cpp:551
t_type getAs() const
Definition String.h:334
NDEVR_BASE_API uint04 indexOf(const String &sub_string, bool ignore_case=false, uint04 start_index=0) const
Definition String.cpp:208
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
static constexpr uint08 SECOND
Definition Time.h:84
NDEVR_BASE_API String toString(bool get_local_time, const String &format_string) const
Converts the timestamp to a string representation. https://ndevr.org/time-patterns/.
Definition Time.cpp:115
Definition TranslatedString.h:9
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
@ DEGREES
Definition Angle.h:66
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Information about the object.
Definition ObjectInfo.h:56