Engine: Update std::stou, remove need for intToHex()
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "inferno/io/gltffile.h"
|
#include "inferno/io/gltffile.h"
|
||||||
#include "inferno/util/json.h"
|
#include "inferno/util/json.h"
|
||||||
#include "inferno/util/string.h"
|
|
||||||
|
|
||||||
namespace Inferno {
|
namespace Inferno {
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ std::pair<std::shared_ptr<char[]>, uint32_t> GltfFile::readChunk(std::ifstream&
|
|||||||
ifstream.read(chunkType, size);
|
ifstream.read(chunkType, size);
|
||||||
|
|
||||||
uint32_t chunkTypeInt = *reinterpret_cast<uint32_t*>(chunkType);
|
uint32_t chunkTypeInt = *reinterpret_cast<uint32_t*>(chunkType);
|
||||||
VERIFY(chunkTypeInt == type, "Gltf invalid chunk type '{}' != '{}'", chunkType, intToHex(type));
|
VERIFY(chunkTypeInt == type, "Gltf invalid chunk type '{}' != '{:#08x}'", chunkType, type);
|
||||||
|
|
||||||
uint32_t chunkLengthInt = *reinterpret_cast<uint32_t*>(chunkLength);
|
uint32_t chunkLengthInt = *reinterpret_cast<uint32_t*>(chunkLength);
|
||||||
// Allocate memory filled with zeros
|
// Allocate memory filled with zeros
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <limits> // std::numeric_limits
|
#include <cstdint> // uint32_t
|
||||||
#include <string> // std::string, std::stoul
|
#include <limits> // std::numeric_limits
|
||||||
|
#include <string> // std::stoul
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#include "ruc/meta/assert.h"
|
#include "ruc/meta/assert.h"
|
||||||
|
|
||||||
@@ -9,16 +11,11 @@ namespace std {
|
|||||||
|
|
||||||
// Can't believe this is not in the standard library
|
// Can't believe this is not in the standard library
|
||||||
|
|
||||||
inline uint32_t stou(const std::string& string)
|
inline uint32_t stou(string_view string)
|
||||||
{
|
{
|
||||||
unsigned long size = std::stoul(string);
|
unsigned long size = std::stoul(string.data());
|
||||||
VERIFY(size <= std::numeric_limits<uint32_t>::max(), "String util not in uint32_t range '{}'", string);
|
VERIFY(size <= std::numeric_limits<uint32_t>::max(), "string not in uint32_t range '{}'", string);
|
||||||
return static_cast<uint32_t>(size);
|
return static_cast<uint32_t>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t stou(const char* string)
|
|
||||||
{
|
|
||||||
return stou(std::string(string));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|||||||
Reference in New Issue
Block a user