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

#include <AbstractGenerator.hpp>

+ Inheritance diagram for AbstractGenerator:
+ Collaboration diagram for AbstractGenerator:

Public Member Functions

 AbstractGenerator (std::vector< BibElement > elements)
 
- Public Member Functions inherited from Generator
virtual ~Generator ()=default
 

Static Public Member Functions

static auto uniqueFieldsOf (const std::vector< BibElement > &values) noexcept -> std::unordered_set< std::string >
 
static auto sortedFields (const std::vector< Field > &set) noexcept -> std::vector< Field >
 

Protected Member Functions

virtual auto fail (const std::string &message, const std::string &type="unknown") -> void
 
auto write () -> std::string override
 

Protected Attributes

std::vector< BibElementelements
 Elements to write. More...
 

Detailed Description

Abstract Class with default-implementation of a File-Writer

Definition at line 14 of file AbstractGenerator.hpp.

Constructor & Destructor Documentation

◆ AbstractGenerator()

AbstractGenerator::AbstractGenerator ( std::vector< BibElement elements)
explicit

Constructor.

Parameters
elementsthe elements to write

Definition at line 23 of file AbstractGenerator.cpp.

References elements.

Member Function Documentation

◆ fail()

auto AbstractGenerator::fail ( const std::string &  message,
const std::string &  type = "unknown" 
) -> void
protectedvirtual

Helper Method to construct sufficient error-messages

Parameters
messagethe message to use
Exceptions
FileWriterException(always)

Reimplemented in XmlGenerator, PlainTextGenerator, and HtmlGenerator.

Definition at line 12 of file AbstractGenerator.cpp.

Referenced by HtmlGenerator::fail(), PlainTextGenerator::fail(), and XmlGenerator::fail().

+ Here is the caller graph for this function:

◆ sortedFields()

auto AbstractGenerator::sortedFields ( const std::vector< Field > &  fields) -> std::vector<Field>
staticnoexcept

Sorts a unordered vector of fields into a vector

Parameters
setthe unordered vector of fields
Returns
the sorted vector of fields

Definition at line 55 of file AbstractGenerator.cpp.

References Field::name.

◆ uniqueFieldsOf()

auto AbstractGenerator::uniqueFieldsOf ( const std::vector< BibElement > &  values) -> std::unordered_set<std::string>
staticnoexcept
Examples
/github/workspace/test/GeneratorFixtureTest.cpp.

Definition at line 33 of file AbstractGenerator.cpp.

References BibElement::attributes.

Referenced by TEST_F().

+ Here is the caller graph for this function:

◆ write()

auto AbstractGenerator::write ( ) -> std::string
overrideprotectedvirtual

Default write-behaviour (do nothing)

Returns
the elements in target format

Implements Generator.

Reimplemented in XmlGenerator, PlainTextGenerator, and HtmlGenerator.

Definition at line 29 of file AbstractGenerator.cpp.

Member Data Documentation

◆ elements

std::vector<BibElement> AbstractGenerator::elements
protected

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