Remove td::ctie.

GitOrigin-RevId: 926a19055770a2566778a022d01b7a9661d46ae6
This commit is contained in:
levlam 2019-12-08 08:50:43 +03:00
parent c0b8349a56
commit 8a7d6be7df
4 changed files with 5 additions and 18 deletions

View File

@ -31,7 +31,7 @@ void gen_to_json_constructor(StringBuilder &sb, const T *constructor, bool is_he
}
sb << " {\n";
sb << " auto jo = jv.enter_object();\n";
sb << " jo << ctie(\"@type\", \"" << tl::simple::gen_cpp_name(constructor->name) << "\");\n";
sb << " jo(\"@type\", \"" << tl::simple::gen_cpp_name(constructor->name) << "\");\n";
for (auto &arg : constructor->args) {
auto field = tl::simple::gen_cpp_field_name(arg.name);
// TODO: or as null
@ -49,7 +49,7 @@ void gen_to_json_constructor(StringBuilder &sb, const T *constructor, bool is_he
arg.type->vector_value_type->type == tl::simple::Type::Int64) {
object = PSTRING() << "JsonVectorInt64{" << object << "}";
}
sb << " jo << ctie(\"" << arg.name << "\", ToJson(" << object << "));\n";
sb << " jo(\"" << arg.name << "\", ToJson(" << object << "));\n";
if (is_custom) {
sb << " }\n";
}

View File

@ -177,7 +177,7 @@ class JsonableJsonValue : public Jsonable {
if (!check_utf8(member->key_)) {
LOG(ERROR) << "Have incorrect UTF-8 object key " << member->key_;
} else {
object << ctie(member->key_, JsonableJsonValue(member->value_.get()));
object(member->key_, JsonableJsonValue(member->value_.get()));
}
}
}

View File

@ -15,20 +15,11 @@
#include "td/utils/StringBuilder.h"
#include <new>
#include <tuple>
#include <type_traits>
#include <utility>
namespace td {
template <class... Args>
std::tuple<const Args &...> ctie(const Args &... args) TD_WARN_UNUSED_RESULT;
template <class... Args>
std::tuple<const Args &...> ctie(const Args &... args) {
return std::tie(args...);
}
class JsonTrue {
public:
friend StringBuilder &operator<<(StringBuilder &sb, const JsonTrue &val) {
@ -411,10 +402,6 @@ class JsonObjectScope : public JsonScope {
*sb_ << "}";
}
template <class S, class T>
JsonObjectScope &operator<<(std::tuple<S, T> key_value) {
return (*this)(std::get<0>(key_value), std::get<1>(key_value));
}
template <class S, class T>
JsonObjectScope &operator<<(std::pair<S, T> key_value) {
return (*this)(key_value.first, key_value.second);
}
@ -603,7 +590,7 @@ class JsonValue : public Jsonable {
case Type::Object: {
auto object = scope->enter_object();
for (auto &key_value : get_object()) {
object << ctie(JsonString(key_value.first), key_value.second);
object(JsonString(key_value.first), key_value.second);
}
break;
}

View File

@ -48,7 +48,7 @@ TEST(JSON, object) {
StringBuilder sb(MutableSlice{tmp, sizeof(tmp)});
JsonBuilder jb(std::move(sb));
auto c = jb.enter_object();
c << std::tie("key", "value");
c("key", "value");
c << std::make_pair("1", 2);
c.leave();
ASSERT_EQ(jb.string_builder().is_error(), false);