diff --git a/schema_salad/tests/cpp_tests/01_single_record.h b/schema_salad/tests/cpp_tests/01_single_record.h index f053df5f..12c01ac9 100644 --- a/schema_salad/tests/cpp_tests/01_single_record.h +++ b/schema_salad/tests/cpp_tests/01_single_record.h @@ -381,8 +381,9 @@ struct MyRecord { }; } -template -example_com::heap_object::~heap_object() = default; +namespace example_com { +template heap_object::~heap_object() = default; +} inline auto example_com::MyRecord::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; @@ -405,12 +406,13 @@ inline void example_com::MyRecord::fromYaml([[maybe_unused]] YAML::Node const& n fromYaml(expandedNode, *name); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecord> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecord> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecord{}; + auto res = ::example_com::MyRecord{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["name"], *res.name); @@ -421,6 +423,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} namespace example_com { template @@ -525,7 +528,7 @@ auto load_document_from_string(std::string document) -> DocumentRootType { return load_document_from_yaml(YAML::Load(document)); } auto load_document(std::filesystem::path path) -> DocumentRootType { - return load_document_from_yaml(YAML::LoadFile(path)); + return load_document_from_yaml(YAML::LoadFile(path.string())); } void store_document(DocumentRootType const& root, std::ostream& ostream, store_config config={}) { auto y = toYaml(root, config); diff --git a/schema_salad/tests/cpp_tests/02_two_records.h b/schema_salad/tests/cpp_tests/02_two_records.h index fd9df17b..9e0cc503 100644 --- a/schema_salad/tests/cpp_tests/02_two_records.h +++ b/schema_salad/tests/cpp_tests/02_two_records.h @@ -391,8 +391,9 @@ struct MyRecordTwo { }; } -template -example_com::heap_object::~heap_object() = default; +namespace example_com { +template heap_object::~heap_object() = default; +} inline auto example_com::MyRecordOne::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; @@ -415,12 +416,13 @@ inline void example_com::MyRecordOne::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *name); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordOne> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordOne> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordOne{}; + auto res = ::example_com::MyRecordOne{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["name"], *res.name); @@ -431,6 +433,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} inline auto example_com::MyRecordTwo::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; auto n = YAML::Node{}; @@ -452,12 +455,13 @@ inline void example_com::MyRecordTwo::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *value); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordTwo> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordTwo> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordTwo{}; + auto res = ::example_com::MyRecordTwo{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["value"], *res.value); @@ -468,6 +472,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} namespace example_com { template @@ -572,7 +577,7 @@ auto load_document_from_string(std::string document) -> DocumentRootType { return load_document_from_yaml(YAML::Load(document)); } auto load_document(std::filesystem::path path) -> DocumentRootType { - return load_document_from_yaml(YAML::LoadFile(path)); + return load_document_from_yaml(YAML::LoadFile(path.string())); } void store_document(DocumentRootType const& root, std::ostream& ostream, store_config config={}) { auto y = toYaml(root, config); diff --git a/schema_salad/tests/cpp_tests/03_simple_inheritance.h b/schema_salad/tests/cpp_tests/03_simple_inheritance.h index f014fba5..38006149 100644 --- a/schema_salad/tests/cpp_tests/03_simple_inheritance.h +++ b/schema_salad/tests/cpp_tests/03_simple_inheritance.h @@ -392,8 +392,9 @@ struct MyRecordTwo }; } -template -example_com::heap_object::~heap_object() = default; +namespace example_com { +template heap_object::~heap_object() = default; +} inline auto example_com::MyRecordOne::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; @@ -416,12 +417,13 @@ inline void example_com::MyRecordOne::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *name); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordOne> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordOne> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordOne{}; + auto res = ::example_com::MyRecordOne{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["name"], *res.name); @@ -432,6 +434,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} inline auto example_com::MyRecordTwo::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; auto n = YAML::Node{}; @@ -455,12 +458,13 @@ inline void example_com::MyRecordTwo::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *value); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordTwo> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordTwo> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordTwo{}; + auto res = ::example_com::MyRecordTwo{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["value"], *res.value); @@ -471,6 +475,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} namespace example_com { template @@ -575,7 +580,7 @@ auto load_document_from_string(std::string document) -> DocumentRootType { return load_document_from_yaml(YAML::Load(document)); } auto load_document(std::filesystem::path path) -> DocumentRootType { - return load_document_from_yaml(YAML::LoadFile(path)); + return load_document_from_yaml(YAML::LoadFile(path.string())); } void store_document(DocumentRootType const& root, std::ostream& ostream, store_config config={}) { auto y = toYaml(root, config); diff --git a/schema_salad/tests/cpp_tests/04_abstract_inheritance.h b/schema_salad/tests/cpp_tests/04_abstract_inheritance.h index fa56263d..bdebbf6c 100644 --- a/schema_salad/tests/cpp_tests/04_abstract_inheritance.h +++ b/schema_salad/tests/cpp_tests/04_abstract_inheritance.h @@ -392,8 +392,9 @@ struct MyRecordTwo }; } -template -example_com::heap_object::~heap_object() = default; +namespace example_com { +template heap_object::~heap_object() = default; +} inline example_com::MyRecordOne::~MyRecordOne() = default; inline auto example_com::MyRecordOne::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { @@ -440,12 +441,13 @@ inline void example_com::MyRecordTwo::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *value); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordTwo> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordTwo> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordTwo{}; + auto res = ::example_com::MyRecordTwo{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["value"], *res.value); @@ -456,6 +458,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} namespace example_com { template @@ -560,7 +563,7 @@ auto load_document_from_string(std::string document) -> DocumentRootType { return load_document_from_yaml(YAML::Load(document)); } auto load_document(std::filesystem::path path) -> DocumentRootType { - return load_document_from_yaml(YAML::LoadFile(path)); + return load_document_from_yaml(YAML::LoadFile(path.string())); } void store_document(DocumentRootType const& root, std::ostream& ostream, store_config config={}) { auto y = toYaml(root, config); diff --git a/schema_salad/tests/cpp_tests/05_specialization.h b/schema_salad/tests/cpp_tests/05_specialization.h index d43a9d1b..a142f5cf 100644 --- a/schema_salad/tests/cpp_tests/05_specialization.h +++ b/schema_salad/tests/cpp_tests/05_specialization.h @@ -410,8 +410,9 @@ struct MyRecordTwo { }; } -template -example_com::heap_object::~heap_object() = default; +namespace example_com { +template heap_object::~heap_object() = default; +} inline auto example_com::FieldRecordA::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; @@ -424,16 +425,18 @@ inline auto example_com::FieldRecordA::toYaml([[maybe_unused]] ::example_com::st inline void example_com::FieldRecordA::fromYaml([[maybe_unused]] YAML::Node const& n) { using ::example_com::fromYaml; } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::FieldRecordA> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::FieldRecordA> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::FieldRecordA{}; + auto res = ::example_com::FieldRecordA{}; return std::nullopt; } }; +} inline auto example_com::FieldRecordB::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; auto n = YAML::Node{}; @@ -445,16 +448,18 @@ inline auto example_com::FieldRecordB::toYaml([[maybe_unused]] ::example_com::st inline void example_com::FieldRecordB::fromYaml([[maybe_unused]] YAML::Node const& n) { using ::example_com::fromYaml; } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::FieldRecordB> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::FieldRecordB> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::FieldRecordB{}; + auto res = ::example_com::FieldRecordB{}; return std::nullopt; } }; +} inline auto example_com::MyRecordOne::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; auto n = YAML::Node{}; @@ -476,12 +481,13 @@ inline void example_com::MyRecordOne::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *name); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordOne> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordOne> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordOne{}; + auto res = ::example_com::MyRecordOne{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["name"], *res.name); @@ -492,6 +498,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} inline auto example_com::MyRecordTwo::toYaml([[maybe_unused]] ::example_com::store_config const& config) const -> YAML::Node { using ::example_com::toYaml; auto n = YAML::Node{}; @@ -523,12 +530,13 @@ inline void example_com::MyRecordTwo::fromYaml([[maybe_unused]] YAML::Node const fromYaml(expandedNode, *value); } } +namespace example_com { template <> -struct example_com::DetectAndExtractFromYaml { - auto operator()(YAML::Node const& n) const -> std::optional { +struct DetectAndExtractFromYaml<::example_com::MyRecordTwo> { + auto operator()(YAML::Node const& n) const -> std::optional<::example_com::MyRecordTwo> { if (!n.IsDefined()) return std::nullopt; if (!n.IsMap()) return std::nullopt; - auto res = example_com::MyRecordTwo{}; + auto res = ::example_com::MyRecordTwo{}; if constexpr (::example_com::IsConstant::value) try { fromYaml(n["name"], *res.name); @@ -545,6 +553,7 @@ struct example_com::DetectAndExtractFromYaml { return std::nullopt; } }; +} namespace example_com { template @@ -649,7 +658,7 @@ auto load_document_from_string(std::string document) -> DocumentRootType { return load_document_from_yaml(YAML::Load(document)); } auto load_document(std::filesystem::path path) -> DocumentRootType { - return load_document_from_yaml(YAML::LoadFile(path)); + return load_document_from_yaml(YAML::LoadFile(path.string())); } void store_document(DocumentRootType const& root, std::ostream& ostream, store_config config={}) { auto y = toYaml(root, config);