public info merge functions

This commit is contained in:
BlackMATov
2021-07-02 05:18:57 +07:00
parent 9495c2a69d
commit e738782c69
14 changed files with 59 additions and 88 deletions

View File

@@ -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_;

View File

@@ -104,23 +104,21 @@ namespace meta_hpp
std::optional<variable_info> 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_;

View File

@@ -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_;

View File

@@ -43,27 +43,13 @@ namespace meta_hpp
std::optional<data_info> 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_;

View File

@@ -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_;

View File

@@ -98,18 +98,16 @@ namespace meta_hpp
std::optional<data_info> 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_;

View File

@@ -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_;

View File

@@ -103,21 +103,16 @@ namespace meta_hpp
std::optional<data_info> 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_;

View File

@@ -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_;

View File

@@ -165,17 +165,16 @@ namespace meta_hpp
std::optional<data_info> 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_;

View File

@@ -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_;

View File

@@ -87,16 +87,16 @@ namespace meta_hpp
std::optional<variable_info> 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<std::string, class_info, std::less<>> classes_;

View File

@@ -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_;

View File

@@ -93,21 +93,16 @@ namespace meta_hpp
std::optional<data_info> 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_;