#include <cassert>
#include <cerrno>
#include <concepts>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <optional>
#include <span>
#include <string_view>
#include <type_traits>
Go to the source code of this file.
|
std::optional< std::size_t > | read_all (FILE *f, std::size_t size, std::span< char > s) |
| Reads a block of a specific size.
|
|
bool | write_all (FILE *f, std::string_view s) |
| Writes the entire content of s into an output stream.
|
|
bool | process_blocks (FILE *in, FILE *out, std::size_t size, std::span< char > in_s, std::span< char > out_s, ProcessingFunc auto f) |
| Reads block of a specific size, processes them, and outputs.
|
|
◆ process_blocks()
bool process_blocks |
( |
FILE * | in, |
|
|
FILE * | out, |
|
|
std::size_t | size, |
|
|
std::span< char > | in_s, |
|
|
std::span< char > | out_s, |
|
|
ProcessingFunc auto | f ) |
|
inline |
Reads block of a specific size, processes them, and outputs.
Blocks of size
are read from in
, processed through f
, and written to out
. in_s
and out_s
are used as storage.
◆ read_all()
std::optional< std::size_t > read_all |
( |
FILE * | f, |
|
|
std::size_t | size, |
|
|
std::span< char > | s ) |
|
inline |
Reads a block of a specific size.
Fills s
with data read from f
. Reads until the buffer is filled or EOF
, in which case the buffer will be filled with zeroes until it is a multiple of size
in length. s
must also be a multiple of size
in length. Returns the number of bytes read without the added zeroes, or nullopt
in case of errors..
◆ write_all()
bool write_all |
( |
FILE * | f, |
|
|
std::string_view | s ) |
|
inline |
Writes the entire content of s
into an output stream.