From eb28f9f5871a7bbee6882dcadde3da9d36bb8378 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 3 Nov 2005 10:01:09 +0000 Subject: [PATCH] From Eric Sokolowsky, added writeEnvironmentSettings to help report what OSG centric environment variables are used. --- include/osg/ApplicationUsage | 2 ++ src/osg/ApplicationUsage.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/osg/ApplicationUsage b/include/osg/ApplicationUsage index 0764c236d..641d9b1eb 100644 --- a/include/osg/ApplicationUsage +++ b/include/osg/ApplicationUsage @@ -84,6 +84,8 @@ class OSG_EXPORT ApplicationUsage void write(std::ostream& output,unsigned int type=COMMAND_LINE_OPTION, unsigned int widthOfOutput=80,bool showDefaults=false); + void writeEnvironmentSettings(std::ostream& output); + protected: std::string _applicationName; diff --git a/src/osg/ApplicationUsage.cpp b/src/osg/ApplicationUsage.cpp index 86a75a5ae..44d12a1ed 100644 --- a/src/osg/ApplicationUsage.cpp +++ b/src/osg/ApplicationUsage.cpp @@ -209,3 +209,39 @@ void ApplicationUsage::write(std::ostream& output, unsigned int type, unsigned i } + +void ApplicationUsage::writeEnvironmentSettings(std::ostream& output) +{ + output << "Current Environment Settings:"<first.find_first_of("\n\r\t "); + if (len == std::string::npos) len = citr->first.size(); + maxNumCharsInOptions = maximum(maxNumCharsInOptions,len); + } + + unsigned int optionPos = 2; + std::string line; + + for(citr=getEnvironmentalVariables().begin(); + citr!=getEnvironmentalVariables().end(); + ++citr) + { + line.assign(optionPos+maxNumCharsInOptions+2,' '); + std::string::size_type len = citr->first.find_first_of("\n\r\t "); + if (len == std::string::npos) len = citr->first.size(); + line.replace(optionPos,len,citr->first.substr(0,len)); + char *cp = getenv(citr->first.substr(0, len).c_str()); + if (!cp) cp = "[not set]"; + else if (!*cp) cp = "[set]"; + line += std::string(cp) + "\n"; + + output << line; + } + output << std::endl; +}