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
// ReSharper disable CppRedundantParentheses
2
3
#pragma once
4
5
#include <cstddef>
6
#include <fstream>
7
#include <string>
8
9
#include <
sourcepp/Math.h
>
10
11
class
BufferStream;
12
13
namespace
sourcepp::parser::binary
{
14
20
[[nodiscard]]
consteval
uint32_t
makeFourCC
(
const
char
fourCC[4]) {
21
return
fourCC[0] | (fourCC[1] << 8) | (fourCC[2] << 16) | (fourCC[3] << 24);
22
}
23
29
[[nodiscard]]
consteval
uint64_t
makeEightCC
(
const
char
eightCC[8]) {
30
return
eightCC[0] | (eightCC[1] << 8) | (eightCC[2] << 16) | (eightCC[3] << 24) | (
static_cast<
uint64_t
>
(eightCC[4]) << 32) | (
static_cast<
uint64_t
>
(eightCC[5]) << 40) | (
static_cast<
uint64_t
>
(eightCC[6]) << 48) | (
static_cast<
uint64_t
>
(eightCC[7]) << 56);
31
}
32
41
void
readStringAtOffset
(BufferStream& stream, std::string& str, std::ios::seekdir offsetFrom = std::ios::cur, std::size_t subtractFromOffset =
sizeof
(int32_t));
42
43
}
// namespace sourcepp::parser::binary
Math.h
sourcepp::parser::binary
Definition
Binary.h:13
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::parser::binary::makeFourCC
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition
Binary.h:20
sourcepp::parser::binary::makeEightCC
consteval uint64_t makeEightCC(const char eightCC[8])
Creates a EightCC identifier from a string of 8 characters.
Definition
Binary.h:29
include
sourcepp
parser
Binary.h
Generated on
for SourcePP by
1.14.0