DiSMEC++
common.h File Reference

building blocks for io procedures that are used by multiple io subsystems More...

#include <stdexcept>
#include "matrix_types.h"
#include "spdlog/fmt/fmt.h"
#include "utils/throw_error.h"
#include "utils/conversion.h"

Go to the source code of this file.

Classes

struct  dismec::io::MatrixHeader
 Collects the rows and columns parsed from a plain-text matrix file. More...
 
struct  dismec::io::LoLBinarySparse
 Binary Sparse Matrix in List-of-Lists format. More...
 

Namespaces

 dismec
 Main namespace in which all types, classes, and functions are defined.
 
 dismec::io
 
 dismec::io::detail
 

Macros

#define THROW_ERROR(...)   THROW_EXCEPTION(std::runtime_error, __VA_ARGS__)
 

Functions

std::string dismec::io::detail::print_char (char c)
 
long dismec::io::parse_long (const char *string, const char **out)
 
template<class F >
void dismec::io::parse_sparse_vector_from_text (const char *feature_part, F &&callback)
 parses sparse features given in index:value text format. More...
 
std::ostream & dismec::io::write_vector_as_text (std::ostream &stream, const Eigen::Ref< const DenseRealVector > &data)
 Writes the given vector as space-separated human-readable numbers. More...
 
std::istream & dismec::io::read_vector_from_text (std::istream &stream, Eigen::Ref< DenseRealVector > data)
 Reads the given vector as space-separated human-readable numbers. More...
 
template<class T >
void dismec::io::binary_dump (std::streambuf &target, const T *begin, const T *end)
 
template<class T >
void dismec::io::binary_load (std::streambuf &target, T *begin, T *end)
 
MatrixHeader dismec::io::parse_header (const std::string &content)
 
LoLBinarySparse dismec::io::read_binary_matrix_as_lol (std::istream &source)
 

Detailed Description

building blocks for io procedures that are used by multiple io subsystems

This file defines functions that do some generic io procedures, such as parsing or writing single vectors in dense or sparse text format.

Note
This needs to be a macro, because THROW_EXCEPTION automatically captures all variables of the current scope for use in the defined lambda expression.

Definition in file common.h.

Macro Definition Documentation

◆ THROW_ERROR

#define THROW_ERROR (   ...)    THROW_EXCEPTION(std::runtime_error, __VA_ARGS__)

Definition at line 23 of file common.h.