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

Add an attribute of the specified `name` and specified `value` to the currently open element in the specified `stream`, with formatting depending on the specified `state`, and update the `state` accordingly&period; Return the `stream`&period; `value` can be of the following types&colon; `char`, `short`, `int`, `bsls&colon;&colon;Types&colon;&colon;Int64`, `float`, `double`, `bsl&colon;&colon;string`, `bdlt&colon;&colon;Datetime`, `bdlt&colon;&colon;Date`, and `bdlt&colon;&colon;Time`&period; Precede this name&equals;&quot;value&quot; pair with a single space&period; Wrap line (write the attribute on next line with proper indentation), if the length of name&equals;&quot;value&quot; is too long&period; Optionally specify a `valueFormattingMode` and `encoderOptions` to control the formatting of `value`&period; If `value` is of type `bsl&colon;&colon;string`, it is truncated at any invalid UTF&hyphen;8 byte&hyphen;sequence or any control character&period; The list of invalid control characters includes characters in the range `&lsqb;0x00, 0x20)&rsqb;` and `0x7F` (DEL) but does not include `0x9`, `0xA`, and `0x0D`&period; The five special characters&colon; apostrophe, double quote, ampersand, less than, and greater than are escaped in the output XML&period; If `value` is of type `char`, it is cast to a signed byte value with a range `&lsqb; &hyphen;128 &period;&period; 127 &rsqb;`&period; The behavior is undefined unless the last manipulator was `openElement` or `addAttribute`&period;

== Synopsis

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

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


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