Browse Source

Util: Rename Stringify -> Serializer

master
Riyyi 2 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/array.h"
#include "util/json/lexer.h" #include "util/json/lexer.h"
#include "util/json/object.h" #include "util/json/object.h"
#include "util/json/stringify.h" #include "util/json/serializer.h"
namespace Json { 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_value(value)
, m_indent(indent) , m_indent(indent)
, m_indentCharacter(indentCharacter) , m_indentCharacter(indentCharacter)
{ {
} }
Stringify::~Stringify() Serializer::~Serializer()
{ {
} }
// ------------------------------------------ // ------------------------------------------
std::string Stringify::dump() std::string Serializer::dump()
{ {
return dumpHelper(m_value); 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()) { switch (value.type()) {
case Value::Type::Null: case Value::Type::Null:
@ -67,7 +67,7 @@ std::string Stringify::dumpHelper(const Value& value, const uint32_t indentLevel
return ""; 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; std::string result;
@ -100,7 +100,7 @@ std::string Stringify::dumpArray(const Value& value, const uint32_t indentLevel)
return result; 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; std::string result;

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

@ -4,8 +4,8 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#ifndef JSON_STRINGIFY_H #ifndef JSON_SERIALIZER_H
#define JSON_STRINGIFY_H #define JSON_SERIALIZER_H
#include <cstdint> // uint32_t #include <cstdint> // uint32_t
#include <string> #include <string>
@ -14,10 +14,10 @@
namespace Json { namespace Json {
class Stringify { class Serializer {
public: public:
Stringify(const Value& value, const uint32_t indent = 0, const char indentCharacter = ' '); Serializer(const Value& value, const uint32_t indent = 0, const char indentCharacter = ' ');
virtual ~Stringify(); virtual ~Serializer();
std::string dump(); std::string dump();
@ -34,4 +34,4 @@ private:
} // namespace Json } // 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/array.h"
#include "util/json/job.h" #include "util/json/job.h"
#include "util/json/object.h" #include "util/json/object.h"
#include "util/json/stringify.h" #include "util/json/serializer.h"
#include "util/json/value.h" #include "util/json/value.h"
namespace Json { 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 std::string Value::dump(const uint32_t indent, const char indentCharacter) const
{ {
Stringify stringify(*this, indent, indentCharacter); Serializer serializer(*this, indent, indentCharacter);
return stringify.dump(); return serializer.dump();
} }
void Value::emplace_back(Value value) void Value::emplace_back(Value value)

Loading…
Cancel
Save