示例#1
0
int main( int argc, char** ppArgv )
{
  try
  {
    if( argc != 3 )
    {
      throw WrongNumberOfArgumentsException( );
    }

    std::string initialAdjustmentParameterString( ppArgv[ 1 ] );
    std::istringstream initialAdjustmentParameterIstream( initialAdjustmentParameterString );

    std::string targetBitratesString( ppArgv[ 2 ] );
    std::istringstream targetBitratesIstream( targetBitratesString );

    guessLambdaModifiers( std::cout, initialAdjustmentParameterIstream, targetBitratesIstream, std::cin );
    return 0;

  }
  catch( std::exception& e )
  {
    std::cerr << e.what( ) << std::endl;
  }
  catch( ... )
  {
    std::cerr << "Unknown exception" << std::endl;
  }
  return 1;
}
示例#2
0
            /**
                \brief Validates the arguments

                This method checks if the arguments are correct. It first
                checks if the sizes match, otherwise throws an WrongNumberOfArgumentsException.
                Then it iterates over all arguments and checks if the types are correct.
                If this is not the case it throws a WrongArgumentTypeException.

                \throws WrongNumberOfArgumentsException
                \throws WrongArgumentTypeException
             */
            void ValidateArguments() const {
                // If sizes do not match return false
                if (ArgumentDictionary::Instance()->IsRepeatedArgument(name)) {
                    if (arguments.size() < ArgumentDictionary::Instance()->Size(name)) {
                        throw WrongNumberOfArgumentsException();
                    }
                } else {
                    if (arguments.size() != ArgumentDictionary::Instance()->Size(name)) {
                        throw WrongNumberOfArgumentsException();
                    }
                }

                for (int i=0; i<arguments.size(); i++) {
                    if (!ArgumentDictionary::Instance()->IsA(name, i, arguments[i]->GetType())) {
                        throw WrongArgumentTypeException(
                                ArgumentDictionary::Instance()->TypeToString(ArgumentDictionary::Instance()->Type(name, i)),
                                ArgumentDictionary::Instance()->TypeToString(arguments[i]->GetType())
                        );
                    }
                }
            }