btool
A parser/converter/transpiler for .bib files
IdentifierParserState.cpp
Go to the documentation of this file.
1
#include <
IdentifierParserState.hpp
>
2
#include <boost/algorithm/string.hpp>
3
#include <
KeyParserState.hpp
>
4
#include <string>
5
#include <cctype>
6
7
using namespace
std::literals::string_literals;
8
14
IdentifierParserState::IdentifierParserState
(
ParserContext
&context, std::vector<BibElement> &result) noexcept
15
:
AbstractParserState
{context, result} {}
16
23
auto
IdentifierParserState::handleCharacter
(
const
char
c) ->
ParserState
* {
24
if
(c ==
','
) {
25
if
(identifier.empty()) {
26
fail(
"Identifier must not be empty"
s);
27
}
else
{
28
result.back().id = boost::trim_copy(identifier);
29
const
auto
keyState =
new
KeyParserState
{context, result};
30
delete
this
;
31
return
keyState;
32
}
33
}
else
if
(std::isgraph(c)) {
34
identifier += c;
35
return
this
;
36
}
else
{
37
fail(
"Invalid Character in Identifier, got so far: ["
s + identifier +
"]"
s);
38
}
39
}
ParserState
Definition:
ParserState.hpp:7
KeyParserState.hpp
AbstractParserState
Definition:
AbstractParserState.hpp:13
IdentifierParserState::handleCharacter
auto handleCharacter(char c) -> ParserState *override
Definition:
IdentifierParserState.cpp:23
ParserContext
Definition:
ParserContext.hpp:10
KeyParserState
Key Parser State.
Definition:
KeyParserState.hpp:14
IdentifierParserState::IdentifierParserState
IdentifierParserState(ParserContext &context, std::vector< BibElement > &result) noexcept
Definition:
IdentifierParserState.cpp:14
IdentifierParserState.hpp
src
IdentifierParserState.cpp
Generated by
1.8.19