Writers for outputing data.
More...
|
struct | mtcore::io::Writer< Impl > |
| A writer that writes data to some sort of stream or buffer Note: the data elements written should be trivially constructible, trivially destructible, and trivially copyable. More...
|
|
|
template<typename T, WriterImpl WI, typename Err = typename io::Writer<WI>::ErrType, typename FuncType = std::function<Result<size_t, Err>(io::Writer<WI> &, Slice<std::add_const_t<T>>)>> |
io::Writer< impl::WriteTransformer< T, WI, Err, FuncType > > | mtcore::io::write_transformer (io::Writer< WI > &writer, FuncType mapper) |
| A specialized writer that will transform input data before passing it through to another writer Useful for things like adding an extra encoding step or for transforming between endianness.
|
|
template<typename T> |
io::Writer< impl::SliceWriterImpl< T > > | mtcore::io::slice_writer (Slice< T > out) |
| Creates a writer to write to a Slice.
|
|
template<typename T> |
io::Writer< impl::VoidWriterImpl< T > > | mtcore::io::void_writer () |
| Creates a writer which discards what's written (think of it as writer to /dev/null) Useful for doing a dry-run of a complicated write pass to get the size of the final content.
|
|
template<Formattable T> |
auto | mtcore::io::ostream_writer (std::ostream &os) |
| Creates a writer which passes its output to an ostream Useful for compatibility with the C++ standard library.
|
|
template<WriterImpl WI, typename Arg> |
Result< size_t, typename Writer< WI >::ErrType > | mtcore::io::format (Writer< WI > &writer, const FormatOptions &opts, Arg arg) |
| Generic format function which takes a bunch of arguments (of the same type) and formatting options and then outputs the formatted version of those arguments into the writer.
|
|
Writers for outputing data.
◆ format()
template<WriterImpl WI, typename Arg>
Generic format function which takes a bunch of arguments (of the same type) and formatting options and then outputs the formatted version of those arguments into the writer.
Usually you will call this through print()
- See also
- mtcore::print
- Template Parameters
-
WI | Writer implementation |
Arg | Argument to format |
- Parameters
-
writer | writer to output to |
opts | Formatting options |
arg | Argumentsto format |
- Returns
- The number of elements written, or an error
Definition at line 444 of file io/writer.hpp.
◆ ostream_writer()
template<Formattable T>
auto mtcore::io::ostream_writer |
( |
std::ostream & | os | ) |
|
Creates a writer which passes its output to an ostream Useful for compatibility with the C++ standard library.
- Template Parameters
-
- Parameters
-
Definition at line 420 of file io/writer.hpp.
420 {
422 }
A writer that writes data to some sort of stream or buffer Note: the data elements written should be ...
◆ slice_writer()
template<typename T>
io::Writer< impl::SliceWriterImpl< T > > mtcore::io::slice_writer |
( |
Slice< T > | out | ) |
|
Creates a writer to write to a Slice.
- Template Parameters
-
T | Data type to write (should be trivially copyable, constructible, and destructible) |
- Parameters
-
- Returns
- A writer that writes to the Slice
Definition at line 396 of file io/writer.hpp.
◆ void_writer()
template<typename T>
io::Writer< impl::VoidWriterImpl< T > > mtcore::io::void_writer |
( |
| ) |
|
Creates a writer which discards what's written (think of it as writer to /dev/null) Useful for doing a dry-run of a complicated write pass to get the size of the final content.
- Template Parameters
-
- Returns
- A writer that discards input
Definition at line 408 of file io/writer.hpp.
◆ write_transformer()
template<typename T, WriterImpl WI, typename Err = typename io::Writer<WI>::ErrType, typename FuncType = std::function<Result<size_t, Err>(io::Writer<WI> &, Slice<std::add_const_t<T>>)>>
io::Writer< impl::WriteTransformer< T, WI, Err, FuncType > > mtcore::io::write_transformer |
( |
io::Writer< WI > & | writer, |
|
|
FuncType | mapper ) |
A specialized writer that will transform input data before passing it through to another writer Useful for things like adding an extra encoding step or for transforming between endianness.
- Template Parameters
-
T | Element type to write into the outermost writer |
WI | Writer implementation type |
Err | Error type to be returned from FuncType (defaults to Writer<WI>::ErrType) |
FuncType | Function type to transform incoming input before passing through to the underlying writer |
- Parameters
-
writer | Underlying writer where data will ultimately go |
mapper | Mapper to transform the data and pass it to the underlying writer (or filter it out, or whatever) |
- Returns
- A writer
Definition at line 384 of file io/writer.hpp.