Skip to content

Commit

Permalink
Merge branch 'Glaze-master-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Astari committed Sep 27, 2024
2 parents a781903 + 19ba385 commit 3ca2ee7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/ThirdParty/Glaze_Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,19 @@ namespace Glaze
}
virtual bool Stringify(const ParseResultBase& parsedData, std::unique_ptr<StringResultBase>& reply) const
{
return Prettify(parsedData, reply);
GetValueResult<T> const& parsedDataInput = dynamic_cast<GetValueResult<T> const&>(parsedData);
std::unique_ptr<StringResultUsingString> output = std::make_unique<StringResultUsingString>();

output->result = glz::write_json(parsedDataInput.data).value_or("error");
reply = std::move(output);
return true;
}
virtual bool Prettify(const ParseResultBase& parsedData, std::unique_ptr<StringResultBase>& reply) const
{
GetValueResult<T> const& parsedDataInput = dynamic_cast<GetValueResult<T> const&>(parsedData);
std::unique_ptr<StringResultUsingString> output = std::make_unique<StringResultUsingString>();

output->result = glz::write_json(parsedDataInput.data).value_or("error");
output->result = glz::write < glz::opts{ .prettify = true } > (parsedDataInput.data).value_or("error");
reply = std::move(output);
return true;
}
Expand Down
17 changes: 10 additions & 7 deletions src/ThirdParty/JsonifierTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "JsonifierCountry.h"
#include "JsonifierTwitter.h"

template<typename value_type> concept performance_data = std::same_as<std::remove_cvref_t<value_type>, twitter_message>
|| std::same_as<std::remove_cvref_t<value_type>, citm_catalog_message>
|| std::same_as<std::remove_cvref_t<value_type>, canada_message>;

template<> struct jsonifier::core<geometry_data> {
using value_type = geometry_data;
static constexpr auto parseValue = createValue<&value_type::type, &value_type::coordinates>();
Expand Down Expand Up @@ -118,7 +122,6 @@ template<> struct jsonifier::core<twitter_message> {
static constexpr auto parseValue = createValue<&value_type::statuses, &value_type::search_metadata>();
};


template<> struct jsonifier::core<audience_sub_category_names> {
using value_type = audience_sub_category_names;
static constexpr auto parseValue = createValue("337100890", &value_type::the337100890);
Expand Down Expand Up @@ -205,7 +208,7 @@ namespace JsonifierTypes
virtual bool ParseDouble(const char* json, long double& reply) const
{
std::vector<double> data;
if (parser.parseJson < jsonifier::parse_options{} > (data, jsonifier::string_view{ json })) {
if (parser.parseJson(data, jsonifier::string_view{ json })) {
if (data.size() == 1) {
reply = data[0];
}
Expand All @@ -220,7 +223,7 @@ namespace JsonifierTypes
virtual bool ParseString(const char* json, std::string& reply) const
{
std::vector<std::string> data;
if (parser.parseJson < jsonifier::parse_options{} > (data, jsonifier::string_view{ json })) {
if (parser.parseJson(data, jsonifier::string_view{ json })) {
if (data.size() == 1) {
reply = data[0];
}
Expand All @@ -244,7 +247,7 @@ template<typename T> struct jsonifier::core<GetValueResult<T>> {

namespace JsonifierTypes {

template<typename T>
template<typename T>
class GetValue : public TestAction
{

Expand All @@ -261,18 +264,18 @@ template<typename T>
{
GetValueResult<T>const& parsedDataInput = static_cast<GetValueResult<T> const&>(parsedData);
reply.reset(new StringResultUsingString{});
parser.serializeJson (parsedDataInput.data, static_cast<StringResultUsingString*>(reply.get())->result);
parser.serializeJson(parsedDataInput.data, static_cast<StringResultUsingString*>(reply.get())->result);
return true;
}
virtual JSONIFIER_ALWAYS_INLINE bool Prettify(const ParseResultBase& parsedData, std::unique_ptr<StringResultBase>& reply) const
{
GetValueResult<T>const& parsedDataInput = static_cast<GetValueResult<T> const&>(parsedData);
reply.reset(new StringResultUsingString{});
parser.serializeJson (parsedDataInput.data, static_cast<StringResultUsingString*>(reply.get())->result);
parser.serializeJson < jsonifier::serialize_options{ .prettify = true } > (parsedDataInput.data, static_cast<StringResultUsingString*>(reply.get())->result);
return true;
}
};

}

#endif
#endif
2 changes: 1 addition & 1 deletion thirdparty/Jsonifier
Submodule Jsonifier updated 193 files

0 comments on commit 3ca2ee7

Please sign in to comment.