Skip to content

Commit d4ba942

Browse files
committed
switch from gsl::span to std::span
1 parent b1f4c49 commit d4ba942

9 files changed

Lines changed: 30 additions & 28 deletions

headers/entryflagdetection.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <span>
4+
35
#include <gsl/gsl>
46

57
namespace uc2
@@ -17,7 +19,7 @@ class EntryFlagDetection
1719
inline bool IsLzmaTexture() const noexcept;
1820

1921
private:
20-
void DetectSpecialTypes( gsl::span<uint8_t> entryData ) noexcept;
22+
void DetectSpecialTypes( std::span<uint8_t> entryData ) noexcept;
2123

2224
private:
2325
bool m_bEncryptedFile;

headers/fsutils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
#include <stdint.h>
44
#include <filesystem>
5-
#include <gsl/gsl>
5+
#include <span>
66
#include <vector>
77

88
namespace fs = std::filesystem;
99

1010
std::pair<bool, std::vector<std::uint8_t>> ReadFileToBuffer(
1111
const fs::path& filePath, uint64_t readLength = 0 );
1212
bool WriteBufferToFile( const fs::path& filePath,
13-
gsl::span<std::uint8_t> buff );
13+
std::span<std::uint8_t> buff );
1414

1515
bool CreateDirIfUnexisting( const fs::path& newDirPath ) noexcept;

headers/miscutils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <cstring>
44
#include <filesystem>
5-
#include <gsl/gsl>
5+
#include <span>
66
#include <string>
77
#include <string_view>
88

@@ -20,7 +20,7 @@ inline size_t GenerateHashFromString( const std::string& str )
2020

2121
template <typename DataType, typename DataSizeType,
2222
typename NoPtrDataType = typename std::remove_pointer<DataType>::type>
23-
inline gsl::span<NoPtrDataType> PairToSpan(
23+
inline std::span<NoPtrDataType> PairToSpan(
2424
std::pair<DataType, DataSizeType> src )
2525
{
2626
return { src.first, src.second };

headers/nodeextractionmgr.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#include <filesystem>
44
#include <unordered_map>
55
#include <vector>
6-
7-
#include <gsl/gsl>
6+
#include <span>
87

98
#include <uc2/pkgfile.hpp>
109

@@ -39,17 +38,17 @@ class NodeExtractionMgr
3938
inline int GetExtractionProgress() const;
4039

4140
// from PkgFileModel
42-
bool ExtractNodes( const gsl::span<ArchiveBaseNode*> targetNodes,
41+
bool ExtractNodes( const std::span<ArchiveBaseNode*> targetNodes,
4342
const fs::path& pkgParentPath );
44-
bool ExtractPackages( gsl::span<uc2::PkgFile*> pkgs,
43+
bool ExtractPackages( std::span<uc2::PkgFile*> pkgs,
4544
const fs::path& pkgParentPath );
4645

4746
bool ExtractSingleFileNode( ArchiveFileNode* pFileNode,
4847
const fs::path& pkgParentPath,
4948
fs::path& outResultPath );
5049

5150
private:
52-
void AddNodes( const gsl::span<ArchiveBaseNode*> nodes,
51+
void AddNodes( const std::span<ArchiveBaseNode*> nodes,
5352
uc2::PkgFile* ownerPkgFile );
5453
void AddFileNode( ArchiveFileNode* pFileNode, uc2::PkgFile* ownerPkgFile,
5554
fs::path nodeParentDir = {} );
@@ -72,7 +71,7 @@ class NodeExtractionMgr
7271

7372
// from PkgFileModel
7473
std::vector<uc2::PkgFile*> GetRequiredPkgFiles(
75-
const gsl::span<ArchiveBaseNode*> nodes );
74+
const std::span<ArchiveBaseNode*> nodes );
7675

7776
private:
7877
std::vector<uint8_t> m_vLoadedPkgFile;

headers/specialfilehandler.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,32 @@
33
#include <cstdint>
44
#include <filesystem>
55
#include <string_view>
6-
7-
#include <gsl/gsl>
6+
#include <span>
87

98
namespace fs = std::filesystem;
109

1110
class SpecialFileHandler
1211
{
1312
public:
14-
SpecialFileHandler( gsl::span<std::uint8_t> fileData, fs::path filePath,
13+
SpecialFileHandler( std::span<std::uint8_t> fileData, fs::path filePath,
1514
bool canDecrypt, bool canDecompress );
1615
~SpecialFileHandler();
1716

1817
public:
19-
gsl::span<std::uint8_t> ProcessData();
18+
std::span<std::uint8_t> ProcessData();
2019
inline fs::path GetNewFilePath() const;
2120

2221
private:
2322
bool IsFileEncrypted() const;
2423
bool IsTextureCompressed() const;
2524

26-
gsl::span<std::uint8_t> DecryptFile();
27-
gsl::span<std::uint8_t> DecompressTexture() const;
25+
std::span<std::uint8_t> DecryptFile();
26+
std::span<std::uint8_t> DecompressTexture() const;
2827

2928
static void FixDecryptedExtension( fs::path& filePath );
3029

3130
private:
32-
gsl::span<std::uint8_t> m_FileData;
31+
std::span<std::uint8_t> m_FileData;
3332
fs::path m_FilePath;
3433

3534
const bool m_bAllowDecryption;

sources/dynpkgfilefactory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <array>
44

55
#include <QDebug>
6+
#include <gsl/gsl>
67

78
#include "fsutils.hpp"
89
#include "miscutils.hpp"

sources/fsutils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <fstream>
44
#include <iostream>
5+
#include <span>
56

67
#include <gsl/gsl>
78

@@ -41,7 +42,7 @@ std::pair<bool, std::vector<uint8_t>> ReadFileToBuffer(
4142
return { true, std::move( res ) };
4243
}
4344

44-
bool WriteBufferToFile( const fs::path& filePath, gsl::span<uint8_t> buff )
45+
bool WriteBufferToFile( const fs::path& filePath, std::span<uint8_t> buff )
4546
{
4647
std::ofstream os( filePath, std::ios::binary );
4748

sources/nodeextractionmgr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ NodeExtractionMgr::NodeExtractionMgr(
2424
{
2525
}
2626

27-
void NodeExtractionMgr::AddNodes( const gsl::span<ArchiveBaseNode*> nodes,
27+
void NodeExtractionMgr::AddNodes( const std::span<ArchiveBaseNode*> nodes,
2828
uc2::PkgFile* ownerPkgFile )
2929
{
3030
std::string szPkgFilename( ownerPkgFile->GetFilename() );
@@ -214,7 +214,7 @@ bool NodeExtractionMgr::WritePkgEntryInternal( uc2::PkgEntry* pEntry,
214214
bool canDecrypt,
215215
bool canDecompress )
216216
{
217-
gsl::span<uint8_t> decryptedBuffer;
217+
std::span<uint8_t> decryptedBuffer;
218218

219219
try
220220
{
@@ -277,7 +277,7 @@ static std::set<std::string_view> GetDirChildrenFiles(
277277
}
278278

279279
std::vector<uc2::PkgFile*> NodeExtractionMgr::GetRequiredPkgFiles(
280-
const gsl::span<ArchiveBaseNode*> nodes )
280+
const std::span<ArchiveBaseNode*> nodes )
281281
{
282282
std::unordered_set<uc2::PkgFile*> uniquePkgFiles;
283283

@@ -315,7 +315,7 @@ std::vector<uc2::PkgFile*> NodeExtractionMgr::GetRequiredPkgFiles(
315315
}
316316

317317
bool NodeExtractionMgr::ExtractNodes(
318-
const gsl::span<ArchiveBaseNode*> targetNodes,
318+
const std::span<ArchiveBaseNode*> targetNodes,
319319
const fs::path& pkgParentPath )
320320
{
321321
auto vPkgFiles = this->GetRequiredPkgFiles( targetNodes );
@@ -353,7 +353,7 @@ bool NodeExtractionMgr::ExtractNodes(
353353
return true;
354354
}
355355

356-
bool NodeExtractionMgr::ExtractPackages( gsl::span<uc2::PkgFile*> pkgs,
356+
bool NodeExtractionMgr::ExtractPackages( std::span<uc2::PkgFile*> pkgs,
357357
const fs::path& pkgParentPath )
358358
{
359359
for ( auto&& pPkgFile : pkgs )

sources/specialfilehandler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "indexkeycollections.hpp"
1111
#include "miscutils.hpp"
1212

13-
SpecialFileHandler::SpecialFileHandler( gsl::span<std::uint8_t> fileData,
13+
SpecialFileHandler::SpecialFileHandler( std::span<std::uint8_t> fileData,
1414
fs::path filePath, bool canDecrypt,
1515
bool canDecompress )
1616
: m_FileData( fileData ), m_FilePath( filePath ),
@@ -20,7 +20,7 @@ SpecialFileHandler::SpecialFileHandler( gsl::span<std::uint8_t> fileData,
2020

2121
SpecialFileHandler::~SpecialFileHandler() {}
2222

23-
gsl::span<std::uint8_t> SpecialFileHandler::ProcessData()
23+
std::span<std::uint8_t> SpecialFileHandler::ProcessData()
2424
{
2525
if ( this->m_bAllowDecryption && this->IsFileEncrypted() )
2626
{
@@ -49,7 +49,7 @@ bool SpecialFileHandler::IsTextureCompressed() const
4949
return bIsCompressedTex;
5050
}
5151

52-
gsl::span<std::uint8_t> SpecialFileHandler::DecryptFile()
52+
std::span<std::uint8_t> SpecialFileHandler::DecryptFile()
5353
{
5454
try
5555
{
@@ -73,7 +73,7 @@ gsl::span<std::uint8_t> SpecialFileHandler::DecryptFile()
7373
return {};
7474
}
7575

76-
gsl::span<std::uint8_t> SpecialFileHandler::DecompressTexture() const
76+
std::span<std::uint8_t> SpecialFileHandler::DecompressTexture() const
7777
{
7878
try
7979
{

0 commit comments

Comments
 (0)