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.
2
3#include <BufferStream.h>
4
5using namespace sourcepp;
6
7void 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}
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
Definition: LZMA.h:11