Browse Source

Util: Rename Stringify -> Serializer

master
Riyyi 3 years ago
parent
commit
c3d6af85ba
  1. 14
      src/util/json/serializer.cpp
  2. 12
      src/util/json/serializer.h
  3. 6
      src/util/json/value.cpp

14
src/util/json/stringify.cpp → src/util/json/serializer.cpp

@ -12,31 +12,31 @@
#include "util/json/array.h"
#include "util/json/lexer.h"
#include "util/json/object.h"
#include "util/json/stringify.h"
#include "util/json/serializer.h"
namespace Json {
Stringify::Stringify(const Value& value, const uint32_t indent, const char indentCharacter)
Serializer::Serializer(const Value& value, const uint32_t indent, const char indentCharacter)
: m_value(value)
, m_indent(indent)
, m_indentCharacter(indentCharacter)
{
}
Stringify::~Stringify()
Serializer::~Serializer()
{
}
// ------------------------------------------
std::string Stringify::dump()
std::string Serializer::dump()
{
return dumpHelper(m_value);
}
// ------------------------------------------
std::string Stringify::dumpHelper(const Value& value, const uint32_t indentLevel)
std::string Serializer::dumpHelper(const Value& value, const uint32_t indentLevel)
{
switch (value.type()) {
case Value::Type::Null:
@ -67,7 +67,7 @@ std::string Stringify::dumpHelper(const Value& value, const uint32_t indentLevel
return "";
}
std::string Stringify::dumpArray(const Value& value, const uint32_t indentLevel)
std::string Serializer::dumpArray(const Value& value, const uint32_t indentLevel)
{
std::string result;
@ -100,7 +100,7 @@ std::string Stringify::dumpArray(const Value& value, const uint32_t indentLevel)
return result;
}
std::string Stringify::dumpObject(const Value& value, const uint32_t indentLevel)
std::string Serializer::dumpObject(const Value& value, const uint32_t indentLevel)
{
std::string result;

12
src/util/json/stringify.h → src/util/json/serializer.h

@ -4,8 +4,8 @@
* SPDX-License-Identifier: MIT
*/
#ifndef JSON_STRINGIFY_H
#define JSON_STRINGIFY_H
#ifndef JSON_SERIALIZER_H
#define JSON_SERIALIZER_H
#include <cstdint> // uint32_t
#include <string>
@ -14,10 +14,10 @@
namespace Json {
class Stringify {
class Serializer {
public:
Stringify(const Value& value, const uint32_t indent = 0, const char indentCharacter = ' ');
virtual ~Stringify();
Serializer(const Value& value, const uint32_t indent = 0, const char indentCharacter = ' ');
virtual ~Serializer();
std::string dump();
@ -34,4 +34,4 @@ private:
} // namespace Json
#endif // JSON_STRINGIFY_H
#endif // JSON_SERIALIZER_H

6
src/util/json/value.cpp

@ -15,7 +15,7 @@
#include "util/json/array.h"
#include "util/json/job.h"
#include "util/json/object.h"
#include "util/json/stringify.h"
#include "util/json/serializer.h"
#include "util/json/value.h"
namespace Json {
@ -118,8 +118,8 @@ Value Value::parse(const std::string& input)
std::string Value::dump(const uint32_t indent, const char indentCharacter) const
{
Stringify stringify(*this, indent, indentCharacter);
return stringify.dump();
Serializer serializer(*this, indent, indentCharacter);
return serializer.dump();
}
void Value::emplace_back(Value value)

Loading…
Cancel
Save