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

C/C++ API Documentation | 2025.2

# StrBuf::Set( const StrPtr & )

Set a `StrBuf` from a reference of a `StrPtr`. Arguments are commonly instances of classes derived from the `StrPtr` class, such as `StrRef` and `StrBuf`.

Virtual? | No |
Class | `StrBuf` |
Arguments | `const StrPtr &s` | reference of the `StrPtr` instance
Returns | `void` |

## Notes

Initialize the `StrBuf` and the `StrPtr` before calling `Set()`.

Any memory allocated for the `StrBuf`'s `buffer` is separate from the memory for the `StrPtr`'s `buffer`.

## Example

Copy

    #include &lt;iostream&gt;

    #include &lt;stdhdrs.h&gt;
    #include &lt;strbuf.h&gt;

    int main( int argc, char **argv )
    {
        StrRef sr;
        StrBuf sbs;
        StrBuf sbt;

        sr.Set( "xyz" );
        sbt.Set( sr );    // set StrBuf from StrRef

        cout &lt;&lt; "sr.Text() returns \"" &lt;&lt; sr.Text() &lt;&lt; "\"\n";
        cout &lt;&lt; "sbt.Text() returns \"" &lt;&lt; sbt.Text() &lt;&lt; "\"\n\n";

        sbs.Set( "abc" );
        sbt.Set( sbs );   // set StrBuf from StrBuf

        cout &lt;&lt; "sbs.Text() returns \"" &lt;&lt; sbs.Text() &lt;&lt; "\"\n";
        cout &lt;&lt; "sbt.Text() returns \"" &lt;&lt; sbt.Text() &lt;&lt; "\"\n";
    }

Executing the preceding code produces the following output:

    sr.Text() returns "xyz"
    sbt.Text() returns "xyz"

    sbs.Text() returns "abc"
    sbt.Text() returns "abc"

Your search for returned results