Browse Source

Util: Add parse(std::ifstream) function

master
Riyyi 2 years ago
parent
commit
a92ac29d19
  1. 10
      src/util/json/value.cpp
  2. 1
      src/util/json/value.h

10
src/util/json/value.cpp

@ -157,6 +157,13 @@ Value Value::parse(const std::string& input)
return Job(input).fire();
}
Value Value::parse(std::ifstream& file)
{
Value value;
file >> value;
return value;
}
std::string Value::dump(const uint32_t indent, const char indentCharacter) const
{
Serializer serializer(indent, indentCharacter);
@ -313,8 +320,7 @@ std::istream& operator>>(std::istream& input, Value& value)
}
inputString.append(buffer, input.gcount());
Job job(inputString);
value = job.fire();
value = Job(inputString).fire();
return input;
}

1
src/util/json/value.h

@ -66,6 +66,7 @@ public:
// --------------------------------------
static Value parse(const std::string& input);
static Value parse(std::ifstream& file);
std::string dump(const uint32_t indent = 0, const char indentCharacter = ' ') const;
void clear();

Loading…
Cancel
Save