Beatmup
|
Parser of simple YAML-like listings. More...
#include <listing.h>
Classes | |
class | Block |
Set of key-value pairs. More... | |
class | Parser |
Public Member Functions | |
Listing () | |
Listing (InputStream &stream) | |
Listing (std::istream &stream) | |
void | printOut (std::ostream &stream) |
Prints out the listing to an output stream. More... | |
bool | has (const std::string &key) const |
Returns true if a specific chapter is present in the listing. More... | |
const std::vector< Block > & | operator[] (const std::string &key) const |
Retrieves a chapter in the listing by its name. More... | |
void | emplace (const std::string &key, Block &&block) |
Adds a block to a chapter. More... | |
Private Attributes | |
std::map< std::string, std::vector< Block > > | chapters |
Parser of simple YAML-like listings.
Listing consists of chapters. Chapters are ordered sequences of blocks of key-value pairs: chapter1:
Listing::Listing | ( | InputStream & | stream | ) |
Definition at line 174 of file listing.cpp.
Listing::Listing | ( | std::istream & | stream | ) |
Definition at line 179 of file listing.cpp.
void Listing::printOut | ( | std::ostream & | stream | ) |
Prints out the listing to an output stream.
Respects its own format when printing, i.e., the printed output may be reparsed into a listing.
[in,out] | stream | The output stream |
Definition at line 184 of file listing.cpp.
|
inline |
const std::vector< Listing::Block > & Listing::operator[] | ( | const std::string & | key | ) | const |
Retrieves a chapter in the listing by its name.
If not found, an exception is thrown.
[in] | key | The chapter name |
Definition at line 192 of file listing.cpp.
void Listing::emplace | ( | const std::string & | key, |
Block && | block | ||
) |
Adds a block to a chapter.
[in] | key | The chapter name |
[in] | block | The block |
Definition at line 200 of file listing.cpp.
|
private |