1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Introduce std::string_view into wider use (#14368)

This commit is contained in:
sfan5 2024-02-17 15:35:33 +01:00 committed by GitHub
parent fa47af737f
commit 6ca214fefc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 501 additions and 456 deletions

View file

@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h"
#include "exceptions.h"
#include <iostream>
#include "util/pointer.h"
#include <string_view>
/*
Map format serialization version
@ -83,19 +83,27 @@ inline bool ser_ver_supported(s32 v) {
}
/*
Misc. serialization functions
Compression functions
*/
void compressZlib(const u8 *data, size_t data_size, std::ostream &os, int level = -1);
void compressZlib(const std::string &data, std::ostream &os, int level = -1);
inline void compressZlib(std::string_view data, std::ostream &os, int level = -1)
{
compressZlib(reinterpret_cast<const u8*>(data.data()), data.size(), os, level);
}
void decompressZlib(std::istream &is, std::ostream &os, size_t limit = 0);
void compressZstd(const u8 *data, size_t data_size, std::ostream &os, int level = 0);
void compressZstd(const std::string &data, std::ostream &os, int level = 0);
inline void compressZstd(std::string_view data, std::ostream &os, int level = 0)
{
compressZstd(reinterpret_cast<const u8*>(data.data()), data.size(), os, level);
}
void decompressZstd(std::istream &is, std::ostream &os);
// These choose between zlib and a self-made one according to version
void compress(const SharedBuffer<u8> &data, std::ostream &os, u8 version, int level = -1);
void compress(const std::string &data, std::ostream &os, u8 version, int level = -1);
void compress(u8 *data, u32 size, std::ostream &os, u8 version, int level = -1);
// These choose between zstd, zlib and a self-made one according to version
void compress(const u8 *data, u32 size, std::ostream &os, u8 version, int level = -1);
inline void compress(std::string_view data, std::ostream &os, u8 version, int level = -1)
{
compress(reinterpret_cast<const u8*>(data.data()), data.size(), os, version, level);
}
void decompress(std::istream &is, std::ostream &os, u8 version);