aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/locale_independent_float.cpp30
-rw-r--r--src/utils/locale_independent_float.hpp3
2 files changed, 22 insertions, 11 deletions
diff --git a/src/utils/locale_independent_float.cpp b/src/utils/locale_independent_float.cpp
index 1f747776..e0015cee 100644
--- a/src/utils/locale_independent_float.cpp
+++ b/src/utils/locale_independent_float.cpp
@@ -38,6 +38,11 @@ namespace usdx
{
}
+ LocaleIndependentFloat::LocaleIndependentFloat(std::string& value)
+ {
+ this->operator=(value);
+ }
+
const float LocaleIndependentFloat::get_value()
{
return this->value;
@@ -60,6 +65,19 @@ namespace usdx
return *this;
}
+ LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::string& value)
+ {
+ std::size_t found = value.find(',');
+ if (found != std::string::npos) {
+ value[found] = '.';
+ }
+
+ std::istringstream str(value);
+ str >> this->value;
+
+ return *this;
+ }
+
std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value)
{
return is >> &float_value;
@@ -70,17 +88,7 @@ namespace usdx
std::string str_value;
is >> str_value;
- std::size_t found = str_value.find(',');
- if (found != std::string::npos) {
- str_value[found] = '.';
- }
-
- std::istringstream str(str_value);
- float value;
- str >> value;
-
- float_value->set_value(value);
-
+ *float_value = str_value;
return is;
}
};
diff --git a/src/utils/locale_independent_float.hpp b/src/utils/locale_independent_float.hpp
index d41fd0fe..82801868 100644
--- a/src/utils/locale_independent_float.hpp
+++ b/src/utils/locale_independent_float.hpp
@@ -37,6 +37,8 @@ namespace usdx
float value;
public:
LocaleIndependentFloat();
+ LocaleIndependentFloat(std::string& value);
+
virtual ~LocaleIndependentFloat();
const float get_value();
@@ -44,6 +46,7 @@ namespace usdx
LocaleIndependentFloat& operator= (const LocaleIndependentFloat& value);
LocaleIndependentFloat& operator= (const float& vaule);
+ LocaleIndependentFloat& operator= (std::string& vaule);
};
std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value);