diff --git a/include/osgDB/Options b/include/osgDB/Options index ef843816c..fc6d91a01 100644 --- a/include/osgDB/Options +++ b/include/osgDB/Options @@ -104,7 +104,10 @@ class OSGDB_EXPORT Options : public osg::Object _str(str), _objectCacheHint(CACHE_ARCHIVES), _precisionHint(FLOAT_PRECISION_ALL), - _buildKdTreesHint(NO_PREFERENCE) {} + _buildKdTreesHint(NO_PREFERENCE) + { + parsePluginStringData(str); + } Options(const Options& options,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); @@ -113,7 +116,7 @@ class OSGDB_EXPORT Options : public osg::Object Options* cloneOptions() const { return new Options(*this); } /** Set the general Options string.*/ - void setOptionString(const std::string& str) { _str = str; } + void setOptionString(const std::string& str) { _str = str; parsePluginStringData(str); } /** Get the general Options string.*/ const std::string& getOptionString() const { return _str; } @@ -169,6 +172,9 @@ class OSGDB_EXPORT Options : public osg::Object /** Remove a value from the PluginData */ void removePluginData(const std::string& s) const { _pluginData.erase(s); } + + /** Get number of PluginData values */ + unsigned int getNumPluginData() const { return _pluginData.size(); } /** Sets a plugindata value PluginData with a string */ @@ -187,6 +193,11 @@ class OSGDB_EXPORT Options : public osg::Object /** Remove a value from the PluginData */ void removePluginStringData(const std::string& s) const { _pluginStringData.erase(s); } + /** Get number of PluginStrData values */ + unsigned int getNumPluginStringData() const { return _pluginStringData.size(); } + + /** Parse string into plugin string data. This will be automatically done in Options(const std::string&) */ + void parsePluginStringData(const std::string& str, char separator1=' ', char separator2='='); /** Set the find callback to use in place of the default findFile calls.*/ diff --git a/src/osgDB/Options.cpp b/src/osgDB/Options.cpp index f3248ed7a..430271cfb 100644 --- a/src/osgDB/Options.cpp +++ b/src/osgDB/Options.cpp @@ -30,3 +30,26 @@ Options::Options(const Options& options,const osg::CopyOp& copyop): _writeFileCallback(options._writeFileCallback), _fileLocationCallback(options._fileLocationCallback), _fileCache(options._fileCache) {} + +void Options::parsePluginStringData(const std::string& str, char separator1, char separator2) +{ + StringList valueList; + split(str, valueList, separator1); + if (valueList.size() > 0) + { + StringList keyAndValue; + for (StringList::iterator itr=valueList.begin(); itr!=valueList.end(); ++itr) + { + split(*itr, keyAndValue, separator2); + if (keyAndValue.size() > 1) + { + setPluginStringData(keyAndValue.front(), keyAndValue.back()); + } + else if (keyAndValue.size() > 0) + { + setPluginStringData(keyAndValue.front(), "true"); + } + keyAndValue.clear(); + } + } +}