+template <typename T>
+std::string ToString(const T& value)
+{
+ std::stringstream ss;
+ ss << value;
+ return ss.str();
+}
+
+template <>
+std::string ToString(const Rect<int>& value)
+{
+ std::stringstream ss;
+ ss << value.x << "," << value.y << "," << value.width << "," << value.height;
+ return ss.str();
+}
+
+
+std::string PropertyValueToString( const Property::Value& value )
+{
+ std::string ret;
+
+ switch( value.GetType() )
+ {
+ case Property::NONE:
+ {
+ ret = "NONE";
+ break;
+ } ///< No type
+ case Property::BOOLEAN:
+ {
+ ret = value.Get<bool>() ? "True" : "False";
+ break;
+ }
+ case Property::FLOAT:
+ {
+
+ ret = ToString( value.Get<float>() );
+ break;
+ }
+ case Property::INTEGER:
+ {
+ ret = ToString( value.Get<int>() );
+ break;
+ }
+ case Property::UNSIGNED_INTEGER:
+ {
+ ret = ToString( value.Get<unsigned int>() );
+ break;
+ }
+ case Property::VECTOR2:
+ {
+ ret = ToString( value.Get<Vector2>() );
+ break;
+ }
+ case Property::VECTOR3:
+ {
+ ret = ToString( value.Get<Vector3>() );
+ break;
+ }
+ case Property::VECTOR4:
+ {
+ ret = ToString( value.Get<Vector4>() );
+ break;
+ }
+ case Property::MATRIX3:
+ {
+ ret = ToString( value.Get<Matrix3>() );
+ break;
+ }
+ case Property::MATRIX:
+ {
+ ret = ToString( value.Get<Matrix>() );
+ break;
+ }
+ case Property::RECTANGLE:
+ {
+ ret = ToString( value.Get< Rect<int> >() );
+ break;
+ }
+ case Property::ROTATION:
+ {
+ break;
+ }
+ case Property::STRING:
+ {
+ ret = value.Get<std::string>();
+ break;
+ }
+ case Property::ARRAY:
+ {
+ ret = std::string("Array Size=") + ToString( value.Get<Property::Array>().size() );
+ break;
+ }
+ case Property::MAP:
+ {
+ ret = std::string("Map Size=") + ToString( value.Get<Property::Map>().size() );
+ break;
+ }
+ case Property::TYPE_COUNT:
+ {
+ ret = "";
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * Recursively collects all stylesin a node (An array of style names).
+ *
+ * stylesCollection The set of styles from the json file (a json object of named styles)
+ * style The style array to begin the collection from
+ * styleList The style list to add nodes to apply
+ */
+void CollectAllStyles( const TreeNode& stylesCollection, const TreeNode& style, TreeNodeList& styleList )
+{
+ // style is an array of style names
+ if( TreeNode::ARRAY == style.GetType() )
+ {
+ for(TreeNode::ConstIterator iter = style.CBegin(); iter != style.CEnd(); ++iter)
+ {
+ if( OptionalString styleName = IsString( (*iter).second ) )
+ {
+ if( OptionalChild node = IsChild( stylesCollection, *styleName) )
+ {
+ styleList.push_back( &(*node) );
+
+ if( OptionalChild subStyle = IsChild( *node, KEYNAME_STYLES ) )
+ {
+ CollectAllStyles( stylesCollection, *subStyle, styleList );
+ }
+ }
+ }
+ }
+ }
+}
+
+} // namespace anon
+