Util+Test: Change namespace of JSON classes: Json -> Util::JSON
This commit is contained in:
+6
-6
@@ -13,7 +13,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "config.h"
|
||||
#include "util/json/value.h"
|
||||
#include "util/json/json.h"
|
||||
|
||||
Config::Config(s)
|
||||
: m_workingDirectory(std::filesystem::current_path())
|
||||
@@ -51,7 +51,7 @@ void Config::parseConfigFile()
|
||||
return;
|
||||
}
|
||||
|
||||
Json::Value json;
|
||||
Util::Json json;
|
||||
|
||||
std::ifstream file(m_config);
|
||||
if (!file.is_open()) {
|
||||
@@ -72,17 +72,17 @@ void Config::parseConfigFile()
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
void toJson(Json::Value& json, const Settings& settings)
|
||||
void toJson(Util::Json& json, const Settings& settings)
|
||||
{
|
||||
json = Json::Value {
|
||||
json = Util::Json {
|
||||
{ "ignorePatterns", settings.ignorePatterns },
|
||||
{ "systemPatterns", settings.systemPatterns }
|
||||
};
|
||||
}
|
||||
|
||||
void fromJson(const Json::Value& json, Settings& settings)
|
||||
void fromJson(const Util::Json& json, Settings& settings)
|
||||
{
|
||||
assert(json.type() == Json::Value::Type::Object);
|
||||
assert(json.type() == Util::Json::Type::Object);
|
||||
|
||||
if (json.exists("ignorePatterns")) {
|
||||
json.at("ignorePatterns").getTo(settings.ignorePatterns);
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "util/singleton.h"
|
||||
#include "util/json/value.h"
|
||||
#include "util/json/json.h"
|
||||
|
||||
struct Settings {
|
||||
std::vector<std::string> ignorePatterns {
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
|
||||
// Json arbitrary type conversion functions
|
||||
|
||||
void toJson(Json::Value& object, const Settings& settings);
|
||||
void fromJson(const Json::Value& object, Settings& settings);
|
||||
void toJson(Util::Json& object, const Settings& settings);
|
||||
void fromJson(const Util::Json& object, Settings& settings);
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "util/json/array.h"
|
||||
#include "util/json/value.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
void Array::emplace_back(Value element)
|
||||
{
|
||||
@@ -23,4 +23,4 @@ Value& Array::operator[](size_t index)
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_ARRAY_H
|
||||
#define JSON_ARRAY_H
|
||||
#ifndef UTIL_JSON_ARRAY_H
|
||||
#define UTIL_JSON_ARRAY_H
|
||||
|
||||
#include <utility> // move
|
||||
#include <vector>
|
||||
|
||||
#include "util/json/parser.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Value;
|
||||
|
||||
@@ -54,6 +54,6 @@ private:
|
||||
std::vector<Value> m_elements;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_ARRAY_H
|
||||
#endif // UTIL_JSON_ARRAY_H
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_FROM_JSON_H
|
||||
#define JSON_FROM_JSON_H
|
||||
#ifndef UTIL_JSON_FROM_JSON_H
|
||||
#define UTIL_JSON_FROM_JSON_H
|
||||
|
||||
#include <algorithm> // transform
|
||||
#include <cassert> // assert
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "util/json/object.h"
|
||||
#include "util/meta/odr.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
namespace Detail {
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace {
|
||||
constexpr const auto& fromJson = Util::Detail::staticConst<Detail::fromJsonFunction>; // NOLINT(misc-definitions-in-headers,clang-diagnostic-unused-variable)
|
||||
} // namespace
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_FROM_JSON_H
|
||||
#endif // UTIL_JSON_FROM_JSON_H
|
||||
|
||||
// Customization Points
|
||||
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "util/json/parser.h"
|
||||
#include "util/json/value.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
Job::Job(std::string_view input)
|
||||
: m_input(input)
|
||||
@@ -111,4 +111,4 @@ void Job::printErrorLine(Token token, const char* message)
|
||||
std::string(line.length() - token.column, '~').c_str());
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_JOB_H
|
||||
#define JSON_JOB_H
|
||||
#ifndef UTIL_JSON_JOB_H
|
||||
#define UTIL_JSON_JOB_H
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <string_view>
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "util/json/lexer.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Value;
|
||||
|
||||
@@ -48,6 +48,6 @@ private:
|
||||
std::vector<Token> m_tokens;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_JOB_H
|
||||
#endif // UTIL_JSON_JOB_H
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "util/json/job.h"
|
||||
#include "util/json/lexer.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
Lexer::Lexer(Job* job)
|
||||
: GenericLexer(job->input())
|
||||
@@ -214,4 +214,4 @@ bool Lexer::consumeLiteral()
|
||||
return consumeNumberOrLiteral(Token::Type::Literal);
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_LEXER_H
|
||||
#define JSON_LEXER_H
|
||||
#ifndef UTIL_JSON_LEXER_H
|
||||
#define UTIL_JSON_LEXER_H
|
||||
|
||||
// The JavaScript Object Notation (JSON) Data Interchange Format
|
||||
// https://www.rfc-editor.org/rfc/pdfrfc/rfc8259.txt.pdf
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "util/genericlexer.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Job;
|
||||
|
||||
@@ -62,6 +62,6 @@ private:
|
||||
std::vector<Token>* m_tokens { nullptr };
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_LEXER_H
|
||||
#endif // UTIL_JSON_LEXER_H
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "util/json/object.h"
|
||||
#include "util/json/value.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
void Object::emplace(const std::string& name, Value value)
|
||||
{
|
||||
@@ -23,4 +23,4 @@ Value& Object::operator[](const std::string& name)
|
||||
return m_members.at(name);
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_OBJECT_H
|
||||
#define JSON_OBJECT_H
|
||||
#ifndef UTIL_JSON_OBJECT_H
|
||||
#define UTIL_JSON_OBJECT_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "util/json/parser.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Value;
|
||||
|
||||
@@ -50,6 +50,6 @@ private:
|
||||
std::map<std::string, Value> m_members;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_OBJECT_H
|
||||
#endif // UTIL_JSON_OBJECT_H
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "util/json/parser.h"
|
||||
#include "util/json/value.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
Parser::Parser(Job* job)
|
||||
: m_job(job)
|
||||
@@ -493,4 +493,4 @@ Value Parser::consumeObject()
|
||||
return object;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_PARSER_H
|
||||
#define JSON_PARSER_H
|
||||
#ifndef UTIL_JSON_PARSER_H
|
||||
#define UTIL_JSON_PARSER_H
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <vector>
|
||||
|
||||
#include "util/json/lexer.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Job;
|
||||
class Value;
|
||||
@@ -43,6 +43,6 @@ private:
|
||||
std::vector<Token>* m_tokens { nullptr };
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_PARSER_H
|
||||
#endif // UTIL_JSON_PARSER_H
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "util/json/object.h"
|
||||
#include "util/json/serializer.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
Serializer::Serializer(const uint32_t indent, const char indentCharacter)
|
||||
: m_indent(indent)
|
||||
@@ -151,4 +151,4 @@ void Serializer::dumpObject(const Value& value, const uint32_t indentLevel)
|
||||
m_output += '}';
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_SERIALIZER_H
|
||||
#define JSON_SERIALIZER_H
|
||||
#ifndef UTIL_JSON_SERIALIZER_H
|
||||
#define UTIL_JSON_SERIALIZER_H
|
||||
|
||||
#include <cstdint> // uint32_t
|
||||
#include <string>
|
||||
|
||||
#include "util/json/value.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Serializer {
|
||||
public:
|
||||
@@ -32,6 +32,6 @@ private:
|
||||
char m_indentCharacter { ' ' };
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_SERIALIZER_H
|
||||
#endif // UTIL_JSON_SERIALIZER_H
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_TO_JSON_H
|
||||
#define JSON_TO_JSON_H
|
||||
#ifndef UTIL_JSON_TO_JSON_H
|
||||
#define UTIL_JSON_TO_JSON_H
|
||||
|
||||
#include <cassert> // assert
|
||||
#include <cstddef> // nullptr_t
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "util/json/object.h"
|
||||
#include "util/meta/odr.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
namespace Detail {
|
||||
|
||||
@@ -136,9 +136,9 @@ namespace {
|
||||
constexpr const auto& toJson = Util::Detail::staticConst<Detail::toJsonFunction>; // NOLINT(misc-definitions-in-headers,clang-diagnostic-unused-variable)
|
||||
} // namespace
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
#endif // JSON_TO_JSON_H
|
||||
#endif // UTIL_JSON_TO_JSON_H
|
||||
|
||||
// Customization Points
|
||||
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "util/json/serializer.h"
|
||||
#include "util/json/value.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
Value::Value(std::nullptr_t)
|
||||
: Value(Type::Null)
|
||||
@@ -337,4 +337,4 @@ void format(FormatBuilder& builder, const Value& value)
|
||||
builder.putString(value.dump(4));
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef JSON_VALUE_H
|
||||
#define JSON_VALUE_H
|
||||
#ifndef UTIL_JSON_VALUE_H
|
||||
#define UTIL_JSON_VALUE_H
|
||||
|
||||
#include <cstddef> // nullptr_t, size_t
|
||||
#include <cstdint> // uint32_t
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "util/json/fromjson.h"
|
||||
#include "util/json/tojson.h"
|
||||
|
||||
namespace Json {
|
||||
namespace Util::JSON {
|
||||
|
||||
class Array;
|
||||
class Object;
|
||||
@@ -137,7 +137,7 @@ std::ostream& operator<<(std::ostream& output, const Value& value);
|
||||
|
||||
void format(FormatBuilder& builder, const Value& value);
|
||||
|
||||
} // namespace Json
|
||||
} // namespace Util::JSON
|
||||
|
||||
/**
|
||||
* User-defined string literal
|
||||
@@ -149,4 +149,4 @@ inline Json::Value operator"" _json(const char* input, size_t length)
|
||||
return Json::Value::parse(std::string(input, length));
|
||||
}
|
||||
|
||||
#endif // JSON_VALUE_H
|
||||
#endif // UTIL_JSON_VALUE_H
|
||||
|
||||
Reference in New Issue
Block a user