From f6e1311e210818d02bc7b74c0c30a8b916ec259d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 12 Jan 2019 11:51:15 -0800 Subject: [PATCH] ircd::json: Split path related from util header. --- include/ircd/json/json.h | 1 + include/ircd/json/path.h | 35 +++++++++++++++++++++++++++++++++++ include/ircd/json/util.h | 25 ------------------------- 3 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 include/ircd/json/path.h diff --git a/include/ircd/json/json.h b/include/ircd/json/json.h index 655fbd308..7fbc30b9f 100644 --- a/include/ircd/json/json.h +++ b/include/ircd/json/json.h @@ -50,6 +50,7 @@ namespace ircd::json } #include "util.h" +#include "path.h" #include "array.h" #include "object.h" #include "vector.h" diff --git a/include/ircd/json/path.h b/include/ircd/json/path.h new file mode 100644 index 000000000..a57265e69 --- /dev/null +++ b/include/ircd/json/path.h @@ -0,0 +1,35 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_JSON_PATH_H + +namespace ircd::json +{ + /// Higher order type beyond a string to cleanly delimit multiple keys. + using path = std::initializer_list; + std::ostream &operator<<(std::ostream &, const path &); +} + +inline std::ostream & +ircd::json::operator<<(std::ostream &s, const path &p) +{ + auto it(std::begin(p)); + if(it != std::end(p)) + { + s << *it; + ++it; + } + + for(; it != std::end(p); ++it) + s << '.' << *it; + + return s; +} diff --git a/include/ircd/json/util.h b/include/ircd/json/util.h index 469ced7a5..2da034786 100644 --- a/include/ircd/json/util.h +++ b/include/ircd/json/util.h @@ -17,10 +17,6 @@ namespace ircd::json constexpr name_hash_t name_hash(const string_view name); constexpr name_hash_t operator ""_(const char *const name, const size_t len); - /// Higher order type beyond a string to cleanly delimit multiple keys. - using path = std::initializer_list; - std::ostream &operator<<(std::ostream &, const path &); - extern const string_view literal_null; extern const string_view literal_true; extern const string_view literal_false; @@ -43,27 +39,6 @@ namespace ircd::json void valid_output(const string_view &, const size_t &expected); } -namespace ircd -{ - using json::operator<<; -} - -inline std::ostream & -ircd::json::operator<<(std::ostream &s, const path &p) -{ - auto it(std::begin(p)); - if(it != std::end(p)) - { - s << *it; - ++it; - } - - for(; it != std::end(p); ++it) - s << '.' << *it; - - return s; -} - constexpr ircd::json::name_hash_t ircd::json::operator ""_(const char *const text, const size_t len) {