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

C/C++ API Documentation | 2026.1

# StrOps::Expand( StrBuf &, StrPtr &, StrDict & )

Expand “`%var%`” strings into corresponding “`val`” strings from a `StrDict`.

Virtual? | No |
Class | `StrOps` |
Arguments | `StrBuf &o` | the output string
| `StrPtr &s` | the input string
| `StrDict &d` | the var/value pairs to look up
Returns | `void` |

## Notes

This function provides a way to quickly expand variables from a `StrDict` into a `StrBuf`.

## Example

This small program demonstrates the `Expand()` method in an `OutputStat()` implementation:

Copy

    void MyClientUser::OutputStat( StrDict *varList )
    {
        StrBuf s = StrBuf();
        s.Set( "File: %depotFile%  Rev: %rev%" );
        StrBuf o = StrBuf();
        StrOps::Expand( o, s, *varList );
        StrOps::Dump( o );
    }

    int main( int argc, char **argv )
    {
        ClientApi client;
        MyClientUser ui;
        Error e;

        client.SetProtocol( "tag", "" );
        client.Init( &amp;e );
        client.SetArgv( 1, ++argv );
        client.Run( "files", &amp;ui );
        return client.Final( &amp;e );
    }

Executing the preceding code produces the following output:

    % a.out *
    File: //depot/src/file1.c  Rev: 4
    File: //depot/src/file2.c  Rev: 2

Your search for returned results