mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-11-02 14:03:41 +01:00 
			
		
		
		
	Make indentation work in toString
This commit is contained in:
		@@ -72,7 +72,7 @@ struct ElementTraits<Array::Ptr>
 | 
			
		||||
	static std::string toString(const Array::Ptr& value, int indent = 0)
 | 
			
		||||
	{
 | 
			
		||||
		//TODO:
 | 
			
		||||
		return value.isNull() ? "null" : value->toString();
 | 
			
		||||
		return value.isNull() ? "null" : value->toString(indent);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -64,28 +64,32 @@ std::string Array::toString(int indent) const
 | 
			
		||||
	{
 | 
			
		||||
		if ( it != _elements.begin() )
 | 
			
		||||
		{
 | 
			
		||||
			if ( indent > 0 )
 | 
			
		||||
			{
 | 
			
		||||
				for(int i = 0; i < indent; ++i)
 | 
			
		||||
				{
 | 
			
		||||
					oss << ' ';
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			oss << ",";
 | 
			
		||||
			if ( indent > 0 )
 | 
			
		||||
			{
 | 
			
		||||
				oss << std::endl;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for(int i = 0; i < indent; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			oss << ' ';
 | 
			
		||||
		}
 | 
			
		||||
		oss << (*it)->toString();
 | 
			
		||||
	}
 | 
			
		||||
	oss << "]";
 | 
			
		||||
 | 
			
		||||
	if ( indent >  0 )
 | 
			
		||||
	if ( indent > 0 )
 | 
			
		||||
	{
 | 
			
		||||
		oss << std::endl;
 | 
			
		||||
		indent -= 2;
 | 
			
		||||
		for(int i = 0; i < indent; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			oss << ' ';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	oss << "]";
 | 
			
		||||
 | 
			
		||||
	return oss.str();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -155,10 +155,40 @@ std::string Document::toString(int indent) const
 | 
			
		||||
	{
 | 
			
		||||
		if ( it != _elements.begin() )
 | 
			
		||||
		{
 | 
			
		||||
			oss << ", ";
 | 
			
		||||
			oss << ",";
 | 
			
		||||
			if ( indent > 0 )
 | 
			
		||||
			{
 | 
			
		||||
				oss << std::endl;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if ( indent > 0 )
 | 
			
		||||
		{
 | 
			
		||||
			for(int i = 0; i < indent; ++i)
 | 
			
		||||
			{
 | 
			
		||||
				oss << ' ';
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		oss << '"' << (*it)->name() << '"' << " : ";
 | 
			
		||||
		if ( indent > 0 )
 | 
			
		||||
		{
 | 
			
		||||
			oss << (*it)->toString(indent + 2);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			oss << (*it)->toString();
 | 
			
		||||
		}
 | 
			
		||||
		oss << '"' << (*it)->name() << '"' << " : " << (*it)->toString();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( indent > 0 )
 | 
			
		||||
	{
 | 
			
		||||
		oss << std::endl;
 | 
			
		||||
		indent -= 2;
 | 
			
		||||
		for(int i = 0; i < indent; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			oss << ' ';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	oss << "}" << std::endl;
 | 
			
		||||
	return oss.str();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user