JSONParser.h 753 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <cstdarg>
  3. #include "Types.h"
  4. #include "List.h"
  5. #include "HeapAllocator.h"
  6. #include "JSON.h"
  7. namespace crown
  8. {
  9. class JSONParser
  10. {
  11. public:
  12. /// Constructor
  13. JSONParser(Allocator& allocator, const char* s);
  14. /// Get root element
  15. JSONParser& root();
  16. /// Get object @a key
  17. JSONParser& object(const char* key);
  18. /// Get array @a key and element @a index
  19. JSONParser& array(const char* key, uint32_t index);
  20. /// Get string @a key
  21. JSONParser& string(const char* key);
  22. /// Get number @a key
  23. JSONParser& number(const char* key);
  24. /// Get boolean @a key
  25. JSONParser& boolean(const char* key);
  26. private:
  27. /// JSONParser allocator
  28. HeapAllocator& m_allocator;
  29. List<JSONNode> m_nodes;
  30. };
  31. } // namespace crown