diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-11-22 16:41:34 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-11-22 16:41:34 +0100 |
commit | a527cc9e29cae256bd095b032f34c80957e84907 (patch) | |
tree | e68dd547d6a88c188eca4798423adf084ba58124 /src/XMLNode.cpp | |
parent | 6a7b605102f1c22224b516906cb4a848cda50a3b (diff) | |
parent | bd2798bed2fddfe00dac006013a9fb1363417f20 (diff) | |
download | astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.gz astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.bz2 astra-a527cc9e29cae256bd095b032f34c80957e84907.tar.xz astra-a527cc9e29cae256bd095b032f34c80957e84907.zip |
Merge branch 'master' into parallel_vec
Diffstat (limited to 'src/XMLNode.cpp')
-rw-r--r-- | src/XMLNode.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp index 3b7237f..2bf1330 100644 --- a/src/XMLNode.cpp +++ b/src/XMLNode.cpp @@ -30,6 +30,9 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "rapidxml/rapidxml.hpp" #include "rapidxml/rapidxml_print.hpp" +#include <sstream> +#include <iomanip> + using namespace rapidxml; using namespace astra; @@ -376,9 +379,9 @@ void XMLNode::setContent(float32 _fValue) template<typename T> static std::string setContentList_internal(T* pfList, int _iSize) { - std::string str = (_iSize > 0) ? StringUtil::toString(pfList[0]) : ""; - for (int i = 1; i < _iSize; i++) { - str += "," + StringUtil::toString(pfList[i]); + std::string str; + for (int i = 0; i < _iSize; i++) { + str += StringUtil::toString(pfList[i]) + ","; } return str; } @@ -399,8 +402,6 @@ void XMLNode::setContent(double* pfList, int _iSize) template<typename T> static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHeight, bool transposed) { - std::string str = ""; - int s1,s2; if (!transposed) { @@ -411,17 +412,20 @@ static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHe s2 = 1; } + std::ostringstream s; + s.imbue(std::locale::classic()); + s << std::setprecision(17); + for (int y = 0; y < _iHeight; ++y) { if (_iWidth > 0) - str += StringUtil::toString(_pfMatrix[0*s1 + y*s2]); + s << _pfMatrix[0*s1 + y*s2]; for (int x = 1; x < _iWidth; x++) - str += "," + StringUtil::toString(_pfMatrix[x*s1 + y*s2]); + s << "," << _pfMatrix[x*s1 + y*s2]; - if (y != _iHeight-1) - str += ";"; + s << ";"; } - return str; + return s.str(); } void XMLNode::setContent(float32* _pfMatrix, int _iWidth, int _iHeight, bool transposed) |