Skip to content

Commit 0b70f21

Browse files
vtfpp: take a path object in ctor/bake methods
1 parent ab533c7 commit 0b70f21

File tree

15 files changed

+81
-79
lines changed

15 files changed

+81
-79
lines changed

include/vtfpp/HOT.h

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

3+
#include <filesystem>
34
#include <cstddef>
45
#include <span>
5-
#include <string>
66
#include <vector>
77

88
#include <sourcepp/Macros.h>
@@ -29,7 +29,7 @@ class HOT {
2929

3030
explicit HOT(std::span<const std::byte> hotData);
3131

32-
explicit HOT(const std::string& hotPath);
32+
explicit HOT(const std::filesystem::path& hotPath);
3333

3434
[[nodiscard]] explicit operator bool() const;
3535

@@ -47,7 +47,7 @@ class HOT {
4747

4848
[[nodiscard]] std::vector<std::byte> bake() const;
4949

50-
bool bake(const std::string& hotPath) const; // NOLINT(*-use-nodiscard)
50+
bool bake(const std::filesystem::path& hotPath) const; // NOLINT(*-use-nodiscard)
5151

5252
protected:
5353
bool opened;

include/vtfpp/PPL.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#pragma once
22

3+
#include <filesystem>
34
#include <cstddef>
45
#include <optional>
56
#include <span>
6-
#include <string>
77
#include <unordered_map>
88
#include <vector>
99

@@ -23,7 +23,7 @@ class PPL {
2323

2424
explicit PPL(std::span<const std::byte> pplData);
2525

26-
explicit PPL(const std::string& pplPath);
26+
explicit PPL(const std::filesystem::path& pplPath);
2727

2828
[[nodiscard]] explicit operator bool() const;
2929

@@ -53,17 +53,17 @@ class PPL {
5353

5454
bool setImage(std::span<const std::byte> imageData, ImageFormat format_, uint32_t width, uint32_t height, uint32_t resizedWidth, uint32_t resizedHeight, uint32_t lod = 0, ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
5555

56-
bool setImage(const std::string& imagePath, uint32_t lod = 0, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
56+
bool setImage(const std::filesystem::path& imagePath, uint32_t lod = 0, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
5757

58-
bool setImage(const std::string& imagePath, uint32_t resizedWidth, uint32_t resizedHeight, uint32_t lod = 0, ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
58+
bool setImage(const std::filesystem::path& imagePath, uint32_t resizedWidth, uint32_t resizedHeight, uint32_t lod = 0, ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
5959

6060
[[nodiscard]] std::vector<std::byte> saveImageToFile(uint32_t lod = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const;
6161

62-
bool saveImageToFile(const std::string& imagePath, uint32_t lod = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
62+
bool saveImageToFile(const std::filesystem::path& imagePath, uint32_t lod = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
6363

6464
[[nodiscard]] std::vector<std::byte> bake();
6565

66-
bool bake(const std::string& pplPath);
66+
bool bake(const std::filesystem::path& pplPath);
6767

6868
protected:
6969
uint32_t version{};

include/vtfpp/PSFrames.h

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

3+
#include <filesystem>
34
#include <span>
4-
#include <string>
55
#include <vector>
66

77
#include <vtfpp/ImageFormats.h>
@@ -15,7 +15,7 @@ class PSFrames {
1515

1616
explicit PSFrames(std::span<const std::byte> psFramesData);
1717

18-
explicit PSFrames(const std::string& psFramesPath);
18+
explicit PSFrames(const std::filesystem::path& psFramesPath);
1919

2020
[[nodiscard]] uint32_t getFrameCount() const;
2121

include/vtfpp/SHT.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#pragma once
22

33
#include <array>
4-
#include <cstddef>
4+
#include <filesystem>
55
#include <span>
6-
#include <string>
76
#include <vector>
87

98
#include <sourcepp/Math.h>
@@ -43,7 +42,7 @@ class SHT {
4342

4443
explicit SHT(std::span<const std::byte> shtData);
4544

46-
explicit SHT(const std::string& shtPath);
45+
explicit SHT(const std::filesystem::path& shtPath);
4746

4847
[[nodiscard]] explicit operator bool() const;
4948

@@ -63,7 +62,7 @@ class SHT {
6362

6463
[[nodiscard]] std::vector<std::byte> bake() const;
6564

66-
bool bake(const std::string& shtPath) const; // NOLINT(*-use-nodiscard)
65+
bool bake(const std::filesystem::path& shtPath) const; // NOLINT(*-use-nodiscard)
6766

6867
protected:
6968
bool opened;

include/vtfpp/TTX.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TTX {
1212

1313
explicit TTX(std::span<const std::byte> tthData, std::span<const std::byte> ttzData = {});
1414

15-
explicit TTX(const std::string& tthPath, const std::string& ttzPath = "");
15+
explicit TTX(const std::filesystem::path& tthPath, const std::filesystem::path& ttzPath = {});
1616

1717
[[nodiscard]] explicit operator bool() const;
1818

@@ -44,7 +44,7 @@ class TTX {
4444

4545
[[nodiscard]] std::pair<std::vector<std::byte>, std::vector<std::byte>> bake() const;
4646

47-
bool bake(const std::string& tthPath, const std::string& ttzPath) const; // NOLINT(*-use-nodiscard)
47+
bool bake(const std::filesystem::path& tthPath, const std::filesystem::path& ttzPath) const; // NOLINT(*-use-nodiscard)
4848

4949
protected:
5050
bool opened = false;

include/vtfpp/VBF.h

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

33
#include <array>
4+
#include <filesystem>
45

56
#include <sourcepp/parser/Binary.h>
67
#include <sourcepp/Macros.h>
@@ -32,7 +33,7 @@ class VBF {
3233

3334
explicit VBF(std::span<const std::byte> vbfData);
3435

35-
explicit VBF(const std::string& vbfPath);
36+
explicit VBF(const std::filesystem::path& vbfPath);
3637

3738
[[nodiscard]] explicit operator bool() const;
3839

include/vtfpp/VTF.h

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

33
#include <array>
44
#include <cstddef>
5+
#include <filesystem>
56
#include <span>
67
#include <string>
8+
#include <string_view>
79
#include <tuple>
810
#include <utility>
911
#include <variant>
@@ -263,7 +265,7 @@ class VTF {
263265

264266
explicit VTF(std::span<const std::byte> vtfData, bool parseHeaderOnly = false);
265267

266-
explicit VTF(const std::string& vtfPath, bool parseHeaderOnly = false);
268+
explicit VTF(const std::filesystem::path& vtfPath, bool parseHeaderOnly = false);
267269

268270
VTF(const VTF& other);
269271

@@ -275,17 +277,17 @@ class VTF {
275277

276278
[[nodiscard]] explicit operator bool() const;
277279

278-
static bool create(std::span<const std::byte> imageData, ImageFormat format, uint16_t width, uint16_t height, const std::string& vtfPath, const CreationOptions& options);
280+
static bool create(std::span<const std::byte> imageData, ImageFormat format, uint16_t width, uint16_t height, const std::filesystem::path& vtfPath, const CreationOptions& options);
279281

280-
static bool create(ImageFormat format, uint16_t width, uint16_t height, const std::string& vtfPath, const CreationOptions& options);
282+
static bool create(ImageFormat format, uint16_t width, uint16_t height, const std::filesystem::path& vtfPath, const CreationOptions& options);
281283

282284
[[nodiscard]] static VTF create(std::span<const std::byte> imageData, ImageFormat format, uint16_t width, uint16_t height, const CreationOptions& options);
283285

284286
[[nodiscard]] static VTF create(ImageFormat format, uint16_t width, uint16_t height, const CreationOptions& options);
285287

286-
static bool create(const std::string& imagePath, const std::string& vtfPath, const CreationOptions& options);
288+
static bool create(const std::filesystem::path& imagePath, const std::filesystem::path& vtfPath, const CreationOptions& options);
287289

288-
[[nodiscard]] static VTF create(const std::string& imagePath, const CreationOptions& options);
290+
[[nodiscard]] static VTF create(const std::filesystem::path& imagePath, const CreationOptions& options);
289291

290292
[[nodiscard]] Platform getPlatform() const;
291293

@@ -414,7 +416,7 @@ class VTF {
414416

415417
void removeExtendedFlagsResource();
416418

417-
void setKeyValuesDataResource(const std::string& value);
419+
void setKeyValuesDataResource(std::string_view value);
418420

419421
void removeKeyValuesDataResource();
420422

@@ -440,11 +442,11 @@ class VTF {
440442

441443
bool setImage(std::span<const std::byte> imageData_, ImageFormat format_, uint16_t width_, uint16_t height_, ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, uint16_t slice = 0, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
442444

443-
bool setImage(const std::string& imagePath, ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, uint16_t slice = 0, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
445+
bool setImage(const std::filesystem::path& imagePath, ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, uint16_t slice = 0, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
444446

445447
[[nodiscard]] std::vector<std::byte> saveImageToFile(uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, uint16_t slice = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const;
446448

447-
bool saveImageToFile(const std::string& imagePath, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, uint16_t slice = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
449+
bool saveImageToFile(const std::filesystem::path& imagePath, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, uint16_t slice = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
448450

449451
[[nodiscard]] bool hasThumbnailData() const;
450452

@@ -456,15 +458,15 @@ class VTF {
456458

457459
void setThumbnail(std::span<const std::byte> imageData_, ImageFormat format_, uint16_t width_, uint16_t height_, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
458460

459-
bool setThumbnail(const std::string& imagePath, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY); // NOLINT(*-use-nodiscard)
461+
bool setThumbnail(const std::filesystem::path& imagePath, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY); // NOLINT(*-use-nodiscard)
460462

461463
void computeThumbnail(ImageConversion::ResizeFilter filter = ImageConversion::ResizeFilter::DEFAULT, float quality = ImageConversion::DEFAULT_COMPRESSED_QUALITY);
462464

463465
void removeThumbnail();
464466

465467
[[nodiscard]] std::vector<std::byte> saveThumbnailToFile(ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const;
466468

467-
bool saveThumbnailToFile(const std::string& imagePath, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
469+
bool saveThumbnailToFile(const std::filesystem::path& imagePath, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
468470

469471
[[nodiscard]] bool hasFallbackData() const;
470472

@@ -480,7 +482,7 @@ class VTF {
480482

481483
[[nodiscard]] std::vector<std::byte> saveFallbackToFile(uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const;
482484

483-
bool saveFallbackToFile(const std::string& imagePath, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
485+
bool saveFallbackToFile(const std::filesystem::path& imagePath, uint8_t mip = 0, uint16_t frame = 0, uint8_t face = 0, ImageConversion::FileFormat fileFormat = ImageConversion::FileFormat::DEFAULT) const; // NOLINT(*-use-nodiscard)
484486

485487
[[nodiscard]] uint8_t getConsoleMipScale() const;
486488

@@ -492,7 +494,7 @@ class VTF {
492494

493495
[[nodiscard]] std::vector<std::byte> bake() const;
494496

495-
bool bake(const std::string& vtfPath) const; // NOLINT(*-use-nodiscard)
497+
bool bake(const std::filesystem::path& vtfPath) const; // NOLINT(*-use-nodiscard)
496498

497499
protected:
498500
static bool createInternal(VTF& writer, CreationOptions options);

0 commit comments

Comments
 (0)