aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-01-18 02:53:09 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:45 +0100
commit8405106cba190ee6e086c52ef1634d07572c3d2b (patch)
treeee4384711e5b3e073423766975cbd547a9a71960
parent9d06ae80cfe008db84991cf69b430c8dc87a0fc1 (diff)
downloadusdx-8405106cba190ee6e086c52ef1634d07572c3d2b.tar.gz
usdx-8405106cba190ee6e086c52ef1634d07572c3d2b.tar.xz
usdx-8405106cba190ee6e086c52ef1634d07572c3d2b.zip
added string constructor and operator= to locale independent float class
-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);