[英]Get output of Perforce command run using p4api
我正在使用 Perforce,又名 Helix Core,C++ API 以编程方式运行 Perforce 命令。 到目前为止,我发现的所有示例都很简短,并展示了如何建立与服务器的连接并运行命令。 但是……然后呢? 如何访问该命令的 output?
一个简单的例子:
#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... ?
(这个问题值得一个“p4api”标签。但是,我没有足够的声誉来创建一个新标签。)
ClientUser
object 收到 output。 如果您从命令行运行此代码,您将看到由 OutputInfo OutputInfo()
方法打印的p4 info
output。
如果您想对 output 做一些不同的事情,请将 ClientUser 子类ClientUser
并实现 output 做其他事情的方法。
https://www.perforce.com/manuals/v15.1/p4api/chapter.methods.html#clientuser.outputinfo
在 Perforce Workshop 中有很多这样的例子。 https://swarm.workshop.perforce.com/files/guest/sam_stafford/deepannotate/DAUserFilelog.cpp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.