Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.1

# ClientUser::OutputStat( StrDict * )

Process tagged output.

Virtual? | Yes |
Class | `ClientUser` |
Arguments | `StrDict *varList` | a `StrDict` containing the information returned by the command
Returns | `void` |

## Notes

Normally, the only P4 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`:

Copy

    &gt; 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.

Copy

    void MyClientUser::OutputStat( StrDict *varList )
    {
        StrPtr *headrev;
        StrPtr *haverev;

        headrev = varList-&gt;GetVar( "headRev" );
        haverev = varList-&gt;GetVar( "haveRev" );

        printf( "By default, revision numbers are returned as strings:\n" );
        printf( "  Head revision number: %s\n", headrev-&gt;Text() );
        printf( "  Have revision number: %s\n", haverev-&gt;Text() );

        printf( "but revision numbers can be converted to integers:\n" );
        printf( "  Head revision number: %d\n", headrev-&gt;Atoi() );
        printf( "  Have revision number: %d\n", haverev-&gt;Atoi() );
    }

Your search for returned results