From 1e5783ece788b2389dac976a6ba3d745bc42b5f4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 18 Jun 2008 16:45:21 +0000 Subject: [PATCH] Added a wrapString(const char*) which automatically handles null strings. --- include/osgDB/Output | 3 +++ src/osgDB/Output.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/osgDB/Output b/include/osgDB/Output index 3e8cbb9e7..55b4ecccf 100644 --- a/include/osgDB/Output +++ b/include/osgDB/Output @@ -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); diff --git a/src/osgDB/Output.cpp b/src/osgDB/Output.cpp index 49e093fd3..426f8a01b 100644 --- a/src/osgDB/Output.cpp +++ b/src/osgDB/Output.cpp @@ -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;