kblib 0.2.3
General utilities library for modern C++
io.h File Reference

Provides I/O utilities. More...

#include "fakestd.h"
#include "traits.h"
#include <fstream>
#include <functional>
#include <string>
#include <vector>
#include <cstdio>
#include <filesystem>
#include <optional>
#include <iostream>
Include dependency graph for io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kblib::get_manip< F >
 A helper class for wrapping stream manipulators. More...
 
struct  kblib::unicode_widen< T, U >
 
struct  kblib::unicode_widen< char16_t, char32_t >
 
class  kblib::detail_io::basic_teestreambuf< SB1_t, SB2_t >
 
class  kblib::basic_teestream< StreamA, StreamB >
 
struct  kblib::file_deleter< F, D, P >
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  detail_io
 
namespace  kblib::detail_io
 

Macros

#define IF_CONSTEXPR   constexpr
 

Typedefs

template<typename Stream >
using kblib::detail_io::buf_for = std::remove_pointer_t< decltype(std::declval< Stream & >().rdbuf())>
 

Functions

template<typename D = std::string, typename std::enable_if_t< is_contiguous_v< D >, int > = 0>
auto kblib::get_contents (std::istream &in, D &out) -> auto
 
template<typename D = std::string, typename string >
auto kblib::get_file_contents (const string &filename) -> std::optional< D >
 Read the entire contents of a file into a container, such as std::string or std::vector<char>. Note that it will be most efficient to read into contiguous containers, as opposed to non-contiguous containers. More...
 
template<typename D = std::string, typename string >
auto kblib::try_get_file_contents (const string &filename) -> D
 Read the entire contents of a file into a container, such as std::string or std::vector<char>. Note that it will be most efficient to read into contiguous containers, as opposed to non-contiguous containers. More...
 
auto kblib::getline (std::istream &is) -> std::string
 By-value std::getline wrapper. More...
 
auto kblib::eat_word (std::istream &is) -> std::istream &
 Consume all non-spaces to first break, then eat that, too. More...
 
std::istream & kblib::eat_space (std::istream &is)
 Eat spaces, don't eat an extra. More...
 
template<typename CharT , typename Traits >
auto kblib::nl (std::basic_istream< CharT, Traits > &is) -> std::basic_istream< CharT, Traits > &
 Read in spaces until the end of the line is found. More...
 
template<typename CharT >
auto kblib::unformatted_expect (CharT c) -> auto
 Read a character from an input stream only if it equals c. Acts as an UnformattedInputOperation, that is, it will not ignore any leading whitespace. More...
 
template<typename CharT >
auto kblib::expect (CharT c) -> auto
 Read a character from an input stream only if it equals c. Acts as a FormattedInputOperation, that is, leading whitespace is ignored. More...
 
template<typename CharT , typename... O, template< typename, typename... > class string>
auto kblib::get_line (string< CharT, O... > &str) -> auto
 Read a whole line into a std::basic_string-like class template. More...
 
template<typename CharT , typename... O, template< typename, typename... > class string>
auto kblib::get_line (string< CharT, O... > &str, CharT delim) -> auto
 Read a delimited string into a std::basic_string-like class template. More...
 
template<typename F , typename CharT , typename Tr >
std::basic_istream< CharT, Tr > & kblib::operator>> (std::basic_istream< CharT, Tr > &is, get_manip< F > func)
 Actually calls the manipulator. More...
 
template<typename F , typename CharT , typename Tr >
std::basic_ostream< CharT, Tr > & kblib::operator<< (std::basic_ostream< CharT, Tr > &is, get_manip< F > func)
 Actually calls the manipulator. More...
 
template<typename StreamA , typename StreamB >
auto kblib::tee (StreamA &a, StreamB &b) -> basic_teestream< StreamA, StreamB >
 
template<typename File = std::fstream>
auto kblib::scoped_file (const std::filesystem::path &path, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
 
template<typename File = std::fstream>
auto kblib::tmpfile (const std::filesystem::path &path, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
 

Detailed Description

Provides I/O utilities.

Author
killerbee
Date
2019-2021

Definition in file io.h.

Macro Definition Documentation

◆ IF_CONSTEXPR

#define IF_CONSTEXPR   constexpr