[#BloombergLP-balxml-Encoder-encode-03]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balxml.adoc[balxml]::xref:BloombergLP/balxml/Encoder.adoc[Encoder]::encode
:relfileprefix: ../../../
:mrdocs:

Encode the specified non&hyphen;modifiable `object` to the specified `stream`&period; Return a reference to `stream`&period; If an encoding error is detected, `stream&period;fail()` will be true on return&period; Note that the encoder will use encoder options, error and warning streams specified at the construction time&period; IMPORTANT&colon; The use of `stream&period;fail()` to communicate errors to the caller has two consequences&colon; 1) if `stream` is the same as the `errorStream` passed to the constructor, then the error message may be suppressed (because of the output&sol;error stream becoming invalidated) and 2) it is important to call `stream&period;clear()` after testing the stream state&period; To avoid these issues, we recommend that you use use `encodeToStream`, above, instead of this version of `encode`&period;

== Synopsis

Declared in `&lt;balxml&lowbar;encoder&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
std::ostream&
encode(
    std::ostream& stream,
    TYPE const& object);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
