diff --git a/CMakeLists.txt b/CMakeLists.txt index 31b408a..19a5936 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/object2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-object2-facetimpl-printable-string + FACET_PKG xo_printable2 + FACET Printable + REPR String + INPUT idl/IPrintable_DString.json5 + OUTPUT_HPP_DIR include/xo/object2/string + OUTPUT_IMPL_SUBDIR . + OUTPUT_CPP_DIR src/object2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-object2-facetimpl-gcobject-string diff --git a/idl/IPrintable_DString.json5 b/idl/IPrintable_DString.json5 new file mode 100644 index 0000000..f032ca4 --- /dev/null +++ b/idl/IPrintable_DString.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DString", + using_doxygen: true, + repr: "DString", + doc: [ "implement APrintable for DString" ], +} diff --git a/include/xo/object2/string/IPrintable_DString.hpp b/include/xo/object2/string/IPrintable_DString.hpp new file mode 100644 index 0000000..d1d3f22 --- /dev/null +++ b/include/xo/object2/string/IPrintable_DString.hpp @@ -0,0 +1,61 @@ +/** @file IPrintable_DString.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DString.json5] + **/ + +#pragma once + +#include +#include +#include "DString.hpp" + +namespace xo { namespace scm { class IPrintable_DString; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DString + **/ + class IPrintable_DString { + public: + /** @defgroup scm-printable-dstring-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dstring-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DString & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/object2/CMakeLists.txt b/src/object2/CMakeLists.txt index 4c74529..5764d98 100644 --- a/src/object2/CMakeLists.txt +++ b/src/object2/CMakeLists.txt @@ -11,6 +11,7 @@ set(SELF_SRCS IPrintable_DList.cpp IPrintable_DFloat.cpp IPrintable_DInteger.cpp + IPrintable_DString.cpp DList.cpp DFloat.cpp DInteger.cpp diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 8e1b959..6c670cc 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -5,6 +5,7 @@ #include "DInteger.hpp" #include +#include namespace xo { using xo::facet::typeseq; diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index b43d1a9..19e09e1 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -4,6 +4,8 @@ **/ #include "DList.hpp" +#include "IPrintable_DList.hpp" +#include #include #include #include @@ -125,7 +127,9 @@ namespace xo { obj elt = FacetRegistry::instance().variant(l->head_); - assert(elt); + + + assert(elt.data()); if (!pps->print_upto(elt)) return false; diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index 3278d25..517f3f9 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -4,11 +4,13 @@ **/ #include "DString.hpp" +#include #include #include namespace xo { using xo::facet::typeseq; + using xo::print::ppdetail_atomic; namespace scm { DString * @@ -113,6 +115,12 @@ namespace xo { return shallow_size(); } + bool + DString::pretty(const ppindentinfo & ppii) const + { + return ppdetail_atomic::print_pretty(ppii, &(chars_[0])); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/object2/IPrintable_DList.cpp b/src/object2/IPrintable_DList.cpp index 19e5a87..bdcf669 100644 --- a/src/object2/IPrintable_DList.cpp +++ b/src/object2/IPrintable_DList.cpp @@ -12,6 +12,7 @@ **/ #include "IPrintable_DList.hpp" +#include namespace xo { namespace scm { diff --git a/src/object2/IPrintable_DString.cpp b/src/object2/IPrintable_DString.cpp new file mode 100644 index 0000000..f47aa3f --- /dev/null +++ b/src/object2/IPrintable_DString.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DString.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DString.json5] +**/ + +#include "string/IPrintable_DString.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DString::pretty(const DString & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DString.cpp */ diff --git a/src/object2/object2_register_facets.cpp b/src/object2/object2_register_facets.cpp index 8b9e810..9cf6798 100644 --- a/src/object2/object2_register_facets.cpp +++ b/src/object2/object2_register_facets.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); log && log(xtag("DList.tseq", typeseq::id())); log && log(xtag("DFloat.tseq", typeseq::id())); diff --git a/utest/Printable.test.cpp b/utest/Printable.test.cpp index 47bfcf1..c1b63dc 100644 --- a/utest/Printable.test.cpp +++ b/utest/Printable.test.cpp @@ -89,6 +89,8 @@ namespace ut { FacetRegistry::instance().dump(&std::cerr); for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { + log && log("printable1 test:", xtag("i_tc", i_tc)); + try { const testcase_pp & tc = s_testcase_v[i_tc]; @@ -130,7 +132,7 @@ namespace ut { pps.pretty(l0_po); - REQUIRE(ss.str() == string(tc.expected_)); + CHECK(ss.str() == string(tc.expected_)); } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false);