MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::io Namespace Reference

Namespaces

namespace  floats
 
namespace  readers
 Additional algorithms that can be done on a reader without having to extend the reader type We're encouraging this method of extending readers to avoid readers from becoming incredibly large, and to create a standardized extension mechanism to allow 3rd party extensions of readers.
 

Classes

struct  EnsureFormattable
 
struct  FormatOptions
 Options for specifying formatting. More...
 
struct  Formatter
 Struct to override to specify how a type should be formatted. More...
 
struct  Formatter< char * >
 Format specifier for null-terminated char* (mutable C-strings) Has same format options as template<Iterable T> struct Formatter<T> More...
 
struct  Formatter< char >
 Formatter for characters Format specifier options for output: More...
 
struct  Formatter< const char * >
 Format specifier for null-terminated const char* (C-strings) Has same format options as template<Iterable T> struct Formatter<T> More...
 
struct  Formatter< IPv4 >
 Formats IPv4 addresses No formatting options are available. More...
 
struct  Formatter< IPv6 >
 Formats IPv6 addresses Formatting options: More...
 
struct  Formatter< Optional< T > >
 Formatter for an optional Uses the formatter for the underlying value if available No formatting options. More...
 
struct  Formatter< Result< V, E > >
 Formatter for a result Will check if the value has been moved out of the result Uses the formatter for the underlying value and/or error if available No formatting options. More...
 
struct  Formatter< SubnetMaskV4 >
 Formats subnet v4 masks. More...
 
struct  Formatter< SubnetMaskV6 >
 Formats subnet v4 masks. More...
 
struct  Formatter< SubnetV4 >
 Formats a masked version 4 IP address with a subnet. More...
 
struct  Formatter< SubnetV6 >
 Formats a masked version 6 IP address with a subnet. More...
 
struct  Formatter< T >
 Formats integer numbers (other than char) such as int, unsigned, long long, etc Format specifier options for output: More...
 
struct  Padded
 Formats data with padding into a writer's output stream Uses Formatter<T> under the hood Usually will use extract_padding_options to get padding options. More...
 
struct  PaddingOptions
 Represents parsed padding options for formatting output. More...
 
struct  Reader
 A reader that reads data from some sort of stream or buffer Note: the data elements read should be trivially constructible, trivially destructible, and trivially copyable. More...
 
struct  SyncFileSystem
 Synchronous File System interface for handling I/O calls This is encapsulated as a struct of file pointers so we can do deterministic testing This allows us to also dynamically swap things out for different file systems, or even do remote "file systems" where we're reading and writing to an object store (e.g. More...
 
struct  SyncFileSystemVTable
 VTable for synchronous file system. More...
 
struct  Writer
 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...
 

Typedefs

using FileError = int
 File error.
 

Enumerations

enum class  ContentAlignment { ContentAlignment::LEFT , ContentAlignment::RIGHT , ContentAlignment::CENTER }
 Represents content alignment options for padded formatting options. More...
 
enum class  SliceReaderError { SliceReaderError::END_OF_FILE , SliceReaderError::ALLOCATION_FAILED , SliceReaderError::SIZE_EXCEEDED }
 Errors that can happen from the Slice Reader Note that these are all required by the Reader class as some methods there may allocate. More...
 
enum class  SliceWriteError { SliceWriteError::OUT_OF_ROOM }
 Errors when writing to a slice. More...
 
enum class  VoidWriteError { VoidWriteError::OUT_OF_ROOM }
 Errors when writing to a slice. More...
 
enum class  OstreamWriteErr { OstreamWriteErr::OUT_OF_ROOM }
 Errors when writing to a slice. More...
 

Functions

SyncFileSystem c_filesys ()
 Creates a sync file system based on the C API Uses the 64-bit options where possible (enables >2GB file ops)
 
Optional< PaddingOptionsextract_padding_options (Slice< const char > formatStr)
 Extracts padding options from a format string if present Padding options are in the following form: (padChar)(padDirection)(padLen); Where padChar is the character to pad with (maybe escaped with \ to avoid interpretation as a control character), padDirection is either < for left pad, > for right pad, or ^ for center padding, and padLen is an integer of the minimum length the output should be.
 
template<typename T>
Reader< impl::SliceReaderImpl< T > > slice_reader (Slice< T > buff)
 Creates a reader to read the contents of a Slice.
 
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 > > 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 > > slice_writer (Slice< T > out)
 Creates a writer to write to a Slice.
 
template<typename T>
io::Writer< impl::VoidWriterImpl< T > > 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 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 > 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 > 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 > 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.