Change formating and copyrights
This commit is contained in:
122 files changed
+14058
-12613
No files matched your search
+46
-23
@@ -37,21 +37,22 @@
|
||||
*/
|
||||
|
||||
#include "PlaYUVerOptions.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "lib/PlaYUVerModuleIf.h"
|
||||
#include "modules/PlaYUVerModuleFactory.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
#include "lib/PlaYUVerModuleIf.h"
|
||||
#include "modules/PlaYUVerModuleFactory.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct ParseFailure : public std::exception
|
||||
{
|
||||
String arg;
|
||||
String val;
|
||||
ParseFailure( String arg0, String val0 ) throw() : arg( arg0 ), val( val0 ) {}
|
||||
ParseFailure( String arg0, String val0 ) throw()
|
||||
: arg( arg0 ), val( val0 ) {}
|
||||
~ParseFailure() throw() {}
|
||||
const Char* what() const throw() { return "Option Parse Failure"; }
|
||||
};
|
||||
@@ -60,7 +61,8 @@ struct ParseFailure : public std::exception
|
||||
class BoolOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
BoolOption( const String& name, const String& desc ) : OptionBase( name, desc ) { is_binary = true; }
|
||||
BoolOption( const String& name, const String& desc )
|
||||
: OptionBase( name, desc ) { is_binary = true; }
|
||||
void parse( const String& arg ) { arg_count++; }
|
||||
};
|
||||
|
||||
@@ -69,7 +71,11 @@ template <typename T>
|
||||
class StandardOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
StandardOption( const String& name, T& storage, const String& desc ) : OptionBase( name, desc ), opt_storage( storage ) { is_binary = false; }
|
||||
StandardOption( const String& name, T& storage, const String& desc )
|
||||
: OptionBase( name, desc ), opt_storage( storage )
|
||||
{
|
||||
is_binary = false;
|
||||
}
|
||||
|
||||
void parse( const String& arg );
|
||||
T& opt_storage;
|
||||
@@ -202,9 +208,12 @@ template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, UInt&
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int& storage, const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, Int64& storage, const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, String& storage, const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<UInt>& storage, const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<Int>& storage, const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<String>& storage, const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<UInt>& storage,
|
||||
const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<Int>& storage,
|
||||
const String& desc );
|
||||
template PlaYUVerOptions& PlaYUVerOptions::operator()( const String& name, std::vector<String>& storage,
|
||||
const String& desc );
|
||||
|
||||
/**
|
||||
* Add option described by name to the parent Options list,
|
||||
@@ -227,7 +236,8 @@ PlaYUVerOptions::PlaYUVerOptions( const String& name )
|
||||
|
||||
PlaYUVerOptions::~PlaYUVerOptions()
|
||||
{
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) {
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
@@ -244,7 +254,8 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName )
|
||||
if( opt_it != opt_short_map.end() )
|
||||
{
|
||||
OptionsList opt_list = ( *opt_it ).second;
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) {
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
{
|
||||
return ( *it )->opt;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +263,8 @@ OptionBase* PlaYUVerOptions::getOption( const String& optName )
|
||||
if( opt_it != opt_long_map.end() )
|
||||
{
|
||||
OptionsList opt_list = ( *opt_it ).second;
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) {
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
{
|
||||
return ( *it )->opt;
|
||||
}
|
||||
}
|
||||
@@ -288,7 +300,8 @@ void PlaYUVerOptions::addOption( OptionBase* opt )
|
||||
string& opt_string = opt->opt_string;
|
||||
|
||||
size_t opt_start = 0;
|
||||
for( size_t opt_end = 0; opt_end != string::npos; ) {
|
||||
for( size_t opt_end = 0; opt_end != string::npos; )
|
||||
{
|
||||
opt_end = opt_string.find_first_of( ',', opt_start );
|
||||
bool force_short = 0;
|
||||
if( opt_string[opt_start] == '-' )
|
||||
@@ -316,7 +329,8 @@ static void setOptions( PlaYUVerOptions::OptionsList& opt_list, const string& va
|
||||
{
|
||||
/* multiple options may be registered for the same name:
|
||||
* allow each to parse value */
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) {
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
{
|
||||
( *it )->opt->parse( value );
|
||||
}
|
||||
}
|
||||
@@ -487,7 +501,8 @@ list<const Char*> PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] )
|
||||
/* a list for anything that didn't get handled as an option */
|
||||
list<const Char*> non_option_arguments;
|
||||
|
||||
for( UInt i = 1; i < argc; i++ ) {
|
||||
for( UInt i = 1; i < argc; i++ )
|
||||
{
|
||||
if( argv[i][0] != '-' )
|
||||
{
|
||||
non_option_arguments.push_back( argv[i] );
|
||||
@@ -515,7 +530,8 @@ list<const Char*> PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] )
|
||||
if( argv[i][2] == 0 )
|
||||
{
|
||||
/* a lone double dash ends option processing */
|
||||
while( ++i < argc ) non_option_arguments.push_back( argv[i] );
|
||||
while( ++i < argc )
|
||||
non_option_arguments.push_back( argv[i] );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -528,7 +544,8 @@ list<const Char*> PlaYUVerOptions::scanArgv( UInt argc, Char* argv[] )
|
||||
|
||||
Void PlaYUVerOptions::parse( std::vector<String> args_array )
|
||||
{
|
||||
for( UInt i = 0; i < args_array.size(); i++ ) {
|
||||
for( UInt i = 0; i < args_array.size(); i++ )
|
||||
{
|
||||
i += parseLONG( args_array[i] );
|
||||
}
|
||||
return;
|
||||
@@ -572,7 +589,8 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns )
|
||||
const UInt pad_short = 3;
|
||||
/* first pass: work out the longest option name */
|
||||
UInt max_width = 0;
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) {
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
ostringstream line( ios_base::out );
|
||||
doHelpOpt( line, **it, pad_short );
|
||||
max_width = max( max_width, (UInt)line.tellp() );
|
||||
@@ -586,7 +604,8 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns )
|
||||
* - if the option text is longer than opt_width, place the help
|
||||
* text at opt_width on the next line.
|
||||
*/
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) {
|
||||
for( PlaYUVerOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
ostringstream line( ios_base::out );
|
||||
line << " ";
|
||||
doHelpOpt( line, **it, pad_short );
|
||||
@@ -608,7 +627,8 @@ Void PlaYUVerOptions::doHelp( ostream& out, UInt columns )
|
||||
}
|
||||
/* split up the help text, taking into account new lines,
|
||||
* (add opt_width of padding to each new line) */
|
||||
for( size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0 ) {
|
||||
for( size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0 )
|
||||
{
|
||||
/* print any required padding space for vertical alignment */
|
||||
line << &( spaces[40 - opt_width + currlength] );
|
||||
newline_pos = opt_desc.find_first_of( '\n', newline_pos );
|
||||
@@ -673,7 +693,8 @@ Bool PlaYUVerOptions::checkListingOpts()
|
||||
if( hasOpt( "pel_fmts" ) )
|
||||
{
|
||||
printf( "PlaYUVer supported pixel formats: \n" );
|
||||
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) {
|
||||
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
printf( " %s\n", PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() );
|
||||
}
|
||||
bRet |= true;
|
||||
@@ -681,7 +702,8 @@ Bool PlaYUVerOptions::checkListingOpts()
|
||||
if( hasOpt( "quality_metrics" ) )
|
||||
{
|
||||
printf( "PlaYUVer supported quality metrics: \n" );
|
||||
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) {
|
||||
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ )
|
||||
{
|
||||
printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() );
|
||||
}
|
||||
bRet |= true;
|
||||
@@ -717,7 +739,8 @@ Void PlaYUVerOptions::listModules()
|
||||
|
||||
Char ModuleNameString[40];
|
||||
|
||||
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) {
|
||||
for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ )
|
||||
{
|
||||
printf( " " );
|
||||
printf( "%-30s", it->first );
|
||||
if( bDetailed )
|
||||
|
||||
Reference in new issue
Block a user