Skip to content

Commit

Permalink
Added error message to float parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuprynowicz committed May 22, 2024
1 parent 4b9ddbc commit 1ba6026
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions libraries/model-serializers/src/GLTFSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,27 @@

#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;
}

#define CGLTF_ATOF(str) atof_locale_independent(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
Expand Down

0 comments on commit 1ba6026

Please sign in to comment.