JsonValue.cpp 649 B

123456789101112131415161718192021222324252627282930313233
  1. #include "JsonObject.h"
  2. #include "JsonNode.h"
  3. #include "JsonValue.h"
  4. void JsonValue::operator=(double value)
  5. {
  6. if (!_node) return;
  7. _node->type = JSON_DOUBLE_2_DECIMALS;
  8. _node->content.asDouble = value;
  9. }
  10. void JsonValue::operator=(int value)
  11. {
  12. if (!_node) return;
  13. _node->type = JSON_INTEGER;
  14. _node->content.asInteger = value;
  15. }
  16. JsonValue::operator double()
  17. {
  18. if (!_node || _node->type < JSON_DOUBLE_0_DECIMALS) return 0;
  19. return _node->content.asDouble;
  20. }
  21. JsonValue::operator int()
  22. {
  23. if (!_node || _node->type != JSON_INTEGER) return 0;
  24. return _node->content.asInteger;
  25. }