1
1

jsonObject.hh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * jsonObject.hh for jsonstroller
  3. *
  4. * Author: isundil <isundill@gmail.com>
  5. **/
  6. #pragma once
  7. #include "config.h"
  8. #include "jsonContainer.hh"
  9. #include "jsonObjectEntry.hh"
  10. #include "jsonException.hh"
  11. class JSonObject: public JSonContainer
  12. {
  13. public:
  14. JSonObject(JSonContainer *parent);
  15. virtual ~JSonObject();
  16. /**
  17. * Add entry
  18. **/
  19. virtual void push(const std::string &key, JSonElement *child);
  20. /**
  21. * find object by key
  22. **/
  23. JSonObject::const_iterator find(const std::string &key) const;
  24. /**
  25. * remove object by key
  26. **/
  27. bool erase(const std::string &);
  28. /**
  29. * check if object exists
  30. **/
  31. bool contains(const std::string &) const;
  32. /**
  33. * fetch object by key
  34. **/
  35. const JSonElement* get(const std::string &) const;
  36. virtual JSonElement *firstChild();
  37. virtual const JSonElement *firstChild() const;
  38. virtual std::string stringify() const;
  39. /**
  40. * multiple objects exists for this key
  41. **/
  42. class DoubleKeyException: public JsonException
  43. {
  44. public:
  45. DoubleKeyException(unsigned long long offset, const std::string &key, LinearHistory &buf);
  46. };
  47. /**
  48. * Invalid value for key
  49. **/
  50. class NotAKeyException: public JsonException
  51. {
  52. public:
  53. NotAKeyException(unsigned long long offset, LinearHistory &buf);
  54. };
  55. };
  56. class JSonSortedObject: public JSonObject
  57. {
  58. public:
  59. JSonSortedObject(JSonContainer *parent);
  60. void push(const std::string &key, JSonElement *child);
  61. };