SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
Binary.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <fstream>
5#include <string>
6
7#include <sourcepp/Math.h>
8
9class BufferStream;
10
12
18consteval uint32_t makeFourCC(const char fourCC[4]) {
19 return fourCC[0] | (fourCC[1] << 8) | (fourCC[2] << 16) | (fourCC[3] << 24);
20}
21
30void readStringAtOffset(BufferStream& stream, std::string& str, std::ios::seekdir offsetFrom = std::ios::cur, std::size_t subtractFromOffset = sizeof(int32_t));
31
32} // namespace sourcepp::parser::binary
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
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition: Binary.h:18