Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/ProjectGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ macro(project_enable_clang_format)
if (NOT ${CLANG_FORMAT_EXE} STREQUAL "CLANG_FORMAT_EXE-NOTFOUND")
message("-- clang-format found, whole source formatting enabled through 'format' target.")
add_custom_target(format
COMMAND find ./src -type f -regex .*\\.h\\\|.*\\.hpp\\\|.*\\.hxx\\\|.*\\.c\\\|.*\\.cpp\\\|.*\\.cxx\\\|.*\\.cc -exec clang-format -i {} \;
COMMAND find ./includes -type f -regex .*\\.h\\\|.*\\.hpp\\\|.*\\.hxx\\\|.*\\.c\\\|.*\\.cpp\\\|.*\\.cxx\\\|.*\\.cc -exec clang-format -i {} \;
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
VERBATIM
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/ProjectTestFunctions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file provides function to add tests tp ctest
# This file prmvides function to add tests tp ctest
# with additional tooling

##
Expand Down
7 changes: 3 additions & 4 deletions includes/named_types/extensions/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace extensions {
namespace __factory_impl {
template <class T, class Base, class... Args>
std::function<Base*(Args...)> make_builder() {
return ([](Args... args) -> Base *
{ return new T(std::forward<Args>(args)...); });
return (
[](Args... args) -> Base* { return new T(std::forward<Args>(args)...); });
}
} // namespace __factory_impl

Expand All @@ -25,8 +25,7 @@ template <class BaseClass, class... T> class factory {
named_tuple<typename id<std::function<BaseClass*(BuildArgs...)>(
__ntuple_tag_spec_t<T>)>::type...>;
static builder_tuple_type const builders_{
__factory_impl::make_builder<__ntuple_tag_elem_t<T>,
BaseClass,
__factory_impl::make_builder<__ntuple_tag_elem_t<T>, BaseClass,
BuildArgs...>()...};
static const_rt_view<builder_tuple_type> const rt_view_(builders_);
auto builder =
Expand Down
10 changes: 5 additions & 5 deletions includes/named_types/extensions/generation_tools.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#pragma once
#include <type_traits>
#include <cstdint>
#include "named_types/extensions/type_traits.hpp"
#include "named_types/named_tuple.hpp"
#include "named_types/rt_named_tuple.hpp"
#include "named_types/extensions/type_traits.hpp"
#include <cstdint>
#include <type_traits>

namespace named_types {
namespace extensions {
namespace generation {

template <class T> struct printf_sequence {
using type = void;
static T evaluate(T value){ return value; };
static T evaluate(T value) { return value; };
};

template <> struct printf_sequence<char const*> {
Expand Down Expand Up @@ -61,7 +61,7 @@ template <> struct printf_sequence<double> {
static inline double evaluate(double data) { return data; };
};

//template <typename ... T> forward_as_flattened_tuple(
// template <typename ... T> forward_as_flattened_tuple(

} // namespace generation
} // namespace extensions
Expand Down
85 changes: 37 additions & 48 deletions includes/named_types/extensions/parsing_tools.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once
#include <type_traits>
#include "named_types/extensions/type_traits.hpp"
#include "named_types/named_tuple.hpp"
#include "named_types/rt_named_tuple.hpp"
#include <cstdint>
#include <vector>
#include <list>
#include <map>
#include <type_traits>
#include <unordered_map>
#include "named_types/named_tuple.hpp"
#include "named_types/rt_named_tuple.hpp"
#include "named_types/extensions/type_traits.hpp"
#include <vector>

namespace named_types {
namespace extensions {
Expand All @@ -20,9 +20,9 @@ inline std::enable_if_t<std::is_arithmetic<From>::value &&
is_std_basic_string<To>::value,
To>
lexical_cast(From const& value) {
std::basic_ostringstream<typename To::value_type,
typename To::traits_type,
typename To::allocator_type> output;
std::basic_ostringstream<typename To::value_type, typename To::traits_type,
typename To::allocator_type>
output;
output << value;
return output.str();
}
Expand All @@ -49,10 +49,9 @@ lexical_cast(From const& value) {
}

template <class To, class From>
inline std::enable_if_t<is_raw_string<From>::value &&
std::is_arithmetic<To>::value,
To>
lexical_cast(From const& value) {
inline std::
enable_if_t<is_raw_string<From>::value && std::is_arithmetic<To>::value, To>
lexical_cast(From const& value) {
To result{};
std::istringstream(value) >> result;
return result;
Expand All @@ -63,8 +62,9 @@ template <class Source, class Tuple, size_t Index>
inline std::enable_if_t<tuple_member_assignable<Source, Tuple, Index>::value,
std::function<void(Tuple&, Source&&)>>
make_setter() {
return [](Tuple& tuple, Source&& source)
-> void { std::get<Index>(tuple) = std::move(source); };
return [](Tuple& tuple, Source&& source) -> void {
std::get<Index>(tuple) = std::move(source);
};
}

template <class Source, class Tuple, size_t Index>
Expand Down Expand Up @@ -144,11 +144,9 @@ inline std::enable_if_t<
std::function<
value_setter_interface<KeyCharT, ValueCharT, SizeType>*(Tuple&)>>
make_creator() {
return [](Tuple & tuple)
-> value_setter_interface<KeyCharT, ValueCharT, SizeType> * {
return new value_setter<KeyCharT,
ValueCharT,
SizeType,
return [](Tuple& tuple)
-> value_setter_interface<KeyCharT, ValueCharT, SizeType>* {
return new value_setter<KeyCharT, ValueCharT, SizeType,
std::tuple_element_t<Index, Tuple>>(
std::get<Index>(tuple));
};
Expand Down Expand Up @@ -177,11 +175,9 @@ inline std::enable_if_t<
std::function<
sequence_pusher_interface<KeyCharT, ValueCharT, SizeType>*(Tuple&)>>
make_sequence_creator() {
return [](Tuple & tuple)
-> sequence_pusher_interface<KeyCharT, ValueCharT, SizeType> * {
return new sequence_pusher<KeyCharT,
ValueCharT,
SizeType,
return [](Tuple& tuple)
-> sequence_pusher_interface<KeyCharT, ValueCharT, SizeType>* {
return new sequence_pusher<KeyCharT, ValueCharT, SizeType,
std::tuple_element_t<Index, Tuple>>(
std::get<Index>(tuple));
};
Expand Down Expand Up @@ -346,12 +342,11 @@ class value_setter<KeyCharT, ValueCharT, SizeType, named_tuple<Tags...>>
rt_view<Tuple> rt_root_;

template <class T> bool setFrom(size_t field_index, T&& value) {
static std::array<std::function<void(Tuple&, T && )>, Tuple::size> setters =
static std::array<std::function<void(Tuple&, T &&)>, Tuple::size> setters =
{make_setter<
T,
Tuple,
T, Tuple,
Tuple::template tag_index<__ntuple_tag_spec_t<Tags>>::value>()...};
std::function<void(Tuple&, T && )> setter(
std::function<void(Tuple&, T &&)> setter(
field_index < setters.size() ? setters[field_index] : nullptr);
if (setter) {
setter(root_, std::move(value));
Expand Down Expand Up @@ -409,20 +404,17 @@ class value_setter<KeyCharT, ValueCharT, SizeType, named_tuple<Tags...>>

virtual value_setter_interface<KeyCharT, ValueCharT, SizeType>*
createChildNode(std::basic_string<KeyCharT> const& key) override {
static std::array<
std::function<
value_setter_interface<KeyCharT, ValueCharT, SizeType>*(Tuple&)>,
Tuple::size> creators = {
make_creator<
KeyCharT,
ValueCharT,
SizeType,
Tuple,
static std::array<std::function<value_setter_interface<KeyCharT, ValueCharT,
SizeType>*(Tuple&)>,
Tuple::size>
creators = {make_creator<
KeyCharT, ValueCharT, SizeType, Tuple,
Tuple::template tag_index<__ntuple_tag_spec_t<Tags>>::value>()...};
size_t field_index = rt_root_.index_of(key);
if (field_index < creators.size()) {
std::function<value_setter_interface<KeyCharT, ValueCharT, SizeType>*(
Tuple&)> creator = creators[field_index];
Tuple&)>
creator = creators[field_index];
if (creator)
return creator(root_);
}
Expand All @@ -431,20 +423,17 @@ class value_setter<KeyCharT, ValueCharT, SizeType, named_tuple<Tags...>>

virtual sequence_pusher_interface<KeyCharT, ValueCharT, SizeType>*
createChildSequence(std::basic_string<KeyCharT> const& key) override {
static std::array<
std::function<
sequence_pusher_interface<KeyCharT, ValueCharT, SizeType>*(Tuple&)>,
Tuple::size> creators = {
make_sequence_creator<
KeyCharT,
ValueCharT,
SizeType,
Tuple,
static std::array<std::function<sequence_pusher_interface<
KeyCharT, ValueCharT, SizeType>*(Tuple&)>,
Tuple::size>
creators = {make_sequence_creator<
KeyCharT, ValueCharT, SizeType, Tuple,
Tuple::template tag_index<__ntuple_tag_spec_t<Tags>>::value>()...};
size_t field_index = rt_root_.index_of(key);
if (field_index < creators.size()) {
std::function<sequence_pusher_interface<KeyCharT, ValueCharT, SizeType>*(
Tuple&)> creator = creators[field_index];
Tuple&)>
creator = creators[field_index];
if (creator)
return creator(root_);
}
Expand Down
16 changes: 8 additions & 8 deletions includes/named_types/extensions/rapidjson.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once
#include "named_types/extensions/type_traits.hpp"
#include "named_types/named_tuple.hpp"
#include "named_types/rt_named_tuple.hpp"
#include <array>
#include <stack>
#include <iterator>
#include <rapidjson/reader.h>
#include "named_types/named_tuple.hpp"
#include "named_types/extensions/type_traits.hpp"
#include <named_types/extensions/parsing_tools.hpp>
#include "named_types/rt_named_tuple.hpp"
#include <rapidjson/reader.h>
#include <stack>

namespace named_types {
namespace extensions {
Expand All @@ -15,9 +15,9 @@ namespace rapidjson {
template <class RootType, class Encoding> class reader_handler;

template <class RootType, class Encoding>
class reader_handler : public ::rapidjson::BaseReaderHandler<
Encoding,
reader_handler<RootType, Encoding>> {
class reader_handler
: public ::rapidjson::
BaseReaderHandler<Encoding, reader_handler<RootType, Encoding>> {
static_assert(is_sub_object<RootType>::value ||
is_sequence_container<RootType>::value,
"Root type of a handler must either be a named_tuple, an "
Expand Down
Loading