• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ alib::CommandLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中alib::CommandLine的典型用法代码示例。如果您正苦于以下问题:C++ CommandLine类的具体用法?C++ CommandLine怎么用?C++ CommandLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CommandLine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:32,代码来源:csved_join.cpp


示例2: 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;
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:27,代码来源:csved_template.cpp


示例3: 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;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:28,代码来源:csved_edit.cpp


示例4: 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 );
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:8,代码来源:csved_filesplit.cpp


示例5: cl

void DateFormatCommand :: ProcessFlags( ALib::CommandLine & cmd ) {
    ALib::CommaList cl( cmd.GetValue( FLAG_COLS, "" ) );
    CommaListToIndex( cl, mFields );
    string fmt = cmd.GetValue( FLAG_FMT, "" );
    if ( ALib::IsEmpty( fmt ) ) {
        CSVTHROW( "Empty date format" );
    }
    BuildFormat( fmt );
}
开发者ID:moissinac,项目名称:csvfix,代码行数:9,代码来源:csved_date.cpp


示例6: 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 );
	}
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:14,代码来源:csved_atable.cpp


示例7: 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;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:26,代码来源:csved_eval.cpp


示例8: 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;
}
开发者ID:purinda,项目名称:csvfix,代码行数:16,代码来源:csved_dsv.cpp


示例9: cl

void FixedCommand :: BuildFields( const ALib::CommandLine & cmd ) {

	mFields.clear();

	ALib::CommaList cl( cmd.GetValue( FLAG_COLS ) );  // chop into pairs

	if ( cl.Size() == 0 )  {
		CSVTHROW( "Need fields specified with " << FLAG_COLS << " flag" );
	}

	for ( unsigned int i = 0; i < cl.Size(); i++ ) {

		vector <string> tmp;
		if ( ALib::Split( cl.At(i), ':', tmp ) != 2 ) {
			CSVTHROW( "Invalid field specification: " << cl.At(i) );
		}

		if ( ! ALib::IsInteger( tmp[0] ) || ! ALib::IsInteger( tmp[1] ) ) {
 			CSVTHROW( "Invalid field specification: " << cl.At(i) );
		}

		unsigned int f1 = ALib::ToInteger( tmp[0] );
		unsigned int f2 = ALib::ToInteger( tmp[1] );
		if ( f1 == 0 || f2 == 0 ) {
			CSVTHROW( "Invalid field specification: " << cl.At(i) );
		}

		mFields.push_back( std::make_pair( f1, f2 ) );
	}
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:30,代码来源:csved_fixed.cpp


示例10: cl

void CallCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {

	string bs = cmd.GetValue( FLAG_BSIZE, ALib::Str( DEF_OUTBUF_SIZE ) );
	if ( ! ALib::IsInteger( bs )) {
		CSVTHROW( "Value for buffer size must be integer" );
	}
	mOutBufSize = ALib::ToInteger( bs ) * 1024;
	if ( mOutBufSize < DEF_OUTBUF_SIZE ) {
		CSVTHROW( "Output buffer size too small" );
	}
	mDLL = cmd.GetValue( FLAG_DLL );
	mFuncName = cmd.GetValue( FLAG_FUNC );
	ALib::CommaList cl( cmd.GetValue( FLAG_COLS ) );
	CommaListToIndex( cl, mFields );

}
开发者ID:bminossi,项目名称:csvfix,代码行数:16,代码来源:csved_call.cpp


示例11: cl

void SQLCommand :: BuildCols( const ALib::CommandLine & cmd,
								const string & flag,
								SQLColSpec::Vec & cols ) {

	bool havenames = false;
	cols.clear();

	if ( cmd.FlagCount( flag ) > 1 ) {
		CSVTHROW( "Need fields specified by single " << flag << " flag" );
	}

	ALib::CommaList cl( cmd.GetValue( flag ) );

	for ( unsigned int i = 0; i < cl.Size(); i++ ) {

		vector <string> tmp;

		if ( ALib::Split( cl.At(i), ':', tmp ) > 2 ) {
			CSVTHROW( "Invalid column specification: " << cl.At(i) );
		}

		if ( tmp.size() == 0 ) {
			CSVTHROW( "Empty column specification" );
		}

		if ( ! ALib::IsInteger( tmp[0] ) ) {
			CSVTHROW( "Field index must be integer in "  << cl.At(i) );
		}

		int icol = ALib::ToInteger( tmp[0] );
		if ( icol <= 0 ) {
			CSVTHROW( "Field index must be greater than xero in " << cl.At(i) );
		}

		if ( tmp.size() == 1 && havenames ) {
			CSVTHROW( "Must specify all column names" );
		}

		havenames = havenames || tmp.size() == 2;

		string colname = tmp.size() == 2 ? tmp[1] : string("");

		cols.push_back( SQLColSpec( icol - 1, colname ) );
	}
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:45,代码来源:csved_sql.cpp


示例12: 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;
}
开发者ID:purinda,项目名称:csvfix,代码行数:34,代码来源:csved_trim.cpp


示例13: 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 );
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:21,代码来源:csved_sql.cpp


示例14: GetField

static unsigned int GetField( const ALib::CommandLine & cmd,
                                const string & option ) {
    string rc = cmd.GetValue( option );
    if ( ! ALib::IsInteger( rc ) ) {
        CSVTHROW( "Value for " << option << " must be integer" );
    }
    int n = ALib::ToInteger( rc );
    if ( n <= 0 ) {
        CSVTHROW( "Value for " << option << " must be greater than zero" );
    }
    return (unsigned int) n - 1;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:12,代码来源:csved_pivot.cpp


示例15: 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;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:40,代码来源:csved_truncpad.cpp


示例16: 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;
}
开发者ID:bminossi,项目名称:csvfix,代码行数:38,代码来源:csved_fileinfo.cpp


示例17: cl

void ShuffleCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {

    string sn = cmd.GetValue( FLAG_NUM, ALib::Str(INT_MAX -1) );
    if ( ! ALib::IsInteger( sn )) {
        CSVTHROW( "Value for " << FLAG_NUM << " must be integeer" );
    }

    if ( ALib::ToInteger( sn ) < 0 ) {
        CSVTHROW( "Value for " << FLAG_NUM << " must be zero or greater" );
    }
    mCount = ALib::ToInteger( sn );

    string sr = cmd.GetValue( FLAG_RSEED, "-1" );
    if ( ! ALib::IsInteger( sr ) ) {
        CSVTHROW( "Value for " << FLAG_RSEED << " must be integer" );
    }
    int n = ALib::ToInteger( sr );
    mSeed = n < 0 ? std::time(0) : n;
    if ( cmd.HasFlag( FLAG_COLS ) ) {
        ALib::CommaList cl( cmd.GetValue( FLAG_COLS ) );
        CommaListToIndex( cl, mFields );
    }
}
开发者ID:moissinac,项目名称:csvfix,代码行数:23,代码来源:csved_shuffle.cpp


示例18: ProcessFlags

void ExcludeCommand :: ProcessFlags( const ALib::CommandLine & cmd ) {

	NotBoth( cmd, FLAG_REVCOLS, FLAG_COLS, ReqOp::Required );

	string es = cmd.GetValue( FLAG_IF, "" );
	if ( es != "" ) {
		string emsg = mExpr.Compile( es );
		if ( emsg != "" ) {
			CSVTHROW( emsg + " " + es );
		}

	}
	mReverse = cmd.HasFlag( FLAG_REVCOLS );
	string sn = cmd.GetValue( FLAG_COLS, ""  );
	if ( sn == "" ) {
		sn = cmd.GetValue( FLAG_REVCOLS, ""  );
	}
	CommaListToIndex( ALib::CommaList( sn ), mFields );
	if ( mFields.size() == 0 ) {
		CSVTHROW( "Field list  specified by " << FLAG_COLS << " or "
						<< FLAG_REVCOLS << " cannot be empty" );
	}
}
开发者ID:darrennolan,项目名称:csvfix,代码行数:23,代码来源:csved_exclude.cpp


示例19: if

void ValidateCommand :: GetOutputMode( const ALib::CommandLine & cl ) {
	string om = cl.GetValue( FLAG_OMODE, "report" );
	if ( om == "report" ) {
		mOutMode = Reports;
	}
	else if ( om == "pass" ) {
		mOutMode = Passes;
	}
	else if ( om == "fail" ) {
		mOutMode = Fails;
	}
	else {
		CSVTHROW( "Invalid value for " << FLAG_OMODE << ": " << om );
	}
}
开发者ID:bminossi,项目名称:csvfix,代码行数:15,代码来源:csved_valid.cpp


示例20: if

void DSVBase ::	ReadFlags( const ALib::CommandLine & cl ) {
    string delim = cl.GetValue( FLAG_SEP, ALib::Str( DEF_DELIM ) );
    if ( delim.size() == 0 ) {
        CSVTHROW( "Separator specified by " << FLAG_SEP
                  << " cannot be empty" );
    }
    else if ( delim.size() == 1 ) {
        mDelim = delim[0];
    }
    else if ( delim.size() == 2 && delim[0] == '\\' ) {
        if ( delim[1] == 't' ) {
            mDelim = '\t';
        }
        else {
            CSVTHROW( "Bad escaped separator specified by " << FLAG_SEP );
        }
    }
    else {
        CSVTHROW( "Bad separator specified by " << FLAG_SEP );
    }

    string fields = cl.GetValue( FLAG_COLS, "" );
    CommaListToIndex( ALib::CommaList( fields ), mFields );
}
开发者ID:purinda,项目名称:csvfix,代码行数:24,代码来源:csved_dsv.cpp



注:本文中的alib::CommandLine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ android::sp类代码示例发布时间:2022-05-31
下一篇:
C++ abccorefactory::IFactory类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap