30 #ifndef PT_JSON_DOCUMENT_H
31 #define PT_JSON_DOCUMENT_H
33 #include <Pt/Json/Api.h>
34 #include <Pt/SerializationInfo.h>
35 #include <Pt/String.h>
72 {
return _si->name(); }
102 return _si ? _si->isVoid() :
true;
123 return Element( _si->parent() );
134 if( it == _si->
end() )
172 Element operator[] (
const std::string& name)
const
174 return this->getMember(name);
181 return this->getMember(name);
228 _si->removeMember(name);
236 _si->removeMember(name);
243 if( ! _si || ! e._si )
246 _si->removeMember( *e._si );
263 _si = _si->sibling();
270 {
return _si != other._si; }
275 {
return _si == other._si; }
298 {
return _si->name(); }
302 template <
typename T>
316 return _si ? _si->isVoid() :
true;
367 return this->getMember(name);
374 return this->getMember(name);
391 _si = _si->sibling();
398 {
return _si != other._si; }
403 {
return _si == other._si; }
425 bool isEmpty()
const;
429 void load( std::basic_istream<Pt::Char>& is );
433 void save( std::basic_ostream<Pt::Char>& os )
const;
448 {
return root().
begin(); }
453 {
return root().
begin(); }
458 {
return root().
end(); }
463 {
return root().
end(); }
546 root().removeMember(name);
553 root().removeMember(name);
560 root().removeElement(e);
Element addMember(const char *name)
Adds a top level element.
Definition: Document.h:523
Element addElement()
Adds a top level element.
Definition: Document.h:537
const SerializationInfo * findMember(const std::string &name) const
Find a struct member.
Definition: SerializationInfo.h:508
Const forward iterator for child elements.
Definition: SerializationInfo.h:782
JSON Document reader.
Definition: DocumentReader.h:45
Element & operator*()
Allows using the element like an iterator.
Definition: Document.h:251
ConstElement begin() const
Begin of sub elements.
Definition: Document.h:321
Element addMember(const std::string &name)
Adds a top level element.
Definition: Document.h:530
void setNull()
Sets element to null.
Definition: Document.h:107
bool operator==(const ConstElement &other) const
Allows using the element like an iterator.
Definition: Document.h:402
Element getMember(const std::string &name)
Returns a top level element.
Definition: Document.h:467
Iterator end()
Returns an iterator to the end of child elements.
Definition: SerializationInfo.h:826
SerializationInfo & addElement()
Add a sequence element.
void removeMember(const std::string &name)
Removes a top level element.
Definition: Document.h:551
SerializationInfo & addMember(const std::string &name)
Add a struct member.
Definition: SerializationInfo.h:449
Element * operator->()
Allows using the element like an iterator.
Definition: Document.h:256
Element parent() const
Returns the parent element.
Definition: Document.h:118
ConstElement end() const
End of elements.
Definition: Document.h:462
void removeMember(const char *name)
Removes a sub element.
Definition: Document.h:233
bool operator==(const Element &other) const
Allows using the element like an iterator.
Definition: Document.h:274
bool operator!=(const ConstElement &other) const
Allows using the element like an iterator.
Definition: Document.h:397
ConstElement getMember(const std::string &name) const
Returns a sub element.
Definition: Document.h:343
Constant document element.
Definition: Document.h:288
const ConstElement * operator->() const
Allows using the element like an iterator.
Definition: Document.h:384
Element end() const
End of sub elements.
Definition: Document.h:143
ConstElement & operator++()
Allows using the element like an iterator.
Definition: Document.h:389
Element & operator++()
Allows using the element like an iterator.
Definition: Document.h:261
void removeMember(const char *name)
Removes a top level element.
Definition: Document.h:544
const char * name() const
Returns the element name.
Definition: Document.h:71
ConstElement root() const
Returns the root element.
Definition: Document.h:442
bool operator!() const
Returns true if element is invalid.
Definition: Document.h:279
void removeElement(const Element &e)
Removes a sub element.
Definition: Document.h:241
ConstElement end() const
End of sub elements.
Definition: Document.h:336
ConstElement getMember(const char *name) const
Returns a sub element.
Definition: Document.h:354
ConstElement getMember(const char *name) const
Returns a top level element.
Definition: Document.h:488
const char * name() const
Returns the element name.
Definition: Document.h:297
void setValue(const T &value)
Sets the value.
Definition: Document.h:89
bool operator!() const
Returns true if element is invalid.
Definition: Document.h:407
Element getMember(const std::string &name) const
Returns a sub element.
Definition: Document.h:150
void removeElement(const Element &e)
Removes a top level element.
Definition: Document.h:558
bool isNull() const
Returns true if element is null.
Definition: Document.h:100
void removeMember(const std::string &name)
Removes a sub element.
Definition: Document.h:225
ConstElement begin() const
Begin of elements.
Definition: Document.h:452
Modifiable document element.
Definition: Document.h:52
bool getValue(T &value) const
Gets the value.
Definition: Document.h:77
Represents arbitrary types during serialization.
Definition: SerializationInfo.h:58
Iterator begin()
Returns an iterator to the begin of child elements.
Element root()
Returns the root element.
Definition: Document.h:437
bool getValue(T &value) const
Gets the value.
Definition: Document.h:303
Element addElement()
Adds a sub element.
Definition: Document.h:214
bool operator!=(const Element &other) const
Allows using the element like an iterator.
Definition: Document.h:269
JSON Document.
Definition: Document.h:45
Forward Iterator for child elements.
Definition: SerializationInfo.h:737
Element addMember(const char *name)
Adds a sub element.
Definition: Document.h:186
bool isNull() const
Returns true if element is null.
Definition: Document.h:314
Element getMember(const char *name)
Returns a top level element.
Definition: Document.h:481
const ConstElement & operator*() const
Allows using the element like an iterator.
Definition: Document.h:379
Element end()
End of elements.
Definition: Document.h:457
Element getMember(const char *name) const
Returns a sub element.
Definition: Document.h:161
ConstElement getMember(const std::string &name) const
Returns a top level element.
Definition: Document.h:474
Element addMember(const std::string &name)
Adds a sub element.
Definition: Document.h:200
Element begin()
Begin of elements.
Definition: Document.h:447
Element begin() const
Begin of sub elements.
Definition: Document.h:128