本文整理汇总了C++中alib::CommandLine::HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandLine::HasFlag方法的具体用法?C++ CommandLine::HasFlag怎么用?C++ CommandLine::HasFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alib::CommandLine
的用法示例。
在下文中一共展示了CommandLine::HasFlag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cl
void DateReadCommand :: ProcessFlags( ALib::CommandLine & cmd ) {
ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
CommaListToIndex( cl, mFields );
string mask = cmd.GetValue( FLAG_MASK, "" );
string cys = cmd.GetValue( FLAG_CDATE, ALib::Str( BASE_YEAR ) );
NotBoth( cmd, FLAG_BDLIST, FLAG_BDEXCL );
if ( cmd.HasFlag( FLAG_BDLIST ) ) {
mWriteAction = WriteBad;
}
else if ( cmd.HasFlag( FLAG_BDEXCL ) ) {
mWriteAction = WriteGood;
}
else {
mWriteAction = WriteAll;
}
if ( ! ALib::IsInteger( cys )) {
CSVTHROW( "Invalid year value " << cys );
}
int cy = ALib::ToInteger( cys );
string mnames = cmd.GetValue( FLAG_MNAMES, MONTH_NAMES );
delete mReader;
mReader = new MaskedDateReader( mask, mnames, cy );
}
示例2: cl
int TrimCommand :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
if ( cmd.HasFlag( FLAG_TRLEAD ) || cmd.HasFlag( FLAG_TRTRAIL ) ) {
mTrimLead = cmd.HasFlag( FLAG_TRLEAD );
mTrimTrail = cmd.HasFlag( FLAG_TRTRAIL );
}
else {
mTrimLead = mTrimTrail = true;
}
if ( cmd.HasFlag( FLAG_WIDTH ) ) {
GetWidths( cmd.GetValue( FLAG_WIDTH ) );
}
ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
CommaListToIndex( cl, mFields );
IOManager io( cmd );
CSVRow row;
while( io.ReadCSV( row ) ) {
if ( Skip( row ) ) {
continue;
}
if ( ! Pass( row ) ) {
Trim( row );
}
io.WriteRow( row );
}
return 0;
}
示例3: io
int JoinCommand :: Execute( ALib::CommandLine & cmd ) {
Clear();
mKeep = cmd.HasFlag( FLAG_KEEP );
mOuterJoin = cmd.HasFlag( FLAG_OUTERJ );
mInvert = cmd.HasFlag( FLAG_INVERT );
mIgnoreCase = cmd.HasFlag( FLAG_ICASE );
if ( mOuterJoin && mInvert ) {
CSVTHROW( "Cannot have both " << FLAG_OUTERJ
<< " and " << FLAG_INVERT << " flags" );
}
string js = cmd.GetValue( FLAG_COLS );
BuildJoinSpecs( js );
IOManager io( cmd );
unsigned int scount = io.InStreamCount();
if ( scount < 2 ) {
CSVTHROW( "Need at least two input streams" );
}
BuildRowMap( io.CreateStreamParser( scount - 1 ) );
CSVRow row;
for ( unsigned int i = 0; i < scount - 1; i++ ) {
std::unique_ptr <ALib::CSVStreamParser> p( io.CreateStreamParser( i ) );
while( p->ParseNext( row ) ) {
WriteJoinRows( io, row );
}
}
return 0;
}
示例4: cl
void RemoveNewlineCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {
string scols = cmd.GetValue( FLAG_COLS, "" );
ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
CommaListToIndex( cl, mFields);
if ( cmd.HasFlag( FLAG_EXCLNL ) && cmd.HasFlag( FLAG_STR ) ) {
CSVTHROW( "Flags " << FLAG_EXCLNL << " and " << FLAG_STR
<< " are mutually exclusive" );
}
mSep = cmd.GetValue( FLAG_STR, "" );
ExpandSep();
mExcludeAfter = cmd.HasFlag( FLAG_EXCLNL );
}
示例5: io
int TemplateCommand :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
ReadTemplate( cmd );
if ( cmd.HasFlag( FLAG_FNAMES ) ) {
mFileTemplate = cmd.GetValue( FLAG_FNAMES );
}
IOManager io( cmd );
CSVRow row;
while( io.ReadCSV( row ) ) {
if ( Skip( row ) ) {
continue;
}
if ( mFileTemplate.empty() ) {
io.Out() << ReplaceColumns( mTemplate, row );
}
else {
FileOut( row );
}
}
return 0;
}
示例6: io
int EvalCommand :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
IOManager io( cmd );
CSVRow row;
mDiscardInput = cmd.HasFlag( FLAG_DISCARD );
GetExpressions( cmd );
while( io.ReadCSV( row ) ) {
if ( Skip( io, row ) ) {
continue;
}
if ( ! Pass( io, row ) ) {
SetParams( row, io );
if ( mDiscardInput ) {
row.clear();
}
Evaluate( row );
}
io.WriteRow( row );
}
return 0;
}
示例7: io
int DSVReadCommand :: Execute( ALib::CommandLine & cmd ) {
ReadFlags( cmd );
mIsCSV = cmd.HasFlag( FLAG_CSV );
mCollapseSep = cmd.HasFlag( FLAG_CMULTI );
IOManager io( cmd );
CSVRow row;
string line;
while( io.ReadLine( line ) ) {
ParseDSV( line, row );
io.WriteRow( row );
}
return 0;
}
示例8: cl
void FileSplitCommand :: ProcessFlags( ALib::CommandLine & cmd ) {
mDir = cmd.GetValue( FLAG_FSDIR, DEF_DIR );
mFilePrefix = cmd.GetValue( FLAG_FSPRE, DEF_PREF );
mFileExt= cmd.GetValue( FLAG_FSEXT, DEF_EXT );
ALib::CommaList cl( cmd.GetValue( FLAG_COLS ) );
CommaListToIndex( cl, mColIndex );
mUseFieldNames = cmd.HasFlag( FLAG_USEFLD );
}
示例9: GetCommonValues
void SQLCommand :: GetCommonValues( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
mTable = cmd.GetValue( FLAG_TABLE );
if ( mTable == "" ) {
CSVTHROW( "Need table name specified by " << FLAG_TABLE << " flag" );
}
if ( ! cmd.HasFlag( FLAG_SQLSEP ) ) {
mSep ="\n;\n";
}
else {
mSep = ALib::UnEscape( cmd.GetValue( FLAG_SQLSEP ) );
}
string noq = cmd.GetValue( FLAG_NOQUOTE, "" );
if ( ! ALib::IsEmpty( noq ) ) {
CommaListToIndex( ALib::CommaList( noq ), mNoQuote );
}
mQuoteNulls = cmd.HasFlag( FLAG_QNULLS );
mEmptyNulls = cmd.HasFlag( FLAG_ENULLS );
}
示例10: padding
int TruncPadBase :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
string ps = cmd.GetValue( FLAG_PAD );
ALib::CommaList padding( ps );
unsigned int ncols = padding.Size();
bool ncolspec = false; // use explicit size or not
if ( ncols == 0 || cmd.HasFlag( FLAG_NUM ) ) {
if ( ! cmd.HasFlag( FLAG_NUM ) ) {
CSVTHROW( "Need -n flag to specify field count" );
}
ncolspec = true;
string nv = cmd.GetValue( FLAG_NUM );
if ( ALib::ToInteger( nv, "-n flag needs integer value" ) < 0 ) {
CSVTHROW( FLAG_NUM << " needs value greater or equal to zero" );
}
ncols = ALib::ToInteger( nv );
}
IOManager io( cmd );
CSVRow row;
while( io.ReadCSV( row ) ) {
if ( Skip( io, row ) ) {
continue;
}
if ( ! Pass( io, row ) ) {
unsigned int nc = ncolspec ? ncols : row.size() + padding.Size();
ProcessRow( row, nc, padding );
}
io.WriteRow( row );
}
return 0;
}
示例11: io
int FileInfoCommand :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
mTwoCols = cmd.HasFlag( FLAG_TWOC );
mBasename = cmd.HasFlag( FLAG_BASEN );
IOManager io( cmd );
CSVRow row;
while( io.ReadCSV( row ) ) {
if ( Skip( io, row ) ) {
continue;
}
if ( Pass( io, row ) ) {
io.WriteRow( row );
continue;
}
string fname = mBasename
? ALib::Filename( io.CurrentFileName() ).Base()
: io.CurrentFileName();
CSVRow outrow;
if ( mTwoCols ) {
outrow.push_back( fname );
outrow.push_back( ALib::Str( io.CurrentLine() ));
}
else {
outrow.push_back( fname + " ("
+ ALib::Str( io.CurrentLine() ) + ")"
);
}
ALib::operator+=( outrow, row );
io.WriteRow( outrow );
}
return 0;
}
示例12: ProcessFlags
void AsciiTableCommand :: ProcessFlags( ALib::CommandLine & cmd ) {
mUseLineSep = cmd.HasFlag( FLAG_SEP );
mHeadings = ALib::CommaList( cmd.GetValue( FLAG_HEADER, "" ) );
ALib::CommaList ra = ALib::CommaList( cmd.GetValue( FLAG_RALIGN, "" ) );
CommaListToIndex( ra, mRightAlign );
if ( mHeadings.Size() && mHeadings.At(0) != FILE_HEADER) {
CSVRow r;
for ( unsigned int i = 0; i < mHeadings.Size() ; i++ ) {
r.push_back( mHeadings.At( i ) );
}
AddRow( r );
}
}
示例13: if
void SummaryCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {
int nf = CountNonGeneric( cmd );
if ( nf == 0 ) {
CSVTHROW( "Need a summary flag" );
}
else if ( nf != 1 ) {
CSVTHROW( "Only one summary flag allowed" );
}
if ( cmd.HasFlag( FLAG_AVG ) ) {
mType = Average;
GetFields( cmd, FLAG_AVG );
}
else if ( cmd.HasFlag( FLAG_MIN ) ) {
mType = Min;
GetFields( cmd, FLAG_MIN );
}
else if ( cmd.HasFlag( FLAG_MAX ) ) {
mType = Max;
GetFields( cmd, FLAG_MAX );
}
else if ( cmd.HasFlag( FLAG_FREQ ) ) {
mType = Frequency;
GetFields( cmd, FLAG_FREQ );
}
else if ( cmd.HasFlag( FLAG_MEDIAN ) ) {
mType = Median;
GetFields( cmd, FLAG_MEDIAN);
}
else if ( cmd.HasFlag( FLAG_MODE) ) {
mType = Mode;
GetFields( cmd, FLAG_MODE );
}
else if ( cmd.HasFlag( FLAG_SUM ) ) {
mType = Sum;
GetFields( cmd, FLAG_SUM );
}
else if ( cmd.HasFlag( FLAG_SIZE ) ) {
mType = Size;
}
else {
CSVTHROW( "Should never happen in SummaryCommand::ProcessFlags" );
}
}
示例14: io
int ReadFixedCommand :: Execute( ALib::CommandLine & cmd ) {
mTrim = ! cmd.HasFlag( FLAG_KEEP );
BuildFields( cmd );
IOManager io( cmd );
string line;
CSVRow row;
while( io.ReadLine( line ) ) {
MakeRow( line, row );
io.WriteRow( row );
}
return 0;
}
示例15: io
int ValidateCommand :: Execute( ALib::CommandLine & cmd ) {
GetSkipOptions( cmd );
GetOutputMode( cmd );
ReadValidationFile( cmd );
IOManager io( cmd );
CSVRow row;
// we optionally return an error code to the shell if validation failed
int errtotal = 0;
bool errcode = cmd.HasFlag( FLAG_ERRCODE );
while( io.ReadCSV( row ) ) {
if ( Skip( io, row ) ) {
continue;
}
int errcount = 0;
for ( unsigned int i = 0; i < mRules.size(); i++ ) {
ValidationRule::Results res = mRules[i]->Apply( row );
if ( res.size() && mOutMode == Reports ) {
Report( io, res, errcount );
errcount++;
errtotal += errcount;
continue;
}
if ( res.size() ) {
errcount++;
if ( mOutMode == Fails ) {
io.WriteRow( row );
break;
}
}
}
if ( mOutMode == Passes && errcount == 0 ) {
io.WriteRow( row );
}
errtotal += errcount;
}
// exit code of 2 indicates program detected invalid data
return errtotal && errcode ? 2 : 0;
}