Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::ca_io_detail Namespace Reference

Functions

template<typename Lattice >
void require_rank2 (const char *fn)
 
std::string trim_copy (const std::string &s)
 
std::string lower_copy (std::string s)
 
bool blank (const std::string &s)
 
ca_size_t parse_size_token (const std::string &s, const char *what)
 
ca_index_t parse_index_token (const std::string &s, const char *what)
 
ca_index_t checked_coord_add (const ca_index_t a, const ca_index_t b, const char *what)
 a + b for coordinates, or std::overflow_error if it does not fit.
 
Array< std::string > split_comment_lines (const std::string &comment)
 
std::string json_escape (const std::string &s)
 
std::string rle_token (ca_size_t n, char glyph)
 
void append_rle_token (std::string &body, ca_size_t n, char glyph)
 
void write_wrapped_rle_body (std::ostream &out, const std::string &body, const std::size_t line_width)
 
std::string header_value (const std::string &line, const std::string &key)
 
void finalise_absolute_pattern (Binary_Cell_Pattern &pattern, const Array< Coord_Vec< 2 > > &absolute, const bool have_extent, const ca_index_t min_row, const ca_index_t min_col, const ca_index_t max_row, const ca_index_t max_col, const char *what)
 
template<typename T >
T parse_scalar (const std::string &token, const char *format)
 
template<typename T >
T parse_json_number (const std::string &s, std::size_t &pos)
 
ca_size_t parse_json_size_field (const std::string &s, const std::string &key)
 
void ensure_stream_ok (const std::ostream &out, const char *fn)
 
template<typename T >
void write_text_scalar (std::ostream &out, const T &value)
 
template<class F >
auto try_parse (F &&parse, const char *context) -> expected< std::invoke_result_t< F & >, std::string >
 Invoke a parser, translating any thrown exception into the error channel of expected.
 

Variables

constexpr ca_index_t Max_Coordinate = std::numeric_limits<ca_index_t>::max()
 Largest coordinate of a cell.
 
constexpr ca_size_t Max_Pattern_Extent = static_cast<ca_size_t>(Max_Coordinate) + 1
 Largest width or height of a pattern: its cells have coordinates from 0 to Max_Coordinate.
 

Function Documentation

◆ append_rle_token()

void Aleph::CA::ca_io_detail::append_rle_token ( std::string &  body,
ca_size_t  n,
char  glyph 
)
inline

Definition at line 413 of file ca-io.H.

References rle_token().

◆ blank()

bool Aleph::CA::ca_io_detail::blank ( const std::string &  s)
inline

Definition at line 288 of file ca-io.H.

◆ checked_coord_add()

ca_index_t Aleph::CA::ca_io_detail::checked_coord_add ( const ca_index_t  a,
const ca_index_t  b,
const char *  what 
)
inline

a + b for coordinates, or std::overflow_error if it does not fit.

Definition at line 347 of file ca-io.H.

References ah_overflow_error_if, and Aleph::and.

◆ ensure_stream_ok()

void Aleph::CA::ca_io_detail::ensure_stream_ok ( const std::ostream &  out,
const char *  fn 
)
inline

Definition at line 562 of file ca-io.H.

References ah_runtime_error_if, ensure_stream_ok(), and out.

Referenced by ensure_stream_ok().

◆ finalise_absolute_pattern()

void Aleph::CA::ca_io_detail::finalise_absolute_pattern ( Binary_Cell_Pattern &  pattern,
const Array< Coord_Vec< 2 > > &  absolute,
const bool  have_extent,
const ca_index_t  min_row,
const ca_index_t  min_col,
const ca_index_t  max_row,
const ca_index_t  max_col,
const char *  what 
)
inline

◆ header_value()

std::string Aleph::CA::ca_io_detail::header_value ( const std::string &  line,
const std::string &  key 
)
inline

Definition at line 450 of file ca-io.H.

References Aleph::eq(), lower_copy(), and trim_copy().

◆ json_escape()

std::string Aleph::CA::ca_io_detail::json_escape ( const std::string &  s)
inline

Definition at line 367 of file ca-io.H.

References out.

◆ lower_copy()

std::string Aleph::CA::ca_io_detail::lower_copy ( std::string  s)
inline

Definition at line 281 of file ca-io.H.

Referenced by header_value().

◆ parse_index_token()

ca_index_t Aleph::CA::ca_io_detail::parse_index_token ( const std::string &  s,
const char *  what 
)
inline

Definition at line 313 of file ca-io.H.

References ah_domain_error_if, ah_overflow_error_if, trim_copy(), and value.

◆ parse_json_number()

template<typename T >
T Aleph::CA::ca_io_detail::parse_json_number ( const std::string &  s,
std::size_t &  pos 
)
inline

Definition at line 516 of file ca-io.H.

References ah_domain_error_if, Aleph::and, and parse_json_number().

Referenced by parse_json_number().

◆ parse_json_size_field()

ca_size_t Aleph::CA::ca_io_detail::parse_json_size_field ( const std::string &  s,
const std::string &  key 
)
inline

Definition at line 543 of file ca-io.H.

References ah_domain_error_if, Aleph::and, parse_json_size_field(), and parse_size_token().

Referenced by parse_json_size_field().

◆ parse_scalar()

template<typename T >
T Aleph::CA::ca_io_detail::parse_scalar ( const std::string &  token,
const char *  format 
)
inline

Definition at line 502 of file ca-io.H.

References ah_domain_error_unless, parse_scalar(), trim_copy(), and value.

Referenced by parse_scalar().

◆ parse_size_token()

ca_size_t Aleph::CA::ca_io_detail::parse_size_token ( const std::string &  s,
const char *  what 
)
inline

Definition at line 296 of file ca-io.H.

References ah_domain_error_if, ah_overflow_error_if, trim_copy(), and value.

Referenced by parse_json_size_field().

◆ require_rank2()

template<typename Lattice >
void Aleph::CA::ca_io_detail::require_rank2 ( const char *  fn)
inline

Definition at line 263 of file ca-io.H.

References Aleph::CA::Lattice< Storage, Boundary >::rank.

◆ rle_token()

std::string Aleph::CA::ca_io_detail::rle_token ( ca_size_t  n,
char  glyph 
)
inline

Definition at line 402 of file ca-io.H.

Referenced by append_rle_token().

◆ split_comment_lines()

Array< std::string > Aleph::CA::ca_io_detail::split_comment_lines ( const std::string &  comment)
inline

Definition at line 355 of file ca-io.H.

References Aleph::Array< T >::append(), and Aleph::Array< T >::clear().

◆ trim_copy()

std::string Aleph::CA::ca_io_detail::trim_copy ( const std::string &  s)
inline

Definition at line 270 of file ca-io.H.

References Aleph::and.

Referenced by header_value(), parse_index_token(), parse_scalar(), and parse_size_token().

◆ try_parse()

template<class F >
auto Aleph::CA::ca_io_detail::try_parse ( F &&  parse,
const char *  context 
) -> expected<std::invoke_result_t<F &>, std::string>

Invoke a parser, translating any thrown exception into the error channel of expected.

The Aleph error macros (ah_*_error) throw types deriving from std::exception, so their message is preserved.

Definition at line 1716 of file ca-io.H.

References try_parse().

Referenced by try_parse().

◆ write_text_scalar()

template<typename T >
void Aleph::CA::ca_io_detail::write_text_scalar ( std::ostream &  out,
const T &  value 
)
inline

Definition at line 568 of file ca-io.H.

References Aleph::and, out, value, and write_text_scalar().

Referenced by write_text_scalar().

◆ write_wrapped_rle_body()

void Aleph::CA::ca_io_detail::write_wrapped_rle_body ( std::ostream &  out,
const std::string &  body,
const std::size_t  line_width 
)
inline

Definition at line 418 of file ca-io.H.

References ah_domain_error_if, Aleph::and, col, and out.

Variable Documentation

◆ Max_Coordinate

constexpr ca_index_t Aleph::CA::ca_io_detail::Max_Coordinate = std::numeric_limits<ca_index_t>::max()
inlineconstexpr

Largest coordinate of a cell.

Definition at line 340 of file ca-io.H.

◆ Max_Pattern_Extent

constexpr ca_size_t Aleph::CA::ca_io_detail::Max_Pattern_Extent = static_cast<ca_size_t>(Max_Coordinate) + 1
inlineconstexpr

Largest width or height of a pattern: its cells have coordinates from 0 to Max_Coordinate.

Definition at line 344 of file ca-io.H.

Referenced by finalise_absolute_pattern().