Accept slice in to_double.
GitOrigin-RevId: 3e68b84972a15404ab6ec43b6c157289487b3a5b
This commit is contained in:
parent
9d5580f315
commit
79df9bac53
|
@ -1409,7 +1409,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
|
||||||
Location l(inline_message_geo->geo_);
|
Location l(inline_message_geo->geo_);
|
||||||
location->location_ = l.get_location_object();
|
location->location_ = l.get_location_object();
|
||||||
} else {
|
} else {
|
||||||
auto coordinates = split(result->description_);
|
auto coordinates = split(Slice(result->description_));
|
||||||
Location l(to_double(coordinates.first), to_double(coordinates.second));
|
Location l(to_double(coordinates.first), to_double(coordinates.second));
|
||||||
location->location_ = l.get_location_object();
|
location->location_ = l.get_location_object();
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ inline Status from_json(double &to, JsonValue &from) {
|
||||||
if (from.type() != JsonValue::Type::Number) {
|
if (from.type() != JsonValue::Type::Number) {
|
||||||
return Status::Error(PSLICE() << "Expected number, got " << from.type());
|
return Status::Error(PSLICE() << "Expected number, got " << from.type());
|
||||||
}
|
}
|
||||||
to = to_double(from.get_number().str());
|
to = to_double(from.get_number());
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -623,7 +623,7 @@ Result<double> get_json_object_double_field(JsonObject &object, Slice name, bool
|
||||||
if (value.type() == JsonValue::Type::Null) {
|
if (value.type() == JsonValue::Type::Null) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
return to_double(value.get_number().str());
|
return to_double(value.get_number());
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<string> get_json_object_string_field(JsonObject &object, Slice name, bool is_optional, string default_value) {
|
Result<string> get_json_object_string_field(JsonObject &object, Slice name, bool is_optional, string default_value) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ string oneline(Slice str) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
double to_double(CSlice str) {
|
double to_double(Slice str) {
|
||||||
static TD_THREAD_LOCAL std::stringstream *ss;
|
static TD_THREAD_LOCAL std::stringstream *ss;
|
||||||
if (init_thread_local<std::stringstream>(ss)) {
|
if (init_thread_local<std::stringstream>(ss)) {
|
||||||
ss->imbue(std::locale::classic());
|
ss->imbue(std::locale::classic());
|
||||||
|
|
|
@ -264,7 +264,7 @@ typename std::enable_if<std::is_unsigned<T>::value, T>::type hex_to_integer(Slic
|
||||||
return integer_value;
|
return integer_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double to_double(CSlice str);
|
double to_double(Slice str);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T clamp(T value, T min_value, T max_value) {
|
T clamp(T value, T min_value, T max_value) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user