btool
A parser/converter/transpiler for .bib files
▼
btool
►
Classes
▼
Files
▼
File List
▼
src
AbstractGenerator.cpp
►
AbstractGenerator.hpp
AbstractParserState.cpp
►
AbstractParserState.hpp
►
BibElement.cpp
►
BibElement.hpp
►
Field.cpp
►
Field.hpp
►
Generator.hpp
GeneratorException.cpp
►
GeneratorException.hpp
GlobalParserState.cpp
►
GlobalParserState.hpp
HtmlGenerator.cpp
►
HtmlGenerator.hpp
IdentifierParserState.cpp
►
IdentifierParserState.hpp
KeyParserState.cpp
►
KeyParserState.hpp
Parser.cpp
►
Parser.hpp
ParserContext.cpp
►
ParserContext.hpp
ParserException.cpp
►
ParserException.hpp
►
ParserState.hpp
PlainTextGenerator.cpp
►
PlainTextGenerator.hpp
StyleParserState.cpp
►
StyleParserState.hpp
StyleProperties.cpp
►
StyleProperties.hpp
TranslationTable.cpp
►
TranslationTable.hpp
ValueParserState.cpp
►
ValueParserState.hpp
XmlGenerator.cpp
►
XmlGenerator.hpp
►
test
►
main.cpp
►
File Members
►
Examples
•
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
PlainTextGenerator.cpp
Go to the documentation of this file.
1
#include <
PlainTextGenerator.hpp
>
2
#include <string>
3
9
auto
PlainTextGenerator::write
() -> std::string {
10
if
(elements.empty()) fail(
"Cannot output empty results."
,
""
);
11
std::string result;
12
for
(
const
auto
&element : elements){
13
std::string repr =
"@"
+ element.style +
"{"
+ element.id +
",\n"
;
14
for
(
const
auto
&key : sortedFields(element.attributes)){
15
repr +=
"\t"
+ key.name +
" = "
+ key.value +
",\n"
;
16
}
17
repr +=
"}\n"
;
18
result += repr;
19
}
20
return
result;
21
}
22
27
auto
PlainTextGenerator::fail
(
const
std::string &message,
const
std::string &type) ->
void
{
28
AbstractGenerator::fail
(message,
"plain-text"
);
29
}
30
31
PlainTextGenerator::PlainTextGenerator
(
const
std::vector<BibElement> &elements) :
AbstractGenerator
{
elements
} {};
AbstractGenerator
Definition:
AbstractGenerator.hpp:14
PlainTextGenerator.hpp
AbstractGenerator::fail
virtual auto fail(const std::string &message, const std::string &type="unknown") -> void
Definition:
AbstractGenerator.cpp:12
PlainTextGenerator::fail
auto fail(const std::string &message, const std::string &type) -> void override
Definition:
PlainTextGenerator.cpp:27
PlainTextGenerator::PlainTextGenerator
PlainTextGenerator(const std::vector< BibElement > &elements)
Definition:
PlainTextGenerator.cpp:31
PlainTextGenerator::write
auto write() -> std::string override
Definition:
PlainTextGenerator.cpp:9
AbstractGenerator::elements
std::vector< BibElement > elements
Elements to write.
Definition:
AbstractGenerator.hpp:16
src
PlainTextGenerator.cpp
Generated by
1.8.19