btool
A parser/converter/transpiler for .bib files
TranslationTable Class Reference

api to interact with translation-table resource More...

#include <TranslationTable.hpp>

+ Collaboration diagram for TranslationTable:

Public Member Functions

 TranslationTable (std::optional< std::stringstream > file)
 
 TranslationTable (const std::optional< boost::filesystem::path > &path)
 
auto printAll (std::ostream &out=std::cout) const -> void
 
auto getStyleProperties () const noexcept -> const std::vector< StyleProperties > &
 
auto stylePropertiesOf (const std::string &name) const noexcept -> std::optional< StyleProperties >
 
auto stylePropertiesOf (const std::vector< std::string > &names) const noexcept -> std::vector< StyleProperties >
 

Private Member Functions

auto parseStyles () const -> std::vector< StyleProperties >
 

Static Private Member Functions

static auto parseStyle (const boost::property_tree::ptree &style) noexcept -> StyleProperties
 

Private Attributes

boost::property_tree::ptree contents
 pointer to parsed json-tree More...
 
std::vector< StylePropertiesstyleProperties
 parsed style-properties More...
 

Detailed Description

api to interact with translation-table resource

Handles interaction with the translation-table-file and does parsing of it

Examples
/github/workspace/test/TranslationTableFixtureTest.cpp.

Definition at line 16 of file TranslationTable.hpp.

Constructor & Destructor Documentation

◆ TranslationTable() [1/2]

TranslationTable::TranslationTable ( std::optional< std::stringstream >  file)
explicit

Constructor.

Parameters
filecontents of a file
Exceptions
boost::property_tree::json_parser_errorwhenever file is not JSON compliant

Definition at line 13 of file TranslationTable.cpp.

References contents, parseStyles(), and styleProperties.

+ Here is the call graph for this function:

◆ TranslationTable() [2/2]

TranslationTable::TranslationTable ( const std::optional< boost::filesystem::path > &  path)
explicit

Constructor.

Parameters
pathpath to a translation-table json-file
Exceptions
std::invalid_argumentwhenever path is no regular file or does not exist
boost::property_tree::json_parser_errorwhenever file is not JSON compliant

Definition at line 29 of file TranslationTable.cpp.

References contents, parseStyles(), and styleProperties.

+ Here is the call graph for this function:

Member Function Documentation

◆ getStyleProperties()

auto TranslationTable::getStyleProperties ( ) const -> const std::vector<StyleProperties> &
noexcept

Provides all parsed style-properties

Returns
all parsed style-properties

Definition at line 118 of file TranslationTable.cpp.

References styleProperties.

◆ parseStyle()

auto TranslationTable::parseStyle ( const boost::property_tree::ptree &  style) -> StyleProperties
staticprivatenoexcept

Parses a style from the styles json-pointer

Parameters
stylethe json-pointer to the style
Returns
the parsed style-properties

Definition at line 62 of file TranslationTable.cpp.

References name.

◆ parseStyles()

auto TranslationTable::parseStyles ( ) const -> std::vector<StyleProperties>
private

Parses Styles of a top-level json-pointer (tree according to proposed structure)

Returns
all the parsed style properties
Exceptions
std::logic_errorwhenever the translation-table does not contain styles

Definition at line 97 of file TranslationTable.cpp.

References contents.

Referenced by TranslationTable().

+ Here is the caller graph for this function:

◆ printAll()

auto TranslationTable::printAll ( std::ostream &  out = std::cout) const -> void

Prints the content of contents

Parameters
[out]outthe ostream to print into

Definition at line 53 of file TranslationTable.cpp.

◆ stylePropertiesOf() [1/2]

auto TranslationTable::stylePropertiesOf ( const std::string &  name) const -> std::optional<StyleProperties>
noexcept

Provides style-properties for a specific style

Parameters
namethe style name to get properties for
Returns
(maybe) the properties for the style - None if there are none

Definition at line 127 of file TranslationTable.cpp.

References name, and StyleProperties::name.

◆ stylePropertiesOf() [2/2]

auto TranslationTable::stylePropertiesOf ( const std::vector< std::string > &  names) const -> std::vector<StyleProperties>
noexcept

Provides style-properties for a collection of styles

Parameters
namesthe style names to get properties for
Returns
collection of properties
Note
if names is empty, returns all properties

Definition at line 141 of file TranslationTable.cpp.

Member Data Documentation

◆ contents

boost::property_tree::ptree TranslationTable::contents
private

pointer to parsed json-tree

Definition at line 17 of file TranslationTable.hpp.

Referenced by parseStyles(), and TranslationTable().

◆ styleProperties

std::vector<StyleProperties> TranslationTable::styleProperties
private

parsed style-properties

Definition at line 18 of file TranslationTable.hpp.

Referenced by getStyleProperties(), and TranslationTable().


The documentation for this class was generated from the following files: