[#BloombergLP-balxml-Formatter_CompactImplUtil-addElementAndData]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balxml.adoc[balxml]::xref:BloombergLP/balxml/Formatter_CompactImplUtil.adoc[Formatter&lowbar;CompactImplUtil]::addElementAndData
:relfileprefix: ../../../
:mrdocs:

Add an element of the specified `name` with the specified `value` as its data content to the specified `stream`&period;

== Synopsis

Declared in `&lt;balxml&lowbar;formatter&lowbar;compactimpl&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
static
std::ostream&
addElementAndData(
    std::ostream& stream,
    xref:BloombergLP/balxml/Formatter_CompactImplUtil/State.adoc[State]* state,
    std::string&lowbar;view const& name,
    TYPE const& value,
    int formattingMode = 0,
    xref:BloombergLP/balxml/EncoderOptions.adoc[EncoderOptions] const& encoderOptions = EncoderOptions());
----

== Description

Formatting depends on the specified `state` and the optionally specified `encoderOptions`, and `state` is updated accordingly&period; Return the `stream`&period; This has the same effect as calling the following sequence&colon; &apos;openElement(name)&semi; addData(value), closeElement(name)&semi;&apos;&period; Optionally specify the `formattingMode`&period;

== Return Value

a reference to the modifiable `stream`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| output stream
| *state*
| formatter state to consult and update
| *name*
| element name
| *value*
| element data content
| *formattingMode*
| optional formatting mode for `value`
| *encoderOptions*
| optional encoder options for `value`
|===


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