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

`encode` overloads

== Synopses

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

Encode the specified non&hyphen;modifiable `object` to the specified `formatter`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Note that encoder will use encoder options, error and warning streams specified at the construction time&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
int
xref:BloombergLP/balxml/Encoder/encode-00.adoc[encode](
    xref:BloombergLP/balxml/Formatter.adoc[Formatter]& formatter,
    TYPE const& object);
----

[.small]#xref:BloombergLP/balxml/Encoder/encode-00.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
std::ostream&
xref:BloombergLP/balxml/Encoder/encode-03.adoc[encode](
    std::ostream& stream,
    TYPE const& object);
----

[.small]#xref:BloombergLP/balxml/Encoder/encode-03.adoc[_» more&period;&period;&period;_]#

Encode the specified non&hyphen;modifiable `object` to the specified `buffer`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Note that the encoder will use encoder options, error and warning streams specified at the construction time&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
int
xref:BloombergLP/balxml/Encoder/encode-08.adoc[encode](
    std::streambuf* buffer,
    TYPE const& object);
----

[.small]#xref:BloombergLP/balxml/Encoder/encode-08.adoc[_» more&period;&period;&period;_]#


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