3rdparty
libpointmatcher
contrib
yaml-cpp-pm
src
scantag.cpp
Go to the documentation of this file.
1
#include "
scanner.h
"
2
#include "
regex.h
"
3
#include "
exp.h
"
4
#include "
yaml-cpp-pm/exceptions.h
"
5
6
namespace
YAML_PM
7
{
8
const
std::string
ScanVerbatimTag
(
Stream
& INPUT)
9
{
10
std::string
tag;
11
12
// eat the start character
13
INPUT.
get
();
14
15
while
(INPUT) {
16
if
(INPUT.
peek
() ==
Keys::VerbatimTagEnd
) {
17
// eat the end character
18
INPUT.
get
();
19
return
tag;
20
}
21
22
int
n =
Exp::URI
().
Match
(INPUT);
23
if
(n <= 0)
24
break
;
25
26
tag += INPUT.
get
(n);
27
}
28
29
throw
ParserException
(INPUT.
mark
(),
ErrorMsg::END_OF_VERBATIM_TAG
);
30
}
31
32
const
std::string
ScanTagHandle
(
Stream
& INPUT,
bool
& canBeHandle)
33
{
34
std::string
tag;
35
canBeHandle =
true
;
36
Mark
firstNonWordChar;
37
38
while
(INPUT) {
39
if
(INPUT.
peek
() ==
Keys::Tag
) {
40
if
(!canBeHandle)
41
throw
ParserException
(firstNonWordChar,
ErrorMsg::CHAR_IN_TAG_HANDLE
);
42
break
;
43
}
44
45
int
n = 0;
46
if
(canBeHandle) {
47
n =
Exp::Word
().
Match
(INPUT);
48
if
(n <= 0) {
49
canBeHandle =
false
;
50
firstNonWordChar = INPUT.
mark
();
51
}
52
}
53
54
if
(!canBeHandle)
55
n =
Exp::Tag
().
Match
(INPUT);
56
57
if
(n <= 0)
58
break
;
59
60
tag += INPUT.
get
(n);
61
}
62
63
return
tag;
64
}
65
66
const
std::string
ScanTagSuffix
(
Stream
& INPUT)
67
{
68
std::string
tag;
69
70
while
(INPUT) {
71
int
n =
Exp::Tag
().
Match
(INPUT);
72
if
(n <= 0)
73
break
;
74
75
tag += INPUT.
get
(n);
76
}
77
78
if
(tag.empty())
79
throw
ParserException
(INPUT.
mark
(),
ErrorMsg::TAG_WITH_NO_SUFFIX
);
80
81
return
tag;
82
}
83
}
84
YAML_PM::ScanTagSuffix
const std::string ScanTagSuffix(Stream &INPUT)
Definition:
scantag.cpp:66
YAML_PM::Stream::peek
char peek() const
Definition:
stream.cpp:228
exceptions.h
YAML_PM::ErrorMsg::END_OF_VERBATIM_TAG
const char *const END_OF_VERBATIM_TAG
Definition:
exceptions.h:28
YAML_PM
Definition:
aliasmanager.h:11
YAML_PM::Keys::Tag
const char Tag
Definition:
exp.h:188
YAML_PM::ScanTagHandle
const std::string ScanTagHandle(Stream &INPUT, bool &canBeHandle)
Definition:
scantag.cpp:32
exp.h
YAML_PM::Stream::get
char get()
Definition:
stream.cpp:245
YAML_PM::Exp::Tag
const RegEx & Tag()
Definition:
exp.h:129
testing::internal::string
::std::string string
Definition:
gtest.h:1979
YAML_PM::ParserException
Definition:
exceptions.h:110
YAML_PM::Exp::URI
const RegEx & URI()
Definition:
exp.h:125
YAML_PM::ErrorMsg::CHAR_IN_TAG_HANDLE
const char *const CHAR_IN_TAG_HANDLE
Definition:
exceptions.h:26
YAML_PM::Keys::VerbatimTagEnd
const char VerbatimTagEnd
Definition:
exp.h:192
regex.h
YAML_PM::ErrorMsg::TAG_WITH_NO_SUFFIX
const char *const TAG_WITH_NO_SUFFIX
Definition:
exceptions.h:27
YAML_PM::RegEx::Match
int Match(const std::string &str) const
Definition:
regeximpl.h:42
YAML_PM::ScanVerbatimTag
const std::string ScanVerbatimTag(Stream &INPUT)
Definition:
scantag.cpp:8
YAML_PM::Mark
Definition:
mark.h:13
YAML_PM::Stream
Definition:
stream.h:20
scanner.h
YAML_PM::Exp::Word
const RegEx & Word()
Definition:
exp.h:54
YAML_PM::Stream::mark
const Mark mark() const
Definition:
stream.h:38
mp2p_icp
Author(s):
autogenerated on Thu Dec 26 2024 03:48:12