From 208a0198c076f48462c6c9127667398c52195205 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 19 May 2018 22:10:58 -0700 Subject: [PATCH] ircd::json: Add specific extern undefined number. --- include/ircd/db/json.h | 2 +- include/ircd/json/util.h | 1 + ircd/json.cc | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/ircd/db/json.h b/include/ircd/db/json.h index b1070a1a9..1edb4ea1d 100644 --- a/include/ircd/db/json.h +++ b/include/ircd/db/json.h @@ -133,7 +133,7 @@ ircd::db::_assign_invalid(tuple &t, if(is_integer) { - json::set(t, cell.col(), 0L); + json::set(t, cell.col(), json::undefined_number); return; } } diff --git a/include/ircd/json/util.h b/include/ircd/json/util.h index f122800d8..0591e96b5 100644 --- a/include/ircd/json/util.h +++ b/include/ircd/json/util.h @@ -28,6 +28,7 @@ namespace ircd::json extern const string_view empty_string; extern const string_view empty_object; extern const string_view empty_array; + extern const int64_t undefined_number; size_t serialized(const string_view &); string_view stringify(mutable_buffer &, const string_view &); diff --git a/ircd/json.cc b/ircd/json.cc index 517e7ffa1..6f2602590 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -1733,6 +1733,12 @@ const ircd::string_view ircd::json::empty_string { "\"\"" }; const ircd::string_view ircd::json::empty_object { "{}" }; const ircd::string_view ircd::json::empty_array { "[]" }; +decltype(ircd::json::undefined_number) +ircd::json::undefined_number +{ + std::numeric_limits::max() +}; + std::ostream & ircd::json::operator<<(std::ostream &s, const value &v) { @@ -2411,7 +2417,7 @@ const switch(type) { case NUMBER: - return integer == std::numeric_limits::max(); + return integer == undefined_number; case STRING: return string_view{string, len}.undefined();