SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
Binary.cpp
Go to the documentation of this file.
1
#include <
sourcepp/parser/Binary.h
>
2
3
#include <BufferStream.h>
4
5
using namespace
sourcepp
;
6
7
void
parser::binary::readStringAtOffset
(BufferStream& stream, std::string& str, std::ios::seekdir offsetFrom, std::size_t subtractFromOffset) {
8
const
auto
offset = stream.read<int32_t>();
9
if
(offset == 0) {
10
str =
""
;
11
return
;
12
}
13
14
const
auto
pos = stream.tell();
15
stream.seek(offset -
static_cast<
int64_t
>
(subtractFromOffset), offsetFrom);
16
stream.read(str);
17
stream.seek_u(pos);
18
}
Binary.h
sourcepp::parser::binary::readStringAtOffset
void readStringAtOffset(BufferStream &stream, std::string &str, std::ios::seekdir offsetFrom=std::ios::cur, std::size_t subtractFromOffset=sizeof(int32_t))
Reads an integer from the stream, seeks there, reads a string, and seeks back.
Definition:
Binary.cpp:7
sourcepp
Definition:
LZMA.h:11
src
sourcepp
parser
Binary.cpp
Generated by
1.9.6