Added a wrapString(const char*) which automatically handles null strings.

This commit is contained in:
Robert Osfield
2008-06-18 16:45:21 +00:00
parent 959c01557c
commit 1e5783ece7
2 changed files with 9 additions and 0 deletions

View File

@@ -49,6 +49,9 @@ class OSGDB_EXPORT Output : public std::ofstream
Output& indent();
/** wrap a string with "" quotes and use \" for any internal quotes.*/
std::string wrapString(const char* str);
/** wrap a string with "" quotes and use \" for any internal quotes.*/
std::string wrapString(const std::string& str);

View File

@@ -105,6 +105,12 @@ void Output::moveOut()
if (_indent<0) _indent=0;
}
std::string Output::wrapString(const char* str)
{
if (!str) return std::string("\"\"");
return wrapString(std::string(str));
}
std::string Output::wrapString(const std::string& str)
{
std::string newstring;