Contributed by Robert Cowham of Vizim Worldwide. Robert is a Perforce Consulting Partner and Trainer.
This is a simple wrapper around the P4API to make it slightly easier to use from C++, and to make it similar in function to P4Ruby, P4Python etc.
Requirements:
Initally provided for Visual Studio 2008
Tested using WinUnit (you need to install).
Requires you to download P4API and currently install in p4api-2009.1.209442-vs2008_static (see .vcproj file).
See p4api.zip for full sources.
Alternatively just navigate to this area of the Perforce Public Depot and sync as usual (requires a login from support@perforce.com).
See P4APITest/TestP4API.cpp for full examples.
StrBuf errMsg;
P4Connection p4;
InitP4(p4); // Just sets Port/Client/User
p4.ParseForms();
WIN_ASSERT_ZERO(p4.Connect(errMsg), _T("Connect should work"));
p4.Run("info", 0, NULL);
WIN_ASSERT_TRUE(p4.InfoArray()->Count() > 0, _T("Some info returned."));
TraceResults(p4);
{
char *args[] = {"-s"};
p4.Run("login", 1, args);
TraceResults(p4);
}
p4.SetInput((LPCSTR) "brunopass");
p4.Run("login", 0, NULL);
TraceResults(p4);
Outputs from test harness:
See P4APITest/TEST_OUTPUT.txt.
Thanks to Tony Smith who helped along the way, and whose Ruby API provided inspiration.
See CHANGES.txt