Skip to content

Commit

Permalink
styles: add empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Mar 15, 2024
1 parent 07e4dc4 commit e9c7aa4
Show file tree
Hide file tree
Showing 78 changed files with 276 additions and 35 deletions.
16 changes: 8 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# for clang-format 17.0.1
Language: Cpp
BasedOnStyle: 'WebKit'
BasedOnStyle: "WebKit"
# AccessModifierOffset: 2
AlignAfterOpenBracket: 'AlwaysBreak'
AlignAfterOpenBracket: "AlwaysBreak"
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
Expand Down Expand Up @@ -84,12 +84,12 @@ FixNamespaceComments: true
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IfMacros:
# IfMacros:
# - 'KJ_IF_MAYBE'
IncludeBlocks: Preserve
# IncludeCategories:
# IncludeIsMainRegex:
# IncludeIsMainSourceRegex:
# IncludeIsMainRegex:
# IncludeIsMainSourceRegex:
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
Expand Down Expand Up @@ -127,7 +127,7 @@ NamespaceIndentation: None
# ObjCSpaceAfterProperty:
# ObjCSpaceBeforeProtocolList:
PackConstructorInitializers: Never
# PenaltyBreakAssignment:
# PenaltyBreakAssignment:
# PenaltyBreakBeforeFirstCallParameter:
# PenaltyBreakComment:
# PenaltyBreakFirstLessLess:
Expand All @@ -151,7 +151,7 @@ RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 1000
SortIncludes: CaseSensitive
# SortJavaStaticImport:
Expand Down Expand Up @@ -180,7 +180,7 @@ SpacesInLineCommentPrefix:
SpacesInParens: Never
SpacesInSquareBrackets: false
Standard: c++20
# StatementAttributeLikeMacros:
# StatementAttributeLikeMacros:
# StatementMacros:
TabWidth: 4
# TypeNames:
Expand Down
13 changes: 13 additions & 0 deletions 3rdparty/include/meojson/common/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ class basic_array
: _array_data(std::make_move_iterator(arr.begin()), std::make_move_iterator(arr.end()))
{
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_member<jsonization_t>::value, bool> = true>
basic_array(const jsonization_t& value)
: basic_array(value.to_json())
{
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_templ_spec<jsonization_t>::value, bool> = true>
Expand All @@ -65,17 +67,24 @@ class basic_array
~basic_array() noexcept = default;

bool empty() const noexcept { return _array_data.empty(); }

size_t size() const noexcept { return _array_data.size(); }

bool contains(size_t pos) const { return pos < _array_data.size(); }

bool exists(size_t pos) const { return contains(pos); }

const basic_value<string_t>& at(size_t pos) const;

string_t dumps(std::optional<size_t> indent = std::nullopt) const
{
return indent ? format(*indent) : to_string();
}

string_t to_string() const;

string_t format(size_t indent = 4) const { return format(indent, 0); }

template <typename value_t>
bool all() const;
template <typename value_t, template <typename...> typename collection_t = std::vector>
Expand Down Expand Up @@ -124,6 +133,7 @@ class basic_array

basic_array<string_t>& operator=(const basic_array<string_t>&) = default;
basic_array<string_t>& operator=(basic_array<string_t>&&) noexcept = default;

template <
typename value_t,
std::enable_if_t<std::is_convertible_v<value_t, basic_array<string_t>>, bool> = true>
Expand All @@ -133,6 +143,7 @@ class basic_array
}

bool operator==(const basic_array<string_t>& rhs) const;

bool operator!=(const basic_array<string_t>& rhs) const { return !(*this == rhs); }

template <
Expand All @@ -143,6 +154,7 @@ class basic_array
{
return as_collection<value_t, collection_t>();
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_from_json_in_member<jsonization_t, string_t>::value, bool> =
Expand All @@ -155,6 +167,7 @@ class basic_array
}
return dst;
}

template <
typename jsonization_t,
std::enable_if_t<
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/include/meojson/common/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class exception : public std::exception
{
public:
exception() = default;

exception(const std::string& msg)
: _what(msg)
{
Expand Down
13 changes: 13 additions & 0 deletions 3rdparty/include/meojson/common/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ class basic_object
: _object_data(std::make_move_iterator(map.begin()), std::make_move_iterator(map.end()))
{
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_member<jsonization_t>::value, bool> = true>
basic_object(const jsonization_t& value)
: basic_object(value.to_json())
{
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_templ_spec<jsonization_t>::value, bool> = true>
Expand All @@ -64,17 +66,24 @@ class basic_object
~basic_object() = default;

bool empty() const noexcept { return _object_data.empty(); }

size_t size() const noexcept { return _object_data.size(); }

bool contains(const string_t& key) const;

bool exists(const string_t& key) const { return contains(key); }

const basic_value<string_t>& at(const string_t& key) const;

string_t dumps(std::optional<size_t> indent = std::nullopt) const
{
return indent ? format(*indent) : to_string();
}

string_t to_string() const;

string_t format(size_t indent = 4) const { return format(indent, 0); }

template <typename value_t>
bool all() const;
template <typename value_t, template <typename...> typename map_t = std::map>
Expand Down Expand Up @@ -116,6 +125,7 @@ class basic_object

basic_object<string_t>& operator=(const basic_object<string_t>&) = default;
basic_object<string_t>& operator=(basic_object<string_t>&&) = default;

template <
typename value_t,
std::enable_if_t<std::is_convertible_v<value_t, basic_object<string_t>>, bool> = true>
Expand All @@ -125,6 +135,7 @@ class basic_object
}

bool operator==(const basic_object<string_t>& rhs) const;

bool operator!=(const basic_object<string_t>& rhs) const { return !(*this == rhs); }

template <
Expand All @@ -135,6 +146,7 @@ class basic_object
{
return as_map<value_t, map_t>();
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_from_json_in_member<jsonization_t, string_t>::value, bool> =
Expand All @@ -147,6 +159,7 @@ class basic_object
}
return dst;
}

template <
typename jsonization_t,
std::enable_if_t<
Expand Down
32 changes: 32 additions & 0 deletions 3rdparty/include/meojson/common/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class basic_value
: basic_value(basic_array<string_t>(std::forward<collection_t>(collection)))
{
}

template <
typename map_t,
std::enable_if_t<
Expand All @@ -96,6 +97,7 @@ class basic_value
: basic_value(value.to_json())
{
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_templ_spec<jsonization_t>::value, bool> = true>
Expand All @@ -118,13 +120,21 @@ class basic_value
~basic_value();

bool valid() const noexcept { return _type != value_type::invalid; }

bool empty() const noexcept { return is_null(); }

bool is_null() const noexcept { return _type == value_type::null; }

bool is_number() const noexcept { return _type == value_type::number; }

bool is_boolean() const noexcept { return _type == value_type::boolean; }

bool is_string() const noexcept { return _type == value_type::string; }

bool is_array() const noexcept { return _type == value_type::array; }

bool is_object() const noexcept { return _type == value_type::object; }

template <typename value_t>
bool is() const noexcept;

Expand All @@ -133,9 +143,13 @@ class basic_value

bool contains(const string_t& key) const;
bool contains(size_t pos) const;

bool exists(const string_t& key) const { return contains(key); }

bool exists(size_t pos) const { return contains(pos); }

value_type type() const noexcept { return _type; }

const basic_value<string_t>& at(size_t pos) const;
const basic_value<string_t>& at(const string_t& key) const;

Expand Down Expand Up @@ -185,12 +199,15 @@ class basic_value
{
return indent ? format(*indent) : to_string();
}

// return raw string
string_t to_string() const;

string_t format(size_t indent = 4) const { return format(indent, 0); }

basic_value<string_t>& operator=(const basic_value<string_t>& rhs);
basic_value<string_t>& operator=(basic_value<string_t>&&) noexcept;

template <
typename value_t,
std::enable_if_t<std::is_convertible_v<value_t, basic_value<string_t>>, bool> = true>
Expand All @@ -200,6 +217,7 @@ class basic_value
}

bool operator==(const basic_value<string_t>& rhs) const;

bool operator!=(const basic_value<string_t>& rhs) const { return !(*this == rhs); }

const basic_value<string_t>& operator[](size_t pos) const;
Expand All @@ -224,18 +242,29 @@ class basic_value
basic_value<string_t>& operator+=(basic_array<string_t>&& rhs);

explicit operator bool() const { return as_boolean(); }

explicit operator int() const { return as_integer(); }

explicit operator unsigned() const { return as_unsigned(); }

explicit operator long() const { return as_long(); }

explicit operator unsigned long() const { return as_unsigned_long(); }

explicit operator long long() const { return as_long_long(); }

explicit operator unsigned long long() const { return as_unsigned_long_long(); }

explicit operator float() const { return as_float(); }

explicit operator double() const { return as_double(); }

explicit operator long double() const { return as_long_double(); }

explicit operator string_t() const { return as_string(); }

explicit operator basic_array<string_t>() const { return as_array(); }

explicit operator basic_object<string_t>() const { return as_object(); }

template <
Expand All @@ -246,6 +275,7 @@ class basic_value
{
return as_collection<value_t, collection_t>();
}

template <
typename value_t,
template <typename...> typename map_t = std::map,
Expand All @@ -254,6 +284,7 @@ class basic_value
{
return as_map<value_t, map_t>();
}

template <
typename jsonization_t,
std::enable_if_t<_utils::has_from_json_in_member<jsonization_t, string_t>::value, bool> =
Expand All @@ -266,6 +297,7 @@ class basic_value
}
return dst;
}

template <
typename jsonization_t,
std::enable_if_t<
Expand Down
Loading

0 comments on commit e9c7aa4

Please sign in to comment.