使用p4api获取Perforce命令运行的输出 我使用PrimCE,A.K.HelixCype,C++ API来编程运行一个PopeCE命令。到目前为止,我找到的所有示例都很简短,它们展示了如何建立到服务器的连接并运行该命令。但是然后呢?如何访问该命令的输出

使用p4api获取Perforce命令运行的输出 我使用PrimCE,A.K.HelixCype,C++ API来编程运行一个PopeCE命令。到目前为止,我找到的所有示例都很简短,它们展示了如何建立到服务器的连接并运行该命令。但是然后呢?如何访问该命令的输出,c++,perforce,C++,Perforce,一个简单的例子: #include <p4/clientapi.h> // Connect to server. ClientApi client; client.SetProtocol( "tag", "" ); client.Init( &e ); if ( e.Test() ) { e.Fmt( &msg ); fprintf( stderr, "%s\n", msg.Text() ); return; } // Run the command.

一个简单的例子:

#include <p4/clientapi.h>

// Connect to server.
ClientApi client;
client.SetProtocol( "tag", "" );
client.Init( &e );
if ( e.Test() )
{
  e.Fmt( &msg );
  fprintf( stderr, "%s\n", msg.Text() );
  return;
}

// Run the command.
ClientUser cu;
client.Run( "info", &cu );

// Access the output.
ummm... ?
#包括
//连接到服务器。
客户机;
client.SetProtocol(“tag”,”);
client.Init(&e);
如果(例如Test())
{
e、 Fmt&msg;
fprintf(stderr,“%s\n”,msg.Text());
返回;
}
//运行命令。
客户用户cu;
client.Run(“info”和“cu”);
//访问输出。
嗯?

(这个问题应该有一个“p4api”标记。但是,我没有足够的声誉来创建一个新标记。)

客户用户对象接收输出。如果从命令行运行此代码,您将看到
p4 info
输出由
OutputInfo()
方法打印

如果您想对输出执行一些不同的操作,可以创建子类
ClientUser
,并实现执行其他操作的输出方法


Perforce研讨会上有很多这样的例子

谢谢,这很有帮助。