From e738782c69a1d65badc135bd886d5d5de9bb7987 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Fri, 2 Jul 2021 05:18:57 +0700 Subject: [PATCH] public info merge functions --- headers/meta.hpp/meta_class.hpp | 12 ++++++------ headers/meta.hpp/meta_class_info.hpp | 22 ++++++++++------------ headers/meta.hpp/meta_data.hpp | 2 +- headers/meta.hpp/meta_data_info.hpp | 22 ++++------------------ headers/meta.hpp/meta_field.hpp | 2 +- headers/meta.hpp/meta_field_info.hpp | 12 +++++------- headers/meta.hpp/meta_function.hpp | 2 +- headers/meta.hpp/meta_function_info.hpp | 15 +++++---------- headers/meta.hpp/meta_method.hpp | 2 +- headers/meta.hpp/meta_method_info.hpp | 13 ++++++------- headers/meta.hpp/meta_namespace.hpp | 10 +++++----- headers/meta.hpp/meta_namespace_info.hpp | 16 ++++++++-------- headers/meta.hpp/meta_variable.hpp | 2 +- headers/meta.hpp/meta_variable_info.hpp | 15 +++++---------- 14 files changed, 59 insertions(+), 88 deletions(-) diff --git a/headers/meta.hpp/meta_class.hpp b/headers/meta.hpp/meta_class.hpp index aff8dfb..0e2c4f6 100644 --- a/headers/meta.hpp/meta_class.hpp +++ b/headers/meta.hpp/meta_class.hpp @@ -39,27 +39,27 @@ namespace meta_hpp } private: void add_(const class_info& info) { - detail::merge_with(info_.classes_, info.id(), info, &class_info::merge_with_); + detail::merge_with(info_.classes_, info.id(), info, &class_info::merge); } void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } void add_(const field_info& info) { - detail::merge_with(info_.fields_, info.id(), info, &field_info::merge_with_); + detail::merge_with(info_.fields_, info.id(), info, &field_info::merge); } void add_(const function_info& info) { - detail::merge_with(info_.functions_, info.id(), info, &function_info::merge_with_); + detail::merge_with(info_.functions_, info.id(), info, &function_info::merge); } void add_(const method_info& info) { - detail::merge_with(info_.methods_, info.id(), info, &method_info::merge_with_); + detail::merge_with(info_.methods_, info.id(), info, &method_info::merge); } void add_(const variable_info& info) { - detail::merge_with(info_.variables_, info.id(), info, &variable_info::merge_with_); + detail::merge_with(info_.variables_, info.id(), info, &variable_info::merge); } private: class_info info_; diff --git a/headers/meta.hpp/meta_class_info.hpp b/headers/meta.hpp/meta_class_info.hpp index bc74084..4c2757c 100644 --- a/headers/meta.hpp/meta_class_info.hpp +++ b/headers/meta.hpp/meta_class_info.hpp @@ -104,23 +104,21 @@ namespace meta_hpp std::optional get_variable(std::string_view id) const { return detail::find_opt(variables_, id); } - private: - friend class namespace_info; - template < typename Class > friend class class_; - friend class namespace_; - private: - void merge_with_(const class_info& other) { + void merge(const class_info& other) { if ( fid() != other.fid() ) { throw std::logic_error("class_info::merge failed"); } - detail::merge_with(classes_, other.classes_, &class_info::merge_with_); - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); - detail::merge_with(fields_, other.fields_, &field_info::merge_with_); - detail::merge_with(functions_, other.functions_, &function_info::merge_with_); - detail::merge_with(methods_, other.methods_, &method_info::merge_with_); - detail::merge_with(variables_, other.variables_, &variable_info::merge_with_); + detail::merge_with(classes_, other.classes_, &class_info::merge); + detail::merge_with(datas_, other.datas_, &data_info::merge); + detail::merge_with(fields_, other.fields_, &field_info::merge); + detail::merge_with(functions_, other.functions_, &function_info::merge); + detail::merge_with(methods_, other.methods_, &method_info::merge); + detail::merge_with(variables_, other.variables_, &variable_info::merge); } + private: + template < typename Class > + friend class class_; private: family_id fid_; std::string id_; diff --git a/headers/meta.hpp/meta_data.hpp b/headers/meta.hpp/meta_data.hpp index 14392cf..5dbebec 100644 --- a/headers/meta.hpp/meta_data.hpp +++ b/headers/meta.hpp/meta_data.hpp @@ -32,7 +32,7 @@ namespace meta_hpp } private: void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } private: data_info info_; diff --git a/headers/meta.hpp/meta_data_info.hpp b/headers/meta.hpp/meta_data_info.hpp index e86aa82..c83a0d9 100644 --- a/headers/meta.hpp/meta_data_info.hpp +++ b/headers/meta.hpp/meta_data_info.hpp @@ -43,27 +43,13 @@ namespace meta_hpp std::optional get_data(std::string_view id) const { return detail::find_opt(datas_, id); } - private: - friend class class_info; - friend class field_info; - friend class function_info; - friend class method_info; - friend class namespace_info; - friend class variable_info; - template < typename Class > friend class class_; - template < auto Field > friend class field_; - template < auto Function > friend class function_; - template < auto Method > friend class method_; - friend class namespace_; - template < auto Variable > friend class variable_; - - friend class data_; - private: - void merge_with_(const data_info& other) { + void merge(const data_info& other) { value_ = other.value_; - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); + detail::merge_with(datas_, other.datas_, &data_info::merge); } + private: + friend class data_; private: std::string id_; value value_; diff --git a/headers/meta.hpp/meta_field.hpp b/headers/meta.hpp/meta_field.hpp index 6d3dbdf..61aab5d 100644 --- a/headers/meta.hpp/meta_field.hpp +++ b/headers/meta.hpp/meta_field.hpp @@ -40,7 +40,7 @@ namespace meta_hpp } private: void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } private: field_info info_; diff --git a/headers/meta.hpp/meta_field_info.hpp b/headers/meta.hpp/meta_field_info.hpp index 71e8c24..ed8e534 100644 --- a/headers/meta.hpp/meta_field_info.hpp +++ b/headers/meta.hpp/meta_field_info.hpp @@ -98,18 +98,16 @@ namespace meta_hpp std::optional get_data(std::string_view id) const { return detail::find_opt(datas_, id); } - private: - friend class class_info; - template < typename Class > friend class class_; - template < auto Field > friend class field_; - private: - void merge_with_(const field_info& other) { + void merge(const field_info& other) { if ( fid() != other.fid() ) { throw std::logic_error("field_info::merge failed"); } - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); + detail::merge_with(datas_, other.datas_, &data_info::merge); } + private: + template < auto Field > + friend class field_; private: family_id fid_; std::string id_; diff --git a/headers/meta.hpp/meta_function.hpp b/headers/meta.hpp/meta_function.hpp index 7400ca5..be7ccea 100644 --- a/headers/meta.hpp/meta_function.hpp +++ b/headers/meta.hpp/meta_function.hpp @@ -39,7 +39,7 @@ namespace meta_hpp } private: void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } private: function_info info_; diff --git a/headers/meta.hpp/meta_function_info.hpp b/headers/meta.hpp/meta_function_info.hpp index 7b9dd23..8a4c291 100644 --- a/headers/meta.hpp/meta_function_info.hpp +++ b/headers/meta.hpp/meta_function_info.hpp @@ -103,21 +103,16 @@ namespace meta_hpp std::optional get_data(std::string_view id) const { return detail::find_opt(datas_, id); } - private: - friend class class_info; - friend class namespace_info; - template < typename Class > friend class class_; - friend class namespace_; - - template < auto Function > friend class function_; - private: - void merge_with_(const function_info& other) { + void merge(const function_info& other) { if ( fid() != other.fid() ) { throw std::logic_error("function_info::merge failed"); } - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); + detail::merge_with(datas_, other.datas_, &data_info::merge); } + private: + template < auto Function > + friend class function_; private: family_id fid_; std::string id_; diff --git a/headers/meta.hpp/meta_method.hpp b/headers/meta.hpp/meta_method.hpp index 9a6223f..a509ab9 100644 --- a/headers/meta.hpp/meta_method.hpp +++ b/headers/meta.hpp/meta_method.hpp @@ -40,7 +40,7 @@ namespace meta_hpp } private: void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } private: method_info info_; diff --git a/headers/meta.hpp/meta_method_info.hpp b/headers/meta.hpp/meta_method_info.hpp index f59324b..f36ee9a 100644 --- a/headers/meta.hpp/meta_method_info.hpp +++ b/headers/meta.hpp/meta_method_info.hpp @@ -165,17 +165,16 @@ namespace meta_hpp std::optional get_data(std::string_view id) const { return detail::find_opt(datas_, id); } - private: - friend class class_info; - template < typename Class > friend class class_; - template < auto Method > friend class method_; - private: - void merge_with_(const method_info& other) { + + void merge(const method_info& other) { if ( fid() != other.fid() ) { throw std::logic_error("method_info::merge failed"); } - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); + detail::merge_with(datas_, other.datas_, &data_info::merge); } + private: + template < auto Method > + friend class method_; private: family_id fid_; std::string id_; diff --git a/headers/meta.hpp/meta_namespace.hpp b/headers/meta.hpp/meta_namespace.hpp index c3fd0ce..5ea6740 100644 --- a/headers/meta.hpp/meta_namespace.hpp +++ b/headers/meta.hpp/meta_namespace.hpp @@ -37,23 +37,23 @@ namespace meta_hpp } private: void add_(const class_info& info) { - detail::merge_with(info_.classes_, info.id(), info, &class_info::merge_with_); + detail::merge_with(info_.classes_, info.id(), info, &class_info::merge); } void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } void add_(const function_info& info) { - detail::merge_with(info_.functions_, info.id(), info, &function_info::merge_with_); + detail::merge_with(info_.functions_, info.id(), info, &function_info::merge); } void add_(const namespace_info& info) { - detail::merge_with(info_.namespaces_, info.id(), info, &namespace_info::merge_with_); + detail::merge_with(info_.namespaces_, info.id(), info, &namespace_info::merge); } void add_(const variable_info& info) { - detail::merge_with(info_.variables_, info.id(), info, &variable_info::merge_with_); + detail::merge_with(info_.variables_, info.id(), info, &variable_info::merge); } private: namespace_info info_; diff --git a/headers/meta.hpp/meta_namespace_info.hpp b/headers/meta.hpp/meta_namespace_info.hpp index c8a11f5..07d0985 100644 --- a/headers/meta.hpp/meta_namespace_info.hpp +++ b/headers/meta.hpp/meta_namespace_info.hpp @@ -87,16 +87,16 @@ namespace meta_hpp std::optional get_variable(std::string_view id) const { return detail::find_opt(variables_, id); } + + void merge(const namespace_info& other) { + detail::merge_with(classes_, other.classes_, &class_info::merge); + detail::merge_with(datas_, other.datas_, &data_info::merge); + detail::merge_with(functions_, other.functions_, &function_info::merge); + detail::merge_with(namespaces_, other.namespaces_, &namespace_info::merge); + detail::merge_with(variables_, other.variables_, &variable_info::merge); + } private: friend class namespace_; - private: - void merge_with_(const namespace_info& other) { - detail::merge_with(classes_, other.classes_, &class_info::merge_with_); - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); - detail::merge_with(functions_, other.functions_, &function_info::merge_with_); - detail::merge_with(namespaces_, other.namespaces_, &namespace_info::merge_with_); - detail::merge_with(variables_, other.variables_, &variable_info::merge_with_); - } private: std::string id_; std::map> classes_; diff --git a/headers/meta.hpp/meta_variable.hpp b/headers/meta.hpp/meta_variable.hpp index 6718a0e..ce133ea 100644 --- a/headers/meta.hpp/meta_variable.hpp +++ b/headers/meta.hpp/meta_variable.hpp @@ -38,7 +38,7 @@ namespace meta_hpp } private: void add_(const data_info& info) { - detail::merge_with(info_.datas_, info.id(), info, &data_info::merge_with_); + detail::merge_with(info_.datas_, info.id(), info, &data_info::merge); } private: variable_info info_; diff --git a/headers/meta.hpp/meta_variable_info.hpp b/headers/meta.hpp/meta_variable_info.hpp index 0cc2574..8c0a8b6 100644 --- a/headers/meta.hpp/meta_variable_info.hpp +++ b/headers/meta.hpp/meta_variable_info.hpp @@ -93,21 +93,16 @@ namespace meta_hpp std::optional get_data(std::string_view id) const { return detail::find_opt(datas_, id); } - private: - friend class class_info; - friend class namespace_info; - template < typename Class > friend class class_; - friend class namespace_; - - template < auto Variable > friend class variable_; - private: - void merge_with_(const variable_info& other) { + void merge(const variable_info& other) { if ( fid() != other.fid() ) { throw std::logic_error("variable_info::merge failed"); } - detail::merge_with(datas_, other.datas_, &data_info::merge_with_); + detail::merge_with(datas_, other.datas_, &data_info::merge); } + private: + template < auto Variable > + friend class variable_; private: family_id fid_; std::string id_;