1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include <cstddef>
#include <vector>
#include <cm/string_view>
#include <cmllpkgc/llpkgc.h>
struct cmPkgConfigValueElement
{
cmPkgConfigValueElement() = default;
cmPkgConfigValueElement(bool isVariable, cm::string_view data);
bool IsVariable;
cm::string_view Data;
};
struct cmPkgConfigEntry
{
cmPkgConfigEntry() = default;
cmPkgConfigEntry(bool isVariable, cm::string_view key);
bool IsVariable;
cm::string_view Key;
std::vector<cmPkgConfigValueElement> Val;
};
class cmPkgConfigParser : llpkgc_t
{
public:
cmPkgConfigParser();
llpkgc_errno_t Parse(char* buf, std::size_t len);
llpkgc_errno_t Finish();
llpkgc_errno_t Finish(char* buf, std::size_t len);
std::vector<cmPkgConfigEntry>& Data() { return Data_; }
private:
int OnSpanNext(const char*, std::size_t len);
static int OnSpanNextTr(llpkgc_t* parser, const char* at, std::size_t len);
int OnKey(const char* at, std::size_t len);
static int OnKeyTr(llpkgc_t* parser, const char* at, std::size_t len);
int OnKeywordComplete();
static int OnKeywordCompleteTr(llpkgc_t* parser);
int OnVariableComplete();
static int OnVariableCompleteTr(llpkgc_t* parser);
int OnValueLiteral(const char* at, std::size_t len);
static int OnValueLiteralTr(llpkgc_t* parser, const char* at,
std::size_t len);
int OnValueLiteralComplete();
static int OnValueLiteralCompleteTr(llpkgc_t* parser);
int OnValueVariable(const char* at, std::size_t len);
static int OnValueVariableTr(llpkgc_t* parser, const char* at,
std::size_t len);
int OnValueVariableComplete();
static int OnValueVariableCompleteTr(llpkgc_t* parser);
llpkgc_settings_t Settings_{
OnKeyTr,
OnValueLiteralTr,
OnValueVariableTr,
nullptr, // on_line_begin
OnKeywordCompleteTr,
OnVariableCompleteTr,
OnValueLiteralCompleteTr,
OnValueVariableCompleteTr,
nullptr, // on_value_complete
nullptr, // on_pkgc_complete
};
const char* Ptr_;
std::size_t Len_;
std::vector<cmPkgConfigEntry> Data_;
};
|