ClientUser::OutputStat( StrDict * )
Process tagged output.
Virtual? |
Yes |
|
Class |
||
Arguments |
|
a |
Returns |
|
Notes
Normally, the only
Helix Core Server
command that sends output through OutputStat()
is
p4 fstat
, which always returns tagged output. Some
other commands can be made to return tagged output by setting the "tag"
protocol variable, in which case the output is in the form of a
StrDict
suitable for passing to OutputStat()
for
processing.
It is generally easier to deal with tagged output than it is to parse
standard output. The default implementation of OutputStat()
passes
each variable/value pair in the StrDict
to OutputInfo()
as a
line of text with a level of "1", with the exception of the "func" var,
which it skips. Alternate implementations can use tagged output to
extract the pieces of information desired from a given command.
See also ClientUser::OutputStatPartial( )
Example
Consider the following output from p4 fstat
:
> p4 fstat file.c ... depotFile //depot/file.c ... clientFile c:\depot\file.c ... isMapped ... headAction integrate ... headType text ... headTime 998644337 ... headRev 10 ... headChange 681 ... headModTime 998643970 ... haveRev 10
The StrDict
passed to OutputStat()
consists of eight variable/value pairs, one for each line of output, plus
a "func" entry, which is discarded by the default implementation of OutputStat()
. Other
commands can be made to return tagged output through OutputStat()
by
using the -Ztag global option at the command line.
To process tagged output differently, create a subclass of
ClientUser
with an alternate implementation of OutputStat()
. The
following simple example demonstrates how the “headRev” and “haveRev”
variables resulting from an “fstat” command can be easily extracted and
manipulated.
Other commands provide StrDict
s with different
variable/value pairs that can be processed in similar ways; use
p4 -Ztag command
to get an understanding for
what sort of information to expect.
void MyClientUser::OutputStat( StrDict *varList ) { StrPtr *headrev; StrPtr *haverev; headrev = varList->GetVar( "headRev" ); haverev = varList->GetVar( "haveRev" ); printf( "By default, revision numbers are returned as strings:\n" ); printf( " Head revision number: %s\n", headrev->Text() ); printf( " Have revision number: %s\n", haverev->Text() ); printf( "but revision numbers can be converted to integers:\n" ); printf( " Head revision number: %d\n", headrev->Atoi() ); printf( " Have revision number: %d\n", haverev->Atoi() ); }