+ xo-printable2 + build fixes for cmake config
This commit is contained in:
parent
6cdd6c494c
commit
402cf9b852
29 changed files with 724 additions and 72 deletions
21
xo-printable2/include/xo/printable2/Printable.hpp
Normal file
21
xo-printable2/include/xo/printable2/Printable.hpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/** @file Printable.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for facet .hpp file:
|
||||
* [facet.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Printable.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "detail/APrintable.hpp"
|
||||
#include "detail/IPrintable_Any.hpp"
|
||||
#include "detail/IPrintable_Xfer.hpp"
|
||||
#include "detail/RPrintable.hpp"
|
||||
|
||||
/* end Printable.hpp */
|
||||
69
xo-printable2/include/xo/printable2/detail/APrintable.hpp
Normal file
69
xo-printable2/include/xo/printable2/detail/APrintable.hpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/** @file APrintable.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [abstract_facet.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Printable.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
// includes (via {facet_includes})
|
||||
#include <xo/indentlog/print/ppindentinfo.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace print {
|
||||
|
||||
using Copaque = const void *;
|
||||
using Opaque = void *;
|
||||
|
||||
/**
|
||||
Trait for data types that support pretty-printing
|
||||
**/
|
||||
class APrintable {
|
||||
public:
|
||||
/** @defgroup print-printable-type-traits **/
|
||||
///@{
|
||||
// types
|
||||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
///@}
|
||||
|
||||
/** @defgroup print-printable-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** RTTI: unique id# for actual runtime data representation **/
|
||||
virtual typeseq _typeseq() const noexcept = 0;
|
||||
/** Pretty-printing support for this object.
|
||||
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
|
||||
virtual bool pretty(Copaque data, const ppindentinfo & ppii) = 0;
|
||||
|
||||
// nonconst methods
|
||||
///@}
|
||||
}; /*APrintable*/
|
||||
|
||||
/** Implementation IPrintable_DRepr of APrintable for state DRepr
|
||||
* should provide a specialization:
|
||||
*
|
||||
* template <>
|
||||
* struct xo::facet::FacetImplementation<APrintable, DRepr> {
|
||||
* using Impltype = IPrintable_DRepr;
|
||||
* };
|
||||
*
|
||||
* then IPrintable_ImplType<DRepr> --> IPrintable_DRepr
|
||||
**/
|
||||
template <typename DRepr>
|
||||
using IPrintable_ImplType = xo::facet::FacetImplType<APrintable, DRepr>;
|
||||
|
||||
} /*namespace print*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* */
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/** @file IPrintable_Any.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Printable.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "APrintable.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
|
||||
namespace xo { namespace print { class IPrintable_Any; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
|
||||
template <>
|
||||
struct FacetImplementation<xo::print::APrintable,
|
||||
DVariantPlaceholder>
|
||||
{
|
||||
using ImplType = xo::print::IPrintable_Any;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace xo {
|
||||
namespace print {
|
||||
|
||||
/** @class IPrintable_Any
|
||||
* @brief APrintable implementation for empty variant instance
|
||||
**/
|
||||
class IPrintable_Any : public APrintable {
|
||||
public:
|
||||
/** @defgroup print-printable-any-type-traits **/
|
||||
///@{
|
||||
|
||||
/** integer identifying a type **/
|
||||
using typeseq = xo::facet::typeseq;
|
||||
|
||||
///@}
|
||||
/** @defgroup print-printable-any-methods **/
|
||||
///@{
|
||||
|
||||
const APrintable * iface() const { return std::launder(this); }
|
||||
|
||||
// from APrintable
|
||||
|
||||
// const methods
|
||||
typeseq _typeseq() const noexcept override { return s_typeseq; }
|
||||
[[noreturn]] bool pretty(Copaque, const ppindentinfo &) override { _fatal(); }
|
||||
|
||||
// nonconst methods
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
/** @defgraoup print-printable-any-private-methods **/
|
||||
///@{
|
||||
|
||||
[[noreturn]] static void _fatal();
|
||||
|
||||
///@}
|
||||
|
||||
public:
|
||||
/** @defgraoup print-printable-any-member-vars **/
|
||||
///@{
|
||||
|
||||
static typeseq s_typeseq;
|
||||
static bool _valid;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace print */
|
||||
} /*namespace xo */
|
||||
|
||||
/* IPrintable_Any.hpp */
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/** @file IPrintable_Xfer.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Printable.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "APrintable.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace print {
|
||||
/** @class IPrintable_Xfer
|
||||
**/
|
||||
template <typename DRepr, typename IPrintable_DRepr>
|
||||
class IPrintable_Xfer : public APrintable {
|
||||
public:
|
||||
/** @defgroup print-printable-xfer-type-traits **/
|
||||
///@{
|
||||
using Impl = IPrintable_DRepr;
|
||||
///@}
|
||||
|
||||
/** @defgroup print-printable-xfer-methods **/
|
||||
///@{
|
||||
|
||||
static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; }
|
||||
static DRepr & _dcast(Opaque d) { return *(DRepr *)d; }
|
||||
|
||||
// from APrintable
|
||||
|
||||
// const methods
|
||||
int32_t _typeseq() const noexcept override { return s_typeseq; }
|
||||
bool pretty(Copaque data, const ppindentinfo & ppii) override {
|
||||
return I::pretty(_dcast(data), ppii);
|
||||
}
|
||||
|
||||
// non-const methods
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
using I = Impl;
|
||||
|
||||
public:
|
||||
/** @defgraoup print-printable-xfer-member-vars **/
|
||||
///@{
|
||||
|
||||
/** typeseq for template parameter DRepr **/
|
||||
static int32_t s_typeseq;
|
||||
/** true iff satisfies facet implementation **/
|
||||
static bool _valid;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
template <typename DRepr, typename IPrintable_DRepr>
|
||||
int32_t
|
||||
IPrintable_Xfer<DRepr, IPrintable_DRepr>::s_typeseq
|
||||
= xo::facet::typeseq::id<DRepr>();
|
||||
|
||||
template <typename DRepr, typename IPrintable_DRepr>
|
||||
bool
|
||||
IPrintable_Xfer<DRepr, IPrintable_DRepr>::_valid
|
||||
= xo::facet::valid_facet_implementation<APrintable,
|
||||
IPrintable_Xfer>();
|
||||
|
||||
} /*namespace print */
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end IPrintable_Xfer.hpp */
|
||||
77
xo-printable2/include/xo/printable2/detail/RPrintable.hpp
Normal file
77
xo-printable2/include/xo/printable2/detail/RPrintable.hpp
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/** @file RPrintable.hpp
|
||||
*
|
||||
* Generated automagically from ingredients:
|
||||
* 1. code generator:
|
||||
* [/home/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet]
|
||||
* arguments:
|
||||
* --input [idl/Printable.json5]
|
||||
* 2. jinja2 template for abstract facet .hpp file:
|
||||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Printable.json5]
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "APrintable.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace print {
|
||||
|
||||
/** @class RPrintable
|
||||
**/
|
||||
template <typename Object>
|
||||
class RPrintable : public Object {
|
||||
private:
|
||||
using O = Object;
|
||||
|
||||
public:
|
||||
/** @defgroup print-printable-router-type-traits **/
|
||||
///@{
|
||||
using ObjectType = Object;
|
||||
using DataPtr = Object::DataPtr;
|
||||
///@}
|
||||
|
||||
/** @defgroup print-printable-router-ctors **/
|
||||
///@{
|
||||
RPrintable() {}
|
||||
RPrintable(Object::DataPtr data) : Object{std::move(data)} {}
|
||||
|
||||
///@}
|
||||
/** @defgroup print-printable-router-methods **/
|
||||
///@{
|
||||
|
||||
// const methods
|
||||
int32_t _typeseq() const noexcept { return O::iface()->_typeseq(); }
|
||||
bool pretty(const ppindentinfo & ppii) override {
|
||||
return O::iface()->pretty(O::data(), ppii);
|
||||
}
|
||||
|
||||
// non-const methods
|
||||
// << do something for non-const methods >>
|
||||
//
|
||||
|
||||
///@}
|
||||
/** @defgroup print-printable-member-vars **/
|
||||
///@{
|
||||
|
||||
static bool _valid;
|
||||
|
||||
///@}
|
||||
};
|
||||
|
||||
template <typename Object>
|
||||
bool
|
||||
RPrintable<Object>::_valid = xo::facet::valid_object_router<Object>();
|
||||
|
||||
} /*namespace print*/
|
||||
} /*namespace xo*/
|
||||
|
||||
namespace xo { namespace facet {
|
||||
template <typename Object>
|
||||
struct RoutingFor<xo::print::APrintable, Object> {
|
||||
using RoutingType = xo::print::RPrintable<Object>;
|
||||
};
|
||||
} }
|
||||
|
||||
/* end RPrintable.hpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue