Kpp Ostream Backends HowTo
---- Ostream Backends HowTo
<< Output Ostream Backends << Output << Kpp c++ ----
How to design a backend ostream
for kpp::print :
Required:
-
The backend ostream should be a class.
-
The class should define virtual destructor.
-
The class has an "using alias" to the buffer-type,
its name should be buffer_type (For example: using buffer_type = std::ostream),
and it should be public.
-
(
-
The backend-ostream is named ostream_type in kpp,
-
the buffer_type is the actual ostream-type,
-
but it is not named ostream_type in kpp.
-
For example, std::ostream can be used as the buffer_type,
-
but std::ostream is not named ostream_type of kpp
-
)
-
It does not require the __buffer created by the buffer_type is Lvalue-reference
or not.
-
.operator<< should be a method of the class as the ostream-operator,
global free function operator<< will be never called.
-
Method operator<< should return a "self-type &"
-
The class should not have any constexpr.
Not required, but helpful:
-
protected self_type
-
Method .data(),
-
Method .cpp_str()
-
Method .begin(), .end(), .operator[](...)
-
How constructor is designed is not limited.
kpp::kspt::ostream
kpp::kspt::ostream_printable
kpp::kspt::register_printable
kpp::print
Up
Kpp Home