16 extern std::ostream
cnull;
19 extern std::wostream
wcnull;
24 bracketed(std::istream& i,
char lbracket,
char rbracket);
27 template <
typename ValueSet,
typename... Args>
29 conv(
const ValueSet& vs,
const std::string& str, Args&&... args)
30 -> decltype(vs.conv(std::declval<std::istream&>(),
31 std::forward<Args>(args)...))
33 std::istringstream i{str};
36 const auto res = vs.conv(i, std::forward<Args>(args)...);
41 catch (
const std::runtime_error& e)
52 char eat(std::istream& is,
char c);
59 const std::string&
eat(std::istream& is,
const std::string& s);
66 template <
typename... Args>
72 std::getline(is, buf,
'\n');
77 raise(std::forward<Args>(args)...);
79 raise(std::forward<Args>(args)...,
": ",
str_escape(buf));
char eat(std::istream &is, char c)
Check lookahead character and advance.
std::string bracketed(std::istream &i, char lbracket, char rbracket)
Extract the string which is here between lbracket and rbracket.
std::string get_file_contents(const std::string &file)
Return the contents of file.
std::ostream cnull
An narrow-char stream that discards the output.
std::shared_ptr< std::istream > open_input_file(const std::string &file)
Open file for reading and return its autoclosing stream.
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
void skip_space(std::istream &is)
Ignore spaces.
char get_char(std::istream &i)
Read a single char, with possible -escape support.
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
std::wostream wcnull
An wide-char stream that discards the output.
ATTRIBUTE_NORETURN void fail_reading(std::istream &is, Args &&...args)
Throw an exception after failing to read from is.
auto conv(const ValueSet &vs, const std::string &str, Args &&...args) -> decltype(vs.conv(std::declval< std::istream & >(), std::forward< Args >(args)...))
Parse str via vs.conv.
std::shared_ptr< std::ostream > open_output_file(const std::string &file)
Open file for writing and return its autoclosing stream.