X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fcommand-line-options.cpp;h=fd4b293735ba6b7b2e6aac2af2d8cc45fdf195a3;hb=5ef1fc5b5db38a0abaa21b027b3c24b4390e1264;hp=a784a80c167880504f4c3237173c50fe1dab6280;hpb=04d259d0d3443165b0d750b0998ef13c83222543;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/command-line-options.cpp b/adaptors/common/command-line-options.cpp index a784a80..fd4b293 100644 --- a/adaptors/common/command-line-options.cpp +++ b/adaptors/common/command-line-options.cpp @@ -24,9 +24,7 @@ #include #include -#include - -using namespace std; +#include namespace Dali { @@ -46,13 +44,13 @@ struct Argument void Print() { - const ios_base::fmtflags flags = cout.flags(); - cout << left << " --"; - cout.width( 18 ); - cout << opt; - cout << optDescription; - cout << endl; - cout.flags( flags ); + const std::ios_base::fmtflags flags = std::cout.flags(); + std::cout << std::left << " --"; + std::cout.width( 18 ); + std::cout << opt; + std::cout << optDescription; + std::cout << std::endl; + std::cout.flags( flags ); } }; @@ -62,7 +60,7 @@ Argument EXPECTED_ARGS[] = { "width", "Stage Width" }, { "height", "Stage Height" }, { "dpi", "Emulated DPI" }, - { "view", "Stereocopic 3D view mode ([0]=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)" }, + { "view", "Stereocopic 3D view mode ([0]=MONO, 1=STEREO_HORIZONTAL, 2=STEREO_VERTICAL, 3=STEREO_INTERLACED)" }, { "stereo-base", "Distance in millimeters between left/right cameras [65.0]" }, { "help", "Help" }, { NULL, NULL } @@ -79,11 +77,11 @@ enum Option OPTION_HELP }; -typedef vector< int > UnhandledContainer; +typedef Dali::Vector< int > UnhandledContainer; void ShowHelp() { - cout << "Available options:" << endl; + std::cout << "Available options:" << std::endl; Argument* arg = EXPECTED_ARGS; while ( arg->opt ) { @@ -100,6 +98,12 @@ CommandLineOptions::CommandLineOptions(int *argc, char **argv[]) viewMode(0), stereoBase(65) { + // Exit gracefully if no arguments provided + if ( !argc || !argv ) + { + return; + } + if ( *argc > 1 ) { // We do not want to print out errors. @@ -203,7 +207,7 @@ CommandLineOptions::CommandLineOptions(int *argc, char **argv[]) default: { - unhandledOptions.push_back( optind - 1 ); + unhandledOptions.PushBack( optind - 1 ); break; } } @@ -212,17 +216,17 @@ CommandLineOptions::CommandLineOptions(int *argc, char **argv[]) // Take out the options we have processed if ( optionProcessed ) { - if ( !unhandledOptions.empty() ) + if ( unhandledOptions.Count() > 0 ) { int index( 1 ); // Overwrite the argv with the values from the unhandled indices - const UnhandledContainer::const_iterator endIter = unhandledOptions.end(); - for ( UnhandledContainer::iterator iter = unhandledOptions.begin(); iter != endIter; ++iter ) + const UnhandledContainer::ConstIterator endIter = unhandledOptions.End(); + for ( UnhandledContainer::Iterator iter = unhandledOptions.Begin(); iter != endIter; ++iter ) { (*argv)[ index++ ] = (*argv)[ *iter ]; } - *argc = unhandledOptions.size() + 1; // +1 for the program name + *argc = unhandledOptions.Count() + 1; // +1 for the program name } else {