72 bool HasAttr(
const char* attr)
const;
84 bool GetBool(
const char* attr = 0)
const;
86 int GetInt(
const char* attr = 0)
const;
90 float GetFloat(
const char* attr = 0)
const;
102 template<
typename T>
void Get(T& target,
const char* attr = 0);
109 bool GetOptBool(
const char* attr,
bool defaultValue)
const;
111 int GetOptInt(
const char* attr,
int defaultValue)
const;
113 float GetOptFloat(
const char* attr,
float defaultValue)
const;
124 template<
typename T>
bool GetOpt(T& target,
const char* attr = 0);
126 template<
typename T>
bool GetOpt(T& target,
const char* attr,
const T& _default);
130 const pjson::value_variant*
GetChild(
const char * key = 0)
const;
149template<>
void JsonReader::Get<Math::mat4>(
Math::mat4& ret,
const char* attr);
150template<>
void JsonReader::Get<Math::int2>(
Math::int2& ret,
const char* attr);
151template<>
void JsonReader::Get<Math::vector>(
Math::vector& ret,
const char* attr);
152template<>
void JsonReader::Get<Math::vec4>(
Math::vec4& ret,
const char* attr);
153template<>
void JsonReader::Get<Math::vec3>(
Math::vec3& ret,
const char* attr);
154template<>
void JsonReader::Get<Math::vec2>(
Math::vec2& ret,
const char* attr);
159template<>
void JsonReader::Get<Util::Variant>(
Util::Variant& ret,
const char* attr);
160template<>
void JsonReader::Get<Util::String>(
Util::String& ret,
const char* attr);
161template<>
void JsonReader::Get<Util::FourCC>(
Util::FourCC& ret,
const char* attr);
162template<>
void JsonReader::Get<Util::StringAtom>(
Util::StringAtom& ret,
const char* attr);
170template<>
bool JsonReader::GetOpt<Math::vec4>(
Math::vec4& ret,
const char* attr);
171template<>
bool JsonReader::GetOpt<Math::quat>(
Math::quat& ret,
const char* attr);
172template<>
bool JsonReader::GetOpt<Math::mat4>(
Math::mat4& ret,
const char* attr);
173template<>
bool JsonReader::GetOpt<Util::String>(
Util::String& ret,
const char* attr);
188 this->
Get(target, attr);
212template<
unsigned int N>
219 unsigned int count = arr.
Size();
221 for (
unsigned int i = 0; i < count; i++)
Reads json formatted data with random access from a stream using pjson as backend.
Definition jsonreader.h:32
bool GetOptBool(const char *attr, bool defaultValue) const
get optional bool attribute value from current node
Definition jsonreader.cc:661
float GetFloat(const char *attr=0) const
get float attribute value from current node
Definition jsonreader.cc:525
bool SetToParent()
set current node to parent, return false if no parent exists
Definition jsonreader.cc:292
bool IsArray() const
check if current node is an array
Definition jsonreader.cc:331
Util::Stack< const pjson::value_variant * > parents
Definition jsonreader.h:135
virtual void Close()
end reading from the stream
Definition jsonreader.cc:92
Util::String GetCurrentNodeName() const
get name of current node
Definition jsonreader.cc:414
Math::vec4 GetVec4(const char *attr=0) const
get vec4 attribute value from current node
Definition jsonreader.cc:576
__DeclareClass(JsonReader)
bool GetOpt(T &target, const char *attr=0)
generic getter for optional items
Definition jsonreader.h:184
pjson::document * document
Definition jsonreader.h:132
bool SetToFirstChild(const Util::String &name="")
set current node to first child, false if none exists
Definition jsonreader.cc:226
bool SetToNode(const Util::String &path)
set current node as path, accepts / as separator and [number] to access array/object elements
Definition jsonreader.cc:169
JsonReader()
constructor
Definition jsonreader.cc:29
virtual bool Open()
begin reading from the stream
Definition jsonreader.cc:53
Math::vec4 GetOptVec4(const char *attr, const Math::vec4 &defaultValue) const
get optional vec4 attribute value from current node
Definition jsonreader.cc:733
float GetOptFloat(const char *attr, float defaultValue) const
get optional float attribute value from current node
Definition jsonreader.cc:697
void SetToRoot()
sets the current node to root
Definition jsonreader.cc:152
bool HasNode(const Util::String &path)
return true if node exists
Definition jsonreader.cc:110
int GetInt(const char *attr=0) const
get int attribute value from current node
Definition jsonreader.cc:495
Math::transform44 GetTransform44(const char *attr=0) const
get transform44 attribute value from current node
Definition jsonreader.cc:620
bool HasChildren() const
check if current node has children (json object or array)
Definition jsonreader.cc:355
virtual ~JsonReader()
destructor
Definition jsonreader.cc:39
Util::Array< Util::String > GetAttrs() const
return names of all attrs on current node
Definition jsonreader.cc:397
int GetOptInt(const char *attr, int defaultValue) const
get optional int attribute value from current node
Definition jsonreader.cc:679
Math::transform44 GetOptTransform44(const char *attr, const Math::transform44 &defaultValue) const
get transform44 attribute value from current node
Definition jsonreader.cc:769
Math::vec2 GetVec2(const char *attr=0) const
get vec2 attribute value from current node
Definition jsonreader.cc:541
Util::String GetOptString(const char *attr, const Util::String &defaultValue) const
get optional string attribute value from current node
Definition jsonreader.cc:643
Math::vec2 GetOptVec2(const char *attr, const Math::vec2 &defaultValue) const
get vec2 attribute value from current node
Definition jsonreader.cc:715
Util::Stack< IndexT > parentIdx
Definition jsonreader.h:136
void Get(T &target, const char *attr=0)
generic getter for extension types
Util::String GetString(const char *attr=0) const
get string attribute value from current node
Definition jsonreader.cc:450
uint GetUInt(const char *attr=0) const
get unsigned int attribute value from current node
Definition jsonreader.cc:510
const pjson::value_variant * GetChild(const char *key=0) const
Definition jsonreader.cc:428
bool SetToNextChild()
set to next child, false if none exists
Definition jsonreader.cc:265
Math::vec3 GetVec3(const char *attr=0) const
get vec4 attribute value from current node
Definition jsonreader.cc:554
Util::String GetChildNodeName(SizeT childIndex)
gets the childname of the child at index, or empty string if no child exists or has no name.
Definition jsonreader.cc:312
bool HasAttr(const char *attr) const
return true if matching attribute exists on current node
Definition jsonreader.cc:383
const pjson::value_variant * curNode
Definition jsonreader.h:133
SizeT CurrentSize() const
children count
Definition jsonreader.cc:367
Math::mat4 GetMat4(const char *attr=0) const
get mat4 attribute value from current node
Definition jsonreader.cc:598
bool IsObject() const
check if current node is an object (can have keys)
Definition jsonreader.cc:344
Util::StringAtom GetStringAtom(const char *attr=0) const
get stringatom attribute value from current node
Definition jsonreader.cc:465
Math::mat4 GetOptMat4(const char *attr, const Math::mat4 &defaultValue) const
get optional mat4 attribute value from current node
Definition jsonreader.cc:751
IndexT childIdx
Definition jsonreader.h:134
char * buffer
Definition jsonreader.h:138
bool GetBool(const char *attr=0) const
get bool attribute value from current node
Definition jsonreader.cc:480
Stream reader classes provide a specialized read-interface for a stream.
Definition streamreader.h:24
Nebula's dynamic array class.
Definition array.h:60
const SizeT Size() const
get number of elements in array
Definition array.h:880
Implements large bit field.
Definition bitfield.h:24
constexpr void SetBit(const uint64_t bitIndex)
set a bit by index
Definition bitfield.h:215
A four-character-code is a quasi-human-readable 32-bit-id.
Definition fourcc.h:19
Nebula's stack class (a FILO container).
Definition stack.h:19
A StringAtom.
Definition stringatom.h:22
An "any type" variable.
Definition variant.h:31
#define n_assert(exp)
Definition debug.h:50
Instances of wrapped stream classes.
Definition orientation.cc:10
Definition jsonreader.h:24
A 4x4 single point precision float matrix.
Definition mat4.h:49
A quaternion is usually used to represent an orientation in 3D space.
Definition quat.h:30
A 2-component float vector class.
Definition vec2.h:21
A 3D vector.
Definition vec3.h:40
A 4D vector.
Definition vec4.h:24
A vector is a 3D direction in space.
Definition vector.h:22
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48