当前位置: 首页>>代码示例>>C++>>正文


C++ Sink::SetTerminalChar方法代码示例

本文整理汇总了C++中Sink::SetTerminalChar方法的典型用法代码示例。如果您正苦于以下问题:C++ Sink::SetTerminalChar方法的具体用法?C++ Sink::SetTerminalChar怎么用?C++ Sink::SetTerminalChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sink的用法示例。


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

示例1: main

int main( void )
{
	char			cmdString[32], buffer1[2048], buffer2[2048];
	string			currentXaction;
	int				command;
	Source			src;
	Sink			snk;
	FormatOptions	fo;
	
	snk.SetSink( stdout );
	snk.SetTerminalChar( '\n' );
	snk.SetFormatOptions( &fo );

	if( !collection.InitializeFromLog( "log.log" ) ) {
		fprintf( stderr, "Failed to initialize from log; error=%d: %s\n", 
			CondorErrno, CondorErrMsg.c_str( ) );
		exit( 1 );
	}

	printf( "'h' for help" );
	while( 1 ) {
		CondorErrMsg = "";
		CondorErrno = ERR_OK;
		printf("\n%s: ",currentXaction.empty()?"(none)":currentXaction.c_str());
		scanf( "%s", cmdString );
		command = findCommand( cmdString );

		switch( command ) {
				// xaction control
			case OPEN_XACTION: {
				scanf( "%s", buffer1 );
				if( !collection.OpenTransaction( buffer1 ) ) {
					fprintf(stderr,"Failed to open transaction: %s\n",buffer1 );
					fprintf( stderr, "%s\n", CondorErrMsg.c_str( ) );
					CondorErrMsg = "";
					continue;
				} else {
					currentXaction = buffer1;
				}
				break;
			}
				
			case COMMIT_XACTION: {
				int	outcome;
				if(!collection.CloseTransaction(currentXaction,true,outcome)||
						outcome == XACTION_ABORTED ){
					fprintf( stderr, "Failed to commit transaction: %s\n",
						currentXaction.c_str( ) );
					fprintf( stderr, "%s\n", CondorErrMsg.c_str( ) );
					CondorErrMsg = "";
				}
				currentXaction = "";
				break;
			}

			case ABORT_XACTION: {
				int outcome;
				if(!collection.CloseTransaction( currentXaction,false,outcome)||
						outcome != XACTION_ABORTED ){
					fprintf( stderr, "Failed to abort transaction: %s\n",
						currentXaction.c_str( ) );
					fprintf( stderr, "%s\n", CondorErrMsg.c_str( ) );
					CondorErrMsg = "";
				}
				currentXaction = "";
				break;
			}
			
			case SET_XACTION: {
				string	s;
				scanf( "%s", buffer1 );
				if( *buffer1 == '-' ) {
					currentXaction = "";
					break;
				}
				s = buffer1;
				if( collection.SetCurrentTransaction( s ) ) {
					currentXaction = s;
				} else {
					fprintf( stderr, "Failed to set transaction: %s\n",
						CondorErrMsg.c_str( ) );
				}
				break;
			}

				// classad control
			case ADD_CLASSAD: 
			case UPDATE_CLASSAD:
			case MODIFY_CLASSAD: {
				ClassAd	*ad=NULL;

				if( scanf( "%s", buffer1 ) != 1 ) {
					fprintf( stderr, "Error reading key\n" );
					fgets( buffer1, 2048, stdin );
					continue;
				}
				scanf( "%s", buffer2 );
				src.SetSource( buffer2 );
				if( !src.ParseClassAd( ad ) ) {
					fprintf( stderr, "Failed to parse classad: %s\n", buffer2 );
//.........这里部分代码省略.........
开发者ID:AlainRoy,项目名称:htcondor,代码行数:101,代码来源:testcoll.cpp


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