MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
writer.hpp File Reference
#include "mtcore/colls/result.hpp"
#include "mtcore/colls/slice.hpp"
#include "mtcore/colls/slice_algo.hpp"
#include "mtcore/traits.hpp"
#include <functional>
#include <ostream>
#include "format.hpp"
Include dependency graph for io/writer.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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...
 

Namespaces

namespace  mtcore
 Core library for C++ with Zig-related functionality.
 
namespace  mtcore::io
 

Enumerations

enum class  mtcore::io::SliceWriteError { mtcore::io::SliceWriteError::OUT_OF_ROOM }
 Errors when writing to a slice. More...
 
enum class  mtcore::io::VoidWriteError { mtcore::io::VoidWriteError::OUT_OF_ROOM }
 Errors when writing to a slice. More...
 
enum class  mtcore::io::OstreamWriteErr { mtcore::io::OstreamWriteErr::OUT_OF_ROOM }
 Errors when writing to a slice. More...
 

Functions

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.
 
template<WriterImpl WI, typename... Args>
Result< size_t, typename Writer< WI >::ErrType > mtcore::io::print (Writer< WI > &writer, const char *fmt, const Args &...args)
 Prints arguments using a format string Element insert points are designated by a pair of curly braces {} Format parameters can be between the curly braces (e.g.
 
template<WriterImpl WI, typename... Args>
Result< size_t, typename Writer< WI >::ErrType > mtcore::io::print (Writer< WI > &writer, const Slice< const char > &fmt, const Args &...args)
 Prints arguments using a format string Element insert points are designated by a pair of curly braces {} Format parameters can be between the curly braces (e.g.