SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
KV1.cpp
Go to the documentation of this file.
1
#include <
kvpp/KV1.h
>
2
3
using namespace
kvpp
;
4
using namespace
sourcepp
;
5
6
KV1::KV1
(std::string_view kv1Data,
bool
useEscapeSequences_)
7
:
KV1ElementReadable
()
8
, useEscapeSequences(useEscapeSequences_) {
9
if
(kv1Data.empty()) {
10
return
;
11
}
12
BufferStreamReadOnly stream{kv1Data.data(), kv1Data.size()};
13
14
// Multiply by 2 to ensure buffer will have enough space (very generous)
15
this->
backingData
.resize(kv1Data.size() * 2);
16
BufferStream backing{this->
backingData
,
false
};
17
try
{
18
read
(stream, backing, this->
children
, this->
useEscapeSequences
?
parser::text::DEFAULT_ESCAPE_SEQUENCES
:
parser::text::NO_ESCAPE_SEQUENCES
);
19
}
catch
(
const
std::overflow_error&) {}
20
}
KV1.h
kvpp::KV1ElementBase< std::string_view, KV1ElementReadable >::read
static void read(BufferStreamReadOnly &stream, BufferStream &backing, std::vector< KV1ElementReadable > &elements, const sourcepp::parser::text::EscapeSequenceMap &escapeSequences)
Definition:
KV1.h:137
kvpp::KV1ElementBase< std::string_view, KV1ElementReadable >::children
std::vector< KV1ElementReadable > children
Definition:
KV1.h:179
kvpp::KV1ElementReadable
Definition:
KV1.h:182
kvpp::KV1::KV1
KV1(std::string_view kv1Data, bool useEscapeSequences_=false)
Definition:
KV1.cpp:6
kvpp::KV1::useEscapeSequences
bool useEscapeSequences
Definition:
KV1.h:199
kvpp::KV1::backingData
std::string backingData
Definition:
KV1.h:198
kvpp
Definition:
KV1.h:13
sourcepp::parser::text::NO_ESCAPE_SEQUENCES
const EscapeSequenceMap NO_ESCAPE_SEQUENCES
Definition:
Text.cpp:26
sourcepp::parser::text::DEFAULT_ESCAPE_SEQUENCES
const EscapeSequenceMap DEFAULT_ESCAPE_SEQUENCES
Definition:
Text.cpp:12
sourcepp
Definition:
LZMA.h:11
src
kvpp
KV1.cpp
Generated by
1.9.6