Skip to content

Commit

Permalink
styles: 继续格式化!
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Mar 6, 2024
1 parent d7fe7c2 commit cc889da
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 1
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
# AllowShortCompoundRequirementOnASingleLine: true
Expand Down
4 changes: 3 additions & 1 deletion include/common/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ inline auto basic_array<string_t>::get(
template <typename string_t>
template <typename value_t, typename... rest_keys_t>
inline auto basic_array<string_t>::get_helper(
const value_t& default_value, size_t pos, rest_keys_t&&... rest) const
const value_t& default_value,
size_t pos,
rest_keys_t&&... rest) const
{
constexpr bool is_json = std::is_same_v<basic_value<string_t>, value_t>
|| std::is_same_v<basic_array<string_t>, value_t>
Expand Down
10 changes: 7 additions & 3 deletions include/common/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ class basic_object
template <typename string_t>
inline basic_object<string_t>::basic_object(std::initializer_list<value_type> init_list)
: _object_data(
std::make_move_iterator(init_list.begin()), std::make_move_iterator(init_list.end()))
std::make_move_iterator(init_list.begin()),
std::make_move_iterator(init_list.end()))
{
}

Expand Down Expand Up @@ -324,7 +325,9 @@ inline auto basic_object<string_t>::get(
template <typename string_t>
template <typename value_t, typename... rest_keys_t>
inline auto basic_object<string_t>::get_helper(
const value_t& default_value, const string_t& key, rest_keys_t&&... rest) const
const value_t& default_value,
const string_t& key,
rest_keys_t&&... rest) const
{
constexpr bool is_json = std::is_same_v<basic_value<string_t>, value_t>
|| std::is_same_v<basic_array<string_t>, value_t>
Expand Down Expand Up @@ -459,7 +462,8 @@ inline basic_object<string_t> basic_object<string_t>::operator|(basic_object<str
basic_object<string_t> temp = *this;
// temp._object_data.merge(std::move(rhs._object_data));
temp._object_data.insert(
std::make_move_iterator(rhs.begin()), std::make_move_iterator(rhs.end()));
std::make_move_iterator(rhs.begin()),
std::make_move_iterator(rhs.end()));
return temp;
}

Expand Down
4 changes: 3 additions & 1 deletion include/common/serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ template <
typename deserializer_t = _serialization_helper::empty_deserializer,
typename string_t = default_string_t>
bool deserialize(
const basic_value<string_t>& in, out_t& out, const deserializer_t& deserializer = {})
const basic_value<string_t>& in,
out_t& out,
const deserializer_t& deserializer = {})
{
if constexpr (_serialization_helper::is_deserializable<out_t, deserializer_t>::value) {
return deserializer(in, out);
Expand Down
13 changes: 9 additions & 4 deletions include/common/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ inline auto basic_value<string_t>::get(
template <typename string_t>
template <typename value_t, typename first_key_t, typename... rest_keys_t>
inline auto basic_value<string_t>::get_helper(
const value_t& default_value, first_key_t&& first, rest_keys_t&&... rest) const
const value_t& default_value,
first_key_t&& first,
rest_keys_t&&... rest) const
{
if constexpr (std::is_constructible_v<string_t, first_key_t>) {
return is_object() ? as_object().get_helper(
Expand Down Expand Up @@ -571,7 +573,8 @@ inline auto
}
else {
static_assert(
!sizeof(unique_key_t), "Parameter must be integral or string_t constructible");
!sizeof(unique_key_t),
"Parameter must be integral or string_t constructible");
}
}

Expand Down Expand Up @@ -810,7 +813,8 @@ inline decltype(auto) basic_value<string_t>::emplace(args_t&&... args)
std::is_constructible_v<typename basic_object<string_t>::value_type, args_t...>;

static_assert(
is_array_args || is_object_args, "Args can not constructure a array or object value");
is_array_args || is_object_args,
"Args can not constructure a array or object value");

if constexpr (is_array_args) {
return as_array().emplace_back(std::forward<args_t>(args)...);
Expand Down Expand Up @@ -1050,7 +1054,8 @@ inline basic_value<string_t>::basic_value(value_type type, args_t&&... args)
, _raw_data(std::forward<args_t>(args)...)
{
static_assert(
std::is_constructible_v<var_t, args_t...>, "Parameter can't be used to construct a var_t");
std::is_constructible_v<var_t, args_t...>,
"Parameter can't be used to construct a var_t");
}

template <typename string_t>
Expand Down
3 changes: 2 additions & 1 deletion include/parser/packed_bytes_arm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ struct packed_bytes_trait_neon
return vmaxvq_u8(x) == 0;
#else
auto fold64 = vorr_u64(
vget_high_u64(vreinterpretq_u8_u64(x), 0), vget_low_u64(vreinterpretq_u8_u64(x), 1));
vget_high_u64(vreinterpretq_u8_u64(x), 0),
vget_low_u64(vreinterpretq_u8_u64(x), 1));
auto fold32 = vget_lane_u32(vreinterpret_u64_u32(fold64), 0)
| vget_lane_u32(vreinterpret_u64_u32(fold64), 1);
return fold32 == 0;
Expand Down
6 changes: 4 additions & 2 deletions include/parser/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ inline basic_value<string_t> parser<string_t, parsing_t, accel_traits>::parse_st
return invalid_value<string_t>();
}
return basic_value<string_t>(
basic_value<string_t>::value_type::string, std::move(string_opt).value());
basic_value<string_t>::value_type::string,
std::move(string_opt).value());
}

template <typename string_t, typename parsing_t, typename accel_traits>
Expand Down Expand Up @@ -636,6 +637,7 @@ template <typename string_t>
const basic_value<string_t> invalid_value()
{
return basic_value<string_t>(
basic_value<string_t>::value_type::invalid, typename basic_value<string_t>::var_t());
basic_value<string_t>::value_type::invalid,
typename basic_value<string_t>::var_t());
}
} // namespace json
4 changes: 3 additions & 1 deletion include/parser5/parser5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class parser5
public:
InvalidChar(u8char ch = 0, const std::string& detail = "")
: exception(
"Invalid Char", "Unexpected token \'" + StringFromCharCode(ch) + "\'", detail)
"Invalid Char",
"Unexpected token \'" + StringFromCharCode(ch) + "\'",
detail)
{
}
};
Expand Down
69 changes: 36 additions & 33 deletions include/reflection/jsonization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,43 +410,46 @@ namespace json::_private_macro
#define _MEOJSON_KEY_VALUE(x) _MEOJSON_STRINGIZE(x), x,
} // namespace json::_private_macro

#define MEO_TOJSON(...) \
json::value to_json() const \
{ \
return json::_jsonization_helper::dumper()._to_json(_MEOJSON_EXPAND(_MEOJSON_FOR_EACH( \
_MEOJSON_KEY_VALUE, __VA_ARGS__)) json::_jsonization_helper::va_arg_end {}); \
#define MEO_TOJSON(...) \
json::value to_json() const \
{ \
return json::_jsonization_helper::dumper()._to_json( \
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
json::_jsonization_helper::va_arg_end {}); \
}

#define MEO_CHECKJSON(...) \
bool check_json(const json::value& _MEOJSON_VARNAME(in)) const \
{ \
std::string _MEOJSON_VARNAME(error_key); \
return check_json(_MEOJSON_VARNAME(in), _MEOJSON_VARNAME(error_key)); \
} \
bool check_json( \
const json::value& _MEOJSON_VARNAME(in), std::string& _MEOJSON_VARNAME(error_key)) const \
{ \
return json::_jsonization_helper::checker()._check_json( \
_MEOJSON_VARNAME(in), \
_MEOJSON_VARNAME(error_key), \
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
json::_jsonization_helper::va_arg_end {}); \
#define MEO_CHECKJSON(...) \
bool check_json(const json::value& _MEOJSON_VARNAME(in)) const \
{ \
std::string _MEOJSON_VARNAME(error_key); \
return check_json(_MEOJSON_VARNAME(in), _MEOJSON_VARNAME(error_key)); \
} \
bool check_json( \
const json::value& _MEOJSON_VARNAME(in), \
std::string& _MEOJSON_VARNAME(error_key)) const \
{ \
return json::_jsonization_helper::checker()._check_json( \
_MEOJSON_VARNAME(in), \
_MEOJSON_VARNAME(error_key), \
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
json::_jsonization_helper::va_arg_end {}); \
}

#define MEO_FROMJSON(...) \
bool from_json(const json::value& _MEOJSON_VARNAME(in)) \
{ \
std::string _MEOJSON_VARNAME(error_key); \
return from_json(_MEOJSON_VARNAME(in), _MEOJSON_VARNAME(error_key)); \
} \
bool from_json( \
const json::value& _MEOJSON_VARNAME(in), std::string& _MEOJSON_VARNAME(error_key)) \
{ \
return json::_jsonization_helper::loader()._from_json( \
_MEOJSON_VARNAME(in), \
_MEOJSON_VARNAME(error_key), \
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
json::_jsonization_helper::va_arg_end {}); \
#define MEO_FROMJSON(...) \
bool from_json(const json::value& _MEOJSON_VARNAME(in)) \
{ \
std::string _MEOJSON_VARNAME(error_key); \
return from_json(_MEOJSON_VARNAME(in), _MEOJSON_VARNAME(error_key)); \
} \
bool from_json( \
const json::value& _MEOJSON_VARNAME(in), \
std::string& _MEOJSON_VARNAME(error_key)) \
{ \
return json::_jsonization_helper::loader()._from_json( \
_MEOJSON_VARNAME(in), \
_MEOJSON_VARNAME(error_key), \
_MEOJSON_EXPAND(_MEOJSON_FOR_EACH(_MEOJSON_KEY_VALUE, __VA_ARGS__)) \
json::_jsonization_helper::va_arg_end {}); \
}

#define MEO_JSONIZATION(...) \
Expand Down
3 changes: 2 additions & 1 deletion test/serializing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ bool jsonizing()
}

std::map<std::string, std::filesystem::path> path_map = {
{ "key1", "/root/dir1/dir2/filename" }, { "key2", "/root/dir1/dir2/filename2" }
{ "key1", "/root/dir1/dir2/filename" },
{ "key2", "/root/dir1/dir2/filename2" }
};
json::object jpath_map = path_map;
std::map<std::string, std::filesystem::path> new_path_map =
Expand Down

0 comments on commit cc889da

Please sign in to comment.