jsonObject.cpp 687 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "jsonObject.hh"
  2. #include "jsonPrimitive.hh"
  3. JSonObject::JSonObject(JSonContainer *p): JSonContainer(p)
  4. { }
  5. JSonObject::~JSonObject()
  6. {
  7. for (iterator i = begin(); i != end(); ++i)
  8. {
  9. delete (*i).second;
  10. }
  11. }
  12. void JSonObject::push(const std::string &key, JSonElement *child)
  13. {
  14. (*this)[key] = child;
  15. }
  16. bool JSonObject::contains(const std::string &key) const
  17. {
  18. return find(key) != end();
  19. }
  20. const JSonElement *JSonObject::get(const std::string &key) const
  21. {
  22. const_iterator item = find(key);
  23. return item == cend() ? nullptr : (*item).second;
  24. }
  25. unsigned int JSonObject::size() const
  26. {
  27. return std::map<std::string, JSonElement *>::size();
  28. }