Skip to content

Commit 42bc688

Browse files
fix: update binaryio
1 parent 11e158c commit 42bc688

31 files changed

Lines changed: 276 additions & 185 deletions

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.26)
22
project(LCE VERSION 1.2.4)
33

4-
set(VERSION_SUFFIX "-dev.2") # used for non-stable versions
4+
set(VERSION_SUFFIX "-dev.3") # used for non-stable versions
55
set(CMAKE_CXX_STANDARD 17)
66

77
message(STATUS "${CMAKE_SYSTEM_PROCESSOR}")
@@ -69,6 +69,7 @@ set(HEADERS
6969
include/LCE/soundbank/BinkaFile.h
7070
# Other
7171
include/LCE/compression/Compression.h
72+
include/LCE/util/StringUtilities.h
7273
# Filesystem
7374
include/LCE/filesystem/FSObject.h
7475
include/LCE/filesystem/Directory.h
@@ -100,6 +101,7 @@ set(FILES
100101
src/filesystem/File.cpp
101102
src/filesystem/Directory.cpp
102103
src/io/Serializable.cpp
104+
src/util/StringUtilities.cpp
103105
)
104106

105107
option(ENABLE_OPTIMIZATIONS "Enable compiler optimizations" OFF)

include/LCE/color/Color.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "LCE/libLCE.h"
1010
#include <string>
1111

12-
#include <BinaryIO/BinaryIO.h>
12+
#include <BinaryIO/BinaryBuffer.h>
1313

1414
namespace lce::color {
1515
/** ARGB Color structure */
@@ -36,8 +36,8 @@ namespace lce::color {
3636

3737
explicit Color(uint8_t *data);
3838
explicit Color(std::vector<uint8_t> &data);
39-
explicit Color(bio::BinaryIO &&io);
40-
explicit Color(bio::BinaryIO &io);
39+
explicit Color(bio::BinaryBuffer &&io);
40+
explicit Color(bio::BinaryBuffer &io);
4141

4242
std::uint8_t *serialize() const override;
4343
size_t getSize() const override;
@@ -54,8 +54,8 @@ namespace lce::color {
5454

5555
explicit WorldColor(uint8_t *data);
5656
explicit WorldColor(std::vector<uint8_t> &data);
57-
explicit WorldColor(bio::BinaryIO &&io);
58-
explicit WorldColor(bio::BinaryIO &io);
57+
explicit WorldColor(bio::BinaryBuffer &&io);
58+
explicit WorldColor(bio::BinaryBuffer &io);
5959

6060
uint8_t *serialize() const override;
6161
size_t getSize() const override;

include/LCE/color/ColorFile.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ namespace lce::color {
9494
const std::unordered_map<std::string, WorldColor> &worldColors)
9595
: ColorFileCommons(colors, 4), mWorldColors(worldColors) {}
9696

97-
explicit ColorFile(uint8_t *data) : ColorFile(bio::BinaryIO(data)) {}
97+
explicit ColorFile(uint8_t *data) : ColorFile(bio::BinaryBuffer(data)) {}
9898
explicit ColorFile(std::vector<uint8_t> &data)
99-
: ColorFile(bio::BinaryIO(data.data())) {}
100-
explicit ColorFile(bio::BinaryIO &&io) : ColorFile(io) {};
101-
explicit ColorFile(bio::BinaryIO &io);
99+
: ColorFile(bio::BinaryBuffer(data.data())) {}
100+
explicit ColorFile(bio::BinaryBuffer &&io) : ColorFile(io) {};
101+
explicit ColorFile(bio::BinaryBuffer &io);
102102

103103
void addWorldColor(const std::string &name, WorldColor color);
104104

@@ -141,12 +141,12 @@ namespace lce::color {
141141
uint32_t version);
142142

143143
explicit ColorFileOld(uint8_t *data)
144-
: ColorFileOld(bio::BinaryIO(data)) {}
144+
: ColorFileOld(bio::BinaryBuffer(data)) {}
145145
explicit ColorFileOld(std::vector<uint8_t> &data)
146-
: ColorFileOld(bio::BinaryIO(data.data())) {}
146+
: ColorFileOld(bio::BinaryBuffer(data.data())) {}
147147

148-
explicit ColorFileOld(bio::BinaryIO &&io) : ColorFileOld(io) {};
149-
explicit ColorFileOld(bio::BinaryIO &io);
148+
explicit ColorFileOld(bio::BinaryBuffer &&io) : ColorFileOld(io) {};
149+
explicit ColorFileOld(bio::BinaryBuffer &io);
150150

151151
uint8_t *serialize() const override;
152152
size_t getSize() const override;

include/LCE/compression/Compression.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <vector>
99

1010
#include "LCE/libLCE.h"
11-
#include <BinaryIO/BinaryIO.h>
11+
#include <BinaryIO/BinaryBuffer.h>
1212

1313
namespace lce::compression {
1414
/** Compression methods
@@ -103,8 +103,9 @@ namespace lce::compression {
103103
std::vector<uint8_t> &out, Type type);
104104

105105
/** @returns The compressed save file's size */
106-
static uint32_t getCompressedSaveFileSize(std::vector<uint8_t> &in,
107-
bio::ByteOrder byteOrder);
106+
static uint32_t
107+
getCompressedSaveFileSize(std::vector<uint8_t> &in,
108+
bio::util::ByteOrder byteOrder);
108109
};
109110

110111
} // namespace lce::compression

include/LCE/filesystem/Filesystem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
namespace lce::fs {
1717

18+
// TODO I would like to move this to it's own lib, and make use of file
19+
// streams and such this could allow for one interface for both physical and
20+
// virtual files. e.g. having a file that holds a handle/stream of a file on
21+
// the user's physical hard disk.
22+
1823
/** Contains a root folder and helper methods for traversing the filesystem
1924
*
2025
* Can be extended to make custom filesystem types

include/LCE/localization/Language.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "LCE/io/Serializable.h"
99

1010
#include "LCE/libLCE.h"
11-
#include <BinaryIO/BinaryIO.h>
11+
#include <BinaryIO/BinaryBuffer.h>
1212

1313
#include <functional>
1414
#include <string>
@@ -44,10 +44,10 @@ namespace lce::loc {
4444
const std::string &getName() const { return mName; }
4545

4646
std::uint8_t *serialize() const override {
47-
bio::BinaryIO io(this->getSize());
47+
bio::BinaryBuffer io(this->getSize());
4848

4949
io.writeBE<uint16_t>(mName.size());
50-
io.writeString(mName);
50+
io.writeString(mName, false);
5151
io.writeBE<uint32_t>(mId);
5252

5353
return io.getData();
@@ -62,7 +62,7 @@ namespace lce::loc {
6262
uint32_t mId;
6363
};
6464

65-
explicit Language(bio::BinaryIO &io, std::vector<uint32_t> &keys);
65+
explicit Language(bio::BinaryBuffer &io, std::vector<uint32_t> &keys);
6666

6767
Language(const uint8_t _byte, const uint32_t _shouldReadByte,
6868
std::string _code, std::vector<uint32_t> &keys)

include/LCE/save/SaveFile.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <vector>
1111

1212
#include "LCE/save/SaveFileCommons.h"
13-
#include <BinaryIO/BinaryIO.h>
13+
#include <BinaryIO/BinaryBuffer.h>
1414

1515
namespace lce::save {
1616
/**
@@ -53,17 +53,20 @@ namespace lce::save {
5353
class LIBLCE_API SaveFile final : public SaveFileCommons {
5454
public:
5555
/** Creates a save file */
56-
explicit SaveFile(bio::ByteOrder byteOrder = bio::ByteOrder::LITTLE,
57-
uint16_t origVersion = 11, uint16_t version = 11);
56+
explicit SaveFile(
57+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::LITTLE,
58+
uint16_t origVersion = 11, uint16_t version = 11);
5859

5960
/** Creates a save file with the contents of a physical folder */
60-
explicit SaveFile(const Filesystem &fs,
61-
bio::ByteOrder byteOrder = bio::ByteOrder::LITTLE,
62-
uint16_t origVersion = 11, uint16_t version = 11);
61+
explicit SaveFile(
62+
const Filesystem &fs,
63+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::LITTLE,
64+
uint16_t origVersion = 11, uint16_t version = 11);
6365

6466
/** Creates a save file from serialized data */
65-
explicit SaveFile(std::vector<uint8_t> data,
66-
bio::ByteOrder byteOrder = bio::ByteOrder::LITTLE);
67+
explicit SaveFile(
68+
std::vector<uint8_t> data,
69+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::LITTLE);
6770

6871
uint8_t *serialize() const override;
6972

include/LCE/save/SaveFileCommons.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "LCE/filesystem/Filesystem.h"
1010
#include "LCE/libLCE.h"
11-
#include <BinaryIO/BinaryIO.h>
11+
#include <BinaryIO/BinaryBuffer.h>
1212
#include <optional>
1313
#include <string>
1414
#include <variant>
@@ -49,14 +49,15 @@ namespace lce::save {
4949
public io::Serializable {
5050
protected:
5151
/** Creates a save file with the contents of the given Filesystem */
52-
SaveFileCommons(const Filesystem &fs, const bio::ByteOrder byteOrder,
52+
SaveFileCommons(const Filesystem &fs,
53+
const bio::util::ByteOrder byteOrder,
5354
const uint16_t origVersion = 11,
5455
const uint16_t version = 11)
5556
: Filesystem(fs), mOriginalVersion(origVersion), mVersion(version),
5657
mByteOrder(byteOrder) {};
5758

5859
explicit SaveFileCommons(
59-
const bio::ByteOrder byteOrder = bio::ByteOrder::LITTLE,
60+
const bio::util::ByteOrder byteOrder = bio::util::ByteOrder::LITTLE,
6061
const uint16_t origVersion = 11, const uint16_t version = 11)
6162
: mOriginalVersion(origVersion), mVersion(version),
6263
mByteOrder(byteOrder) {};
@@ -85,16 +86,16 @@ namespace lce::save {
8586
static SaveFileCommons *deserializeAuto(std::vector<uint8_t> &data);
8687

8788
/** @returns The serialized save file's version */
88-
static uint16_t
89-
getVersionFromData(std::vector<uint8_t> &data,
90-
bio::ByteOrder byteOrder = bio::ByteOrder::LITTLE);
89+
static uint16_t getVersionFromData(
90+
std::vector<uint8_t> &data,
91+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::LITTLE);
9192

9293
/** @returns The save file's original version */
9394
[[nodiscard]] uint16_t getOriginalVersion() const;
9495
/** @returns The save file's version */
9596
[[nodiscard]] uint16_t getVersion() const;
9697
/** @returns The save file's byte order (endianness) */
97-
[[nodiscard]] bio::ByteOrder getByteOrder() const;
98+
[[nodiscard]] bio::util::ByteOrder getByteOrder() const;
9899
/** Sets the save file's original version */
99100
void setOriginalVersion(uint16_t version);
100101
/** Sets the save file's version
@@ -104,7 +105,7 @@ namespace lce::save {
104105
*/
105106
void setVersion(uint16_t version);
106107
/** Sets the save file's byte order (endianness) */
107-
void setEndian(bio::ByteOrder byteOrder);
108+
void setEndian(bio::util::ByteOrder byteOrder);
108109

109110
/** Migrates the current save file to the chosen version should there be
110111
* any differences */
@@ -114,7 +115,7 @@ namespace lce::save {
114115
*
115116
* @returns The save file's byte order (endianness)
116117
*/
117-
static bio::ByteOrder detectByteOrder(std::vector<uint8_t> data);
118+
static bio::util::ByteOrder detectByteOrder(std::vector<uint8_t> data);
118119

119120
friend std::wostream &operator<<(std::wostream &wos,
120121
const SaveFileCommons &f) {
@@ -137,7 +138,7 @@ namespace lce::save {
137138
// NOTE: this could be wrong name
138139
uint16_t mOriginalVersion;
139140
uint16_t mVersion;
140-
bio::ByteOrder mByteOrder;
141+
bio::util::ByteOrder mByteOrder;
141142
};
142143
} // namespace lce::save
143144

include/LCE/save/SaveFileOld.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ namespace lce::save {
4848
public:
4949
explicit SaveFileOld(
5050
std::vector<uint8_t> data,
51-
bio::ByteOrder byteOrder =
52-
bio::ByteOrder::BIG); // big endian cuz xb360 was the only
53-
// edition with this format
51+
bio::util::ByteOrder byteOrder =
52+
bio::util::ByteOrder::BIG); // big endian cuz xb360 was the only
53+
// edition with this format
5454

5555
/** Creates an old format save file */
56-
explicit SaveFileOld(bio::ByteOrder byteOrder = bio::ByteOrder::BIG,
57-
uint16_t origVersion = B0033,
58-
uint16_t version = B0033);
56+
explicit SaveFileOld(
57+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::BIG,
58+
uint16_t origVersion = B0033, uint16_t version = B0033);
5959

6060
/** Creates an old format save file with the contents of a physical
6161
* folder
6262
*/
63-
explicit SaveFileOld(const Filesystem &fs,
64-
bio::ByteOrder byteOrder = bio::ByteOrder::BIG,
65-
uint16_t origVersion = B0033,
66-
uint16_t version = B0033);
63+
explicit SaveFileOld(
64+
const Filesystem &fs,
65+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::BIG,
66+
uint16_t origVersion = B0033, uint16_t version = B0033);
6767

6868
SaveFileCommons *migrateVersion(uint16_t version) override;
6969

include/LCE/save/Thumb.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef THUMB_H
66
#define THUMB_H
77
#include "LCE/libLCE.h"
8-
#include <BinaryIO/BinaryIO.h>
8+
#include <BinaryIO/BinaryBuffer.h>
99
#include <string>
1010
#include <unordered_map>
1111
#include <vector>
@@ -24,9 +24,10 @@ namespace lce::save {
2424
*/
2525
class LIBLCE_API Thumb {
2626
public:
27-
explicit Thumb(std::vector<uint8_t> data,
28-
bio::ByteOrder byteOrder = bio::ByteOrder::LITTLE,
29-
int headerSize = 0x100, bool use4ByteWideChar = false);
27+
explicit Thumb(
28+
std::vector<uint8_t> data,
29+
bio::util::ByteOrder byteOrder = bio::util::ByteOrder::LITTLE,
30+
int headerSize = 0x100, bool use4ByteWideChar = false);
3031

3132
[[nodiscard]] std::wstring getWorldName() const;
3233
void setWorldName(const std::wstring &name);

0 commit comments

Comments
 (0)