style: aplicar checks modernize-* (215 fixes)
Cambios aplicados:
- [[nodiscard]] añadido a funciones que retornan valores
- .starts_with() en lugar de .find() == 0
- Inicializadores designados {.x=0, .y=0}
- auto en castings obvios
- = default para constructores triviales
- Funciones deleted movidas a public
- std::numbers::pi_v<float> (C++20)
Checks excluidos:
- use-trailing-return-type: Estilo controversial
- avoid-c-arrays: Arrays C aceptables en ciertos contextos
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
|
||||
#include "resource_loader.hpp"
|
||||
|
||||
namespace Resource {
|
||||
namespace Helper {
|
||||
namespace Resource::Helper {
|
||||
|
||||
// Inicialitzar el sistema de recursos
|
||||
bool initializeResourceSystem(const std::string& pack_file, bool fallback) {
|
||||
@@ -79,5 +78,4 @@ bool isPackLoaded() {
|
||||
return Loader::get().isPackLoaded();
|
||||
}
|
||||
|
||||
} // namespace Helper
|
||||
} // namespace Resource
|
||||
} // namespace Resource::Helper
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Resource {
|
||||
namespace Helper {
|
||||
namespace Resource::Helper {
|
||||
|
||||
// Inicialització del sistema
|
||||
bool initializeResourceSystem(const std::string& pack_file, bool fallback);
|
||||
@@ -24,5 +23,4 @@ std::string normalizePath(const std::string& path);
|
||||
// Estat
|
||||
bool isPackLoaded();
|
||||
|
||||
} // namespace Helper
|
||||
} // namespace Resource
|
||||
} // namespace Resource::Helper
|
||||
|
||||
@@ -27,20 +27,20 @@ class Loader {
|
||||
|
||||
// Validació
|
||||
bool validatePack();
|
||||
bool isPackLoaded() const;
|
||||
[[nodiscard]] bool isPackLoaded() const;
|
||||
|
||||
// Estat
|
||||
void setBasePath(const std::string& path);
|
||||
std::string getBasePath() const;
|
||||
|
||||
private:
|
||||
Loader() = default;
|
||||
~Loader() = default;
|
||||
[[nodiscard]] std::string getBasePath() const;
|
||||
|
||||
// No es pot copiar ni moure
|
||||
Loader(const Loader&) = delete;
|
||||
Loader& operator=(const Loader&) = delete;
|
||||
|
||||
private:
|
||||
Loader() = default;
|
||||
~Loader() = default;
|
||||
|
||||
// Dades
|
||||
std::unique_ptr<Pack> pack_;
|
||||
bool fallback_enabled_ = false;
|
||||
|
||||
@@ -41,11 +41,11 @@ class Pack {
|
||||
|
||||
// Accés a recursos
|
||||
std::vector<uint8_t> getResource(const std::string& filename);
|
||||
bool hasResource(const std::string& filename) const;
|
||||
std::vector<std::string> getResourceList() const;
|
||||
[[nodiscard]] bool hasResource(const std::string& filename) const;
|
||||
[[nodiscard]] std::vector<std::string> getResourceList() const;
|
||||
|
||||
// Validació
|
||||
bool validatePack() const;
|
||||
[[nodiscard]] bool validatePack() const;
|
||||
|
||||
private:
|
||||
// Constants
|
||||
@@ -59,7 +59,7 @@ class Pack {
|
||||
|
||||
// Funcions auxiliars
|
||||
std::vector<uint8_t> readFile(const std::string& filepath);
|
||||
uint32_t calculateChecksum(const std::vector<uint8_t>& data) const;
|
||||
[[nodiscard]] uint32_t calculateChecksum(const std::vector<uint8_t>& data) const;
|
||||
void encryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||
void decryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user