comparison src/core/byte_stream.cc @ 369:47c9f8502269

*: clang-format all the things I've edited the formatting a bit. Now pointer asterisks (and reference ampersands) are on the variable instead of the type, as well as having newlines for function braces (but nothing else)
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 10:16:02 -0400
parents 99c961c91809
children
comparison
equal deleted inserted replaced
368:6d37a998cf91 369:47c9f8502269
1 #include "core/byte_stream.h" 1 #include "core/byte_stream.h"
2 2
3 ByteStream::ByteStream(std::uint8_t *bytes, std::size_t size) { 3 ByteStream::ByteStream(std::uint8_t *bytes, std::size_t size)
4 {
4 bytes_ = bytes; 5 bytes_ = bytes;
5 size_ = size; 6 size_ = size;
6 } 7 }
7 8
8 void ByteStream::ResetOffset() { 9 void ByteStream::ResetOffset()
10 {
9 offset_ = 0; 11 offset_ = 0;
10 } 12 }
11 13
12 void ByteStream::SetEndianness(ByteStream::ByteOrder endian) { 14 void ByteStream::SetEndianness(ByteStream::ByteOrder endian)
15 {
13 endian_ = endian; 16 endian_ = endian;
14 } 17 }
15 18
16 bool ByteStream::ReadString(std::string& str, std::size_t size) { 19 bool ByteStream::ReadString(std::string &str, std::size_t size)
20 {
17 if (offset_ + size >= size_) 21 if (offset_ + size >= size_)
18 return false; 22 return false;
19 23
20 str.assign(reinterpret_cast<const char *>(bytes_ + offset_), size); 24 str.assign(reinterpret_cast<const char *>(bytes_ + offset_), size);
21 Advance(size); 25 Advance(size);
22 return true; 26 return true;
23 } 27 }
24 28
25 bool ByteStream::Advance(std::size_t amount) { 29 bool ByteStream::Advance(std::size_t amount)
30 {
26 if (offset_ + amount >= size_) 31 if (offset_ + amount >= size_)
27 return false; 32 return false;
28 33
29 offset_ += amount; 34 offset_ += amount;
30 return true; 35 return true;