diff --git a/include/xo/indentlog/print/ppdetail_atomic.hpp b/include/xo/indentlog/print/ppdetail_atomic.hpp index 3f2a3c3f..cc50770a 100644 --- a/include/xo/indentlog/print/ppdetail_atomic.hpp +++ b/include/xo/indentlog/print/ppdetail_atomic.hpp @@ -1,17 +1,17 @@ -/* ppdetail_atomic.hpp +/** @file ppdetail_atomic.hpp * - * author: Roland Conybeare, Jul 2025 - */ + * @author Roland Conybeare, Jul 2025 + **/ #pragma once +#include "ppindentinfo.hpp" #include #include namespace xo { namespace print { struct ppstate; // see pretty.hpp - struct ppindentinfo; // Defining this means ppdetail_atomic -> ppdetail. // For debugging suppress the #define; causes specialization of ppdetail_atomic to be required for every T @@ -22,28 +22,6 @@ namespace xo { // #define ppdetail_atomic ppdetail - struct ppindentinfo { - ppindentinfo(ppstate * pps, std::uint32_t ci0, std::uint32_t indent_width, bool upto) - : pps_{pps}, ci0_{ci0}, ci1_{ci0 + indent_width}, upto_{upto} {} - - ppstate * pps() const { return pps_; } - std::uint32_t ci0_unused() const { return ci0_; } - std::uint32_t ci1() const { return ci1_; } - bool upto() const { return upto_; } - - private: - ppstate * pps_ = nullptr; - /** current indent **/ - std::uint32_t ci0_ = 0; - /** ci0 +1 indent level **/ - std::uint32_t ci1_ = 0; - /** - * true -> print on remainder of current line, unless past right margin - * false -> pretty across across multiple lines - **/ - bool upto_; - }; - /** @class ppdetail * @brief template for opt-in to pretty-printer * diff --git a/include/xo/indentlog/print/ppindentinfo.hpp b/include/xo/indentlog/print/ppindentinfo.hpp new file mode 100644 index 00000000..6137e6f9 --- /dev/null +++ b/include/xo/indentlog/print/ppindentinfo.hpp @@ -0,0 +1,43 @@ +/** @file ppindentinfo.hpp + * + * @author Roland Conybeare, Jul 2025 + **/ + +#pragma once + +#include + +namespace xo { + namespace print { + struct ppstate; + + /** @class ppindentinfo + * @brief pretty-printing state passed down the stack while traversing object graph + **/ + struct ppindentinfo { + ppindentinfo(ppstate * pps, std::uint32_t ci0, std::uint32_t indent_width, bool upto) + : pps_{pps}, ci0_{ci0}, ci1_{ci0 + indent_width}, upto_{upto} {} + + ppstate * pps() const { return pps_; } + std::uint32_t ci0_unused() const { return ci0_; } + std::uint32_t ci1() const { return ci1_; } + bool upto() const { return upto_; } + + private: + /** pretty-printing state. flyweight. See [xo/indentlog/print/pretty.hpp] **/ + ppstate * pps_ = nullptr; + /** current indent **/ + std::uint32_t ci0_ = 0; + /** ci0 +1 indent level **/ + std::uint32_t ci1_ = 0; + /** + * true -> print on remainder of current line, unless past right margin + * false -> pretty across across multiple lines + **/ + bool upto_; + }; + + } +} + +/* end ppindentinfo.hpp */