本文整理汇总了C++中alib::CommandLine::Argv方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandLine::Argv方法的具体用法?C++ CommandLine::Argv怎么用?C++ CommandLine::Argv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alib::CommandLine
的用法示例。
在下文中一共展示了CommandLine::Argv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cl
int EditCommand :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
for ( int i = 2; i < cmd.Argc(); i++ ) {
if ( cmd.Argv( i ) == FLAG_EDIT ) {
AddSubCmd( cmd.Argv( i + 1 ) );
i++;
}
}
ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
CommaListToIndex( cl, mCols );
IOManager io( cmd );
CSVRow row;
while( io.ReadCSV( row ) ) {
if ( Skip( io, row ) ) {
continue;
}
if ( ! Pass( io, row ) ) {
EditRow( row );
}
io.WriteRow( row );
}
return 0;
}
示例2: if
void EvalCommand :: GetExpressions( ALib::CommandLine & cmd ) {
int i = 2; // skip exe name and command name
while( i < cmd.Argc() ) {
if ( cmd.Argv( i ) == FLAG_EXPR || cmd.Argv( i ) == FLAG_IF ) {
mIsIf.push_back( cmd.Argv( i ) == FLAG_IF );
if ( i + 1 >= cmd.Argc() ) {
CSVTHROW( "Missing expression" );
}
i++;
string expr = cmd.Argv( i );
ALib::Expression ex;
string emsg = ex.Compile( expr );
if ( emsg != "" ) {
CSVTHROW( emsg + " in " + expr );
}
mFieldExprs.push_back( FieldEx( -1, ex ) );
}
else if ( cmd.Argv( i ) == FLAG_REMOVE ) {
mIsIf.push_back( false );
if ( mDiscardInput ) {
CSVTHROW( "Cannot specify both " << FLAG_REMOVE
<< " and " << FLAG_DISCARD );
}
if ( i + 1 >= cmd.Argc() ) {
CSVTHROW( "Missimg field/expression" );
}
i++;
string::size_type pos = cmd.Argv(i).find_first_of( "," );
if ( pos == string::npos ) {
CSVTHROW( "Invalid field/index pair: " << cmd.Argv(i) );
}
string field = cmd.Argv(i).substr( 0, pos );
string expr = cmd.Argv(i).substr( pos + 1 );
if ( ! ALib::IsInteger( field ) ) {
CSVTHROW( "Invalid field (need integer): " << field );
}
int n = ALib::ToInteger( field );
if ( n <= 0 ) {
CSVTHROW( "Invalid field (must be greater than zero): " << field );
}
ALib::Expression ex;
string emsg = ex.Compile( expr );
if ( emsg != "" ) {
CSVTHROW( emsg + " in " + expr );
}
mFieldExprs.push_back( FieldEx( n - 1, ex ) );
}
i++;
}
if ( mFieldExprs.size() == 0 ) {
CSVTHROW( "Need at least one of -e or -r options" );
}
}