Added new ReaderWriter methods for recording what protocols, extensions and options are

support by ReaderWriters
This commit is contained in:
Robert Osfield
2008-07-13 15:24:45 +00:00
parent 6aa604f31a
commit cb98cddc31
8 changed files with 85 additions and 72 deletions

View File

@@ -113,17 +113,21 @@ std::string osgDB::convertFileNameToNativeStyle(const std::string& fileName)
std::string osgDB::getLowerCaseFileExtension(const std::string& filename)
{
std::string ext = osgDB::getFileExtension(filename);
for(std::string::iterator itr=ext.begin();
itr!=ext.end();
return convertToLowerCase(osgDB::getFileExtension(filename));
}
std::string osgDB::convertToLowerCase(const std::string& str)
{
std::string lowcase_str(str);
for(std::string::iterator itr=lowcase_str.begin();
itr!=lowcase_str.end();
++itr)
{
*itr = tolower(*itr);
}
return ext;
return lowcase_str;
}
// strip one level of extension from the filename.
std::string osgDB::getNameLessExtension(const std::string& fileName)
{

View File

@@ -12,6 +12,7 @@
*/
#include <osgDB/ReaderWriter>
#include <osgDB/FileNameUtils>
#include <osgDB/Archive>
using namespace osgDB;
@@ -33,3 +34,24 @@ osg::Shader* ReaderWriter::ReadResult::takeShader() { osg::Shader* shader=dynami
ReaderWriter::~ReaderWriter()
{
}
bool ReaderWriter::acceptsExtension(const std::string& extension) const
{
std::string lowercase_ext = convertToLowerCase(extension);
return (_supportedExtensions.count(lowercase_ext)!=0);
}
void ReaderWriter::supportsProtocol(const std::string& fmt, const std::string& description)
{
_supportedProtocols[convertToLowerCase(fmt)] = description;
}
void ReaderWriter::supportsExtension(const std::string& fmt, const std::string& description)
{
_supportedExtensions[convertToLowerCase(fmt)] = description;
}
void ReaderWriter::supportsOption(const std::string& fmt, const std::string& description)
{
_supportedOptions[fmt] = description;
}