JsonValue.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "JsonValue.h"
  2. #include "JsonArray.h"
  3. #include "JsonObject.h"
  4. #include "Internals/JsonNode.h"
  5. void JsonValue::operator=(bool value)
  6. {
  7. if (_node)
  8. _node->setAsBoolean(value);
  9. }
  10. void JsonValue::operator=(char const* value)
  11. {
  12. if (_node)
  13. _node->setAsString(value);
  14. }
  15. void JsonValue::set(double value, int decimals)
  16. {
  17. if (_node)
  18. _node->setAsDouble(value, decimals);
  19. }
  20. void JsonValue::operator=(int value)
  21. {
  22. if (_node)
  23. _node->setAsLong(value);
  24. }
  25. JsonValue::operator bool() const
  26. {
  27. return _node ? _node->getAsBoolean() : false;
  28. }
  29. JsonValue::operator char const*() const
  30. {
  31. return _node ? _node->getAsString() : 0;
  32. }
  33. JsonValue::operator double() const
  34. {
  35. return _node ? _node->getAsDouble() : 0;
  36. }
  37. JsonValue::operator long() const
  38. {
  39. return _node ? _node->getAsInteger() : 0;
  40. }
  41. JsonValue::operator JsonArray() const
  42. {
  43. return JsonArray(_node);
  44. }
  45. JsonValue::operator JsonObject() const
  46. {
  47. return JsonObject(_node);
  48. }