Added --format extname and --plugin pluginname extensions, and improved formating
This commit is contained in:
parent
ea309e2677
commit
efd20ea643
@ -69,3 +69,79 @@ bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoL
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static std::string padwithspaces(const std::string& str, unsigned int padLength)
|
||||
{
|
||||
std::string newStr(str);
|
||||
while(newStr.length()<padLength) newStr.push_back(' ');
|
||||
return newStr;
|
||||
}
|
||||
|
||||
bool osgDB::outputPluginDetails(std::ostream& out, const std::string& fileName)
|
||||
{
|
||||
|
||||
|
||||
out<<"Plugin "<<fileName<<std::endl;
|
||||
out<<"{"<<std::endl;
|
||||
osgDB::ReaderWriterInfoList infoList;
|
||||
if (osgDB::queryPlugin(fileName, infoList))
|
||||
{
|
||||
for(osgDB::ReaderWriterInfoList::iterator rwi_itr = infoList.begin();
|
||||
rwi_itr != infoList.end();
|
||||
++rwi_itr)
|
||||
{
|
||||
osgDB::ReaderWriterInfo& info = *(*rwi_itr);
|
||||
out<<" ReaderWriter : "<<info.description<<std::endl;
|
||||
out<<" {"<<std::endl;
|
||||
|
||||
unsigned int longestOptionLength = 0;
|
||||
osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr;
|
||||
for(fdm_itr = info.protocols.begin();
|
||||
fdm_itr != info.protocols.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length();
|
||||
}
|
||||
|
||||
for(fdm_itr = info.extensions.begin();
|
||||
fdm_itr != info.extensions.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length();
|
||||
}
|
||||
|
||||
for(fdm_itr = info.options.begin();
|
||||
fdm_itr != info.options.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length();
|
||||
}
|
||||
|
||||
unsigned int padLength = longestOptionLength+4;
|
||||
|
||||
for(fdm_itr = info.protocols.begin();
|
||||
fdm_itr != info.protocols.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
out<<" protocol : "<<padwithspaces(fdm_itr->first, padLength)<<fdm_itr->second<<std::endl;
|
||||
}
|
||||
|
||||
for(fdm_itr = info.extensions.begin();
|
||||
fdm_itr != info.extensions.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
out<<" extensions : ."<<padwithspaces(fdm_itr->first, padLength-1)<<fdm_itr->second<<std::endl;
|
||||
}
|
||||
|
||||
for(fdm_itr = info.options.begin();
|
||||
fdm_itr != info.options.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
out<<" options : "<<padwithspaces(fdm_itr->first, padLength)<<fdm_itr->second<<std::endl;
|
||||
}
|
||||
out<<" }"<<std::endl;
|
||||
}
|
||||
}
|
||||
out<<"}"<<std::endl<<std::endl;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ typedef std::list< osg::ref_ptr<ReaderWriterInfo> > ReaderWriterInfoList;
|
||||
|
||||
bool queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoList);
|
||||
|
||||
bool outputPluginDetails(std::ostream& out, const std::string& fileName);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -537,6 +537,21 @@ int main( int argc, char **argv )
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string plugin;
|
||||
if (arguments.read("--plugin", plugin))
|
||||
{
|
||||
osgDB::outputPluginDetails(std::cout, plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string ext;
|
||||
if (arguments.read("--format", ext))
|
||||
{
|
||||
plugin = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
|
||||
osgDB::outputPluginDetails(std::cout, plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--formats"))
|
||||
{
|
||||
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
|
||||
@ -544,43 +559,7 @@ int main( int argc, char **argv )
|
||||
itr != plugins.end();
|
||||
++itr)
|
||||
{
|
||||
std::cout<<"Plugin "<<*itr<<std::endl;
|
||||
std::cout<<"{"<<std::endl;
|
||||
osgDB::ReaderWriterInfoList infoList;
|
||||
if (osgDB::queryPlugin(*itr, infoList))
|
||||
{
|
||||
for(osgDB::ReaderWriterInfoList::iterator rwi_itr = infoList.begin();
|
||||
rwi_itr != infoList.end();
|
||||
++rwi_itr)
|
||||
{
|
||||
osgDB::ReaderWriterInfo& info = *(*rwi_itr);
|
||||
std::cout<<" ReaderWriter : "<<info.description<<std::endl;
|
||||
std::cout<<" {"<<std::endl;
|
||||
|
||||
for(osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr = info.protocols.begin();
|
||||
fdm_itr != info.protocols.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
std::cout<<" protocol : "<<fdm_itr->first<<"\t"<<fdm_itr->second<<std::endl;
|
||||
}
|
||||
|
||||
for(osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr = info.extensions.begin();
|
||||
fdm_itr != info.extensions.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
std::cout<<" extensions : ."<<fdm_itr->first<<"\t"<<fdm_itr->second<<std::endl;
|
||||
}
|
||||
|
||||
for(osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr = info.options.begin();
|
||||
fdm_itr != info.options.end();
|
||||
++fdm_itr)
|
||||
{
|
||||
std::cout<<" options : "<<fdm_itr->first<<"\t"<<fdm_itr->second<<std::endl;
|
||||
}
|
||||
std::cout<<" }"<<std::endl;
|
||||
}
|
||||
}
|
||||
std::cout<<"}"<<std::endl<<std::endl;
|
||||
osgDB::outputPluginDetails(std::cout,*itr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -603,7 +582,6 @@ int main( int argc, char **argv )
|
||||
osgDB::Registry::instance()->setOptions(options);
|
||||
}
|
||||
|
||||
std::string ext;
|
||||
while (arguments.read("-e",ext))
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
|
||||
|
Loading…
Reference in New Issue
Block a user