codex
Loading...
Searching...
No Matches
block.hpp File Reference
#include <cassert>
#include <cerrno>
#include <concepts>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <optional>
#include <span>
#include <string_view>
#include <type_traits>
Include dependency graph for block.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Concepts

concept  ProcessingFunc
 Processes an input buffer.
 

Functions

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.
 

Function Documentation

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

Here is the call graph for this function:
Here is the caller graph for this function:

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_all()

bool write_all ( FILE * f,
std::string_view s )
inline

Writes the entire content of s into an output stream.

Here is the call graph for this function:
Here is the caller graph for this function: