xmlNode* AddArray(xmlNode* parent, const char* id, const FloatList& values)
	{
		size_t valueCount = values.size();
		FUSStringBuilder builder;
		builder.reserve(valueCount * FLOAT_STR_ESTIMATE);
		FUStringConversion::ToString(builder, values);
		return AddArray(parent, id, DAE_FLOAT_ARRAY_ELEMENT, builder.ToCharPtr(), valueCount);
	}
	xmlNode* AddArray(xmlNode* parent, const char* id, const StringList& values, const char* arrayType)
	{
		size_t valueCount = values.size();
		FUSStringBuilder builder;
		builder.reserve(valueCount * 18); // Pulled out of a hat
		if (valueCount > 0)
		{
			StringList::const_iterator itV = values.begin();
			builder.set(*itV);
			for (++itV; itV != values.end(); ++itV) { builder.append(' '); builder.append(*itV); }
		}
		return AddArray(parent, id, arrayType, builder.ToCharPtr(), valueCount);
	}
	xmlNode* AddArray(xmlNode* parent, const char* id, const FMMatrix44List& values)
	{
		FUSStringBuilder builder;
		size_t valueCount = values.size();
		builder.reserve(valueCount * 16 * FLOAT_STR_ESTIMATE);
		if (valueCount > 0)
		{
			FMMatrix44List::const_iterator itM = values.begin();
			FUStringConversion::ToString(builder, *itM);
			for (++itM; itM != values.end(); ++itM) { builder.append(' '); FUStringConversion::ToString(builder, *itM); }
		}
		return AddArray(parent, id, DAE_FLOAT_ARRAY_ELEMENT, builder.ToCharPtr(), valueCount * 16);
	}
Example #4
0
	fm::string FUStringConversion::ToString(const fchar* value)
	{
		FUSStringBuilder builder;
		if (value != NULL)
		{
			uint32 length = (uint32) fstrlen(value);
			builder.reserve(length + 1);
			for (uint32 i = 0; i < length; ++i)
			{
				if (value[i] < 0xFF || (value[i] & (~0xFF)) >= 32) builder.append((char)value[i]);
				else builder.append('_'); // some generic enough character
			}
		}
		return builder.ToString();
	}
	xmlNode* AddArray(xmlNode* parent, const char* id, const FMVector3List& values)
	{
		// Reserve the necessary space within the string builder
		FUSStringBuilder builder;
		size_t valueCount = values.size();
		builder.reserve(valueCount * 3 * FLOAT_STR_ESTIMATE);
		if (valueCount > 0)
		{
			// Write out the values
			FMVector3List::const_iterator itP = values.begin();
			FUStringConversion::ToString(builder, *itP);
			for (++itP; itP != values.end(); ++itP) { builder.append(' '); FUStringConversion::ToString(builder, *itP); }
		}

		// Create the typed array node.
		return AddArray(parent, id, DAE_FLOAT_ARRAY_ELEMENT, builder.ToCharPtr(), valueCount * 3);
	}