Added error message to float parser

This commit is contained in:
ksuprynowicz 2024-05-22 22:16:22 +02:00
parent 4b9ddbc260
commit 1ba6026a85

View file

@ -16,12 +16,20 @@
#include <sstream>
inline float atof_locale_independent(char *str) {
#include <memory.h>
#include <QtNetwork/QNetworkReply>
#include <hfm/ModelFormatLogging.h>
#include <hfm/HFMSerializer.h>
static float atof_locale_independent(char *str) {
//TODO: Once we have C++17 we can use std::from_chars
std::istringstream streamToParse(str);
streamToParse.imbue(std::locale("C"));
float value = 0.0f;
streamToParse >> value;
float value;
if(!(streamToParse >> value)) {
qDebug(modelformat) << "cgltf: Cannot parse float from string: " << str;
return 0.0f;
}
return value;
}
@ -29,11 +37,6 @@ inline float atof_locale_independent(char *str) {
#include "cgltf.h"
#include <memory.h>
#include <QtNetwork/QNetworkReply>
#include <hfm/ModelFormatLogging.h>
#include <hfm/HFMSerializer.h>
class GLTFSerializer : public QObject, public HFMSerializer {
Q_OBJECT