Browse Source

Force fixed floating point format for ostringstream in ObjectEntry saving

Ivan Safrin 10 years ago
parent
commit
2d0c9bd161
2 changed files with 11 additions and 1 deletions
  1. 1 1
      Core/Contents/Include/PolyObject.h
  2. 10 0
      Core/Contents/Source/PolyObject.cpp

+ 1 - 1
Core/Contents/Include/PolyObject.h

@@ -38,7 +38,7 @@ namespace Polycode {
 		/**
 		* Default constructor
 		*/
-		ObjectEntry() { type = UNKNOWN_ENTRY; length = 0; }
+        ObjectEntry();
 				
 		/**
 		* Type of entry. Possible values are (FLOAT_ENTRY, INT_ENTRY, BOOL_ENTRY, ARRAY_ENTRY, STRING_ENTRY, CONTAINER_ENTRY).

+ 10 - 0
Core/Contents/Source/PolyObject.cpp

@@ -28,6 +28,15 @@
 
 using namespace Polycode;
 
+ObjectEntry::ObjectEntry() :
+type(UNKNOWN_ENTRY),
+NumberVal(0.0),
+length(0),
+intVal(0)
+{
+    
+}
+
 void ObjectEntry::Clear() {
 	for(int i=0; i < children.size(); i++) {
 		children[i]->Clear();
@@ -132,6 +141,7 @@ TiXmlElement *Object::createElementFromObjectEntry(ObjectEntry *entry) {
 						break;
 						case ObjectEntry::FLOAT_ENTRY: {
 							std::ostringstream o; // Avoid NumberToString, it truncates
+                            o << std::fixed;
 							o << childEntry->NumberVal;
 							newElement->SetAttribute(childTypedName.c_str(), o.str().c_str());
 						} break;