本文整理汇总了C++中Sink::SetSink方法的典型用法代码示例。如果您正苦于以下问题:C++ Sink::SetSink方法的具体用法?C++ Sink::SetSink怎么用?C++ Sink::SetSink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sink
的用法示例。
在下文中一共展示了Sink::SetSink方法的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 );
//.........这里部分代码省略.........