[#BloombergLP-bslim-Printer-printAttribute-05]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslim.adoc[bslim]::xref:BloombergLP/bslim/Printer.adoc[Printer]::printAttribute
:relfileprefix: ../../../
:mrdocs:

Format to the output stream supplied at construction the specified `data`, prefixed by the specified `name`&period; Format `data` based on the parameterized `TYPE`&colon;

== Synopsis

Declared in `&lt;bslim&lowbar;printer&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
void
printAttribute(
    xref:BloombergLP/bslstl/StringRef.adoc[bslstl::StringRef] const& name,
    TYPE const& data) const;
----

== Description

&ast; If `TYPE` is a fundamental type, output `data` to the stream&period; &ast; If `TYPE` is a fixed length array (`Element&lsqb;NUM&rsqb;`) and not a char array, print out all the elements of the array&period; &ast; If `TYPE` is `void &ast; or `const void &ast;&apos;, or function pointer, print the address value of `data` in hexadecimal format if it is not 0, and print the string &quot;NULL&quot; otherwise&period; &ast; If `TYPE` is `char &ast;`, `const char &ast;`, `char &lsqb;&rsqb;`, or &apos;const char `&lsqb;&rsqb;` or `bsl&colon;&colon;string` print `data` to the stream as a null&hyphen;terminated C&hyphen;style string enclosed in quotes if `data` is not 0, and print the string &quot;NULL&quot; otherwise&period; &ast; If `TYPE` is a pointer type (other than the, potentially const&hyphen;qualified, `char &ast;` or `void &ast;`), print the address value of `data` in hexadecimal format, then format the object at that address if `data` is not 0, and print the string &quot;NULL&quot; otherwise&period; There will be a compile&hyphen;time error if `data` is a pointer to a user&hyphen;defined type that does not provide a standard `print` method&period; &ast; If `TYPE` is a `bsl&colon;&colon;pair` object, print out the two elements of the pair&period; &ast; If `TYPE` is a `bslstl&colon;&colon;StringRef` object, print the referenced string enclosed in quotes (possibly including embedded 0s)&period; &ast; If `TYPE` has STL iterators (this includes all STL sequence and associative containers&colon; vector, deque, list, set, map, multiset, multimap, unordered&lowbar;set, unordered&lowbar;map, unordered&lowbar;multiset, and unordered&lowbar;multimap), print all the objects in the container&period; &ast; If `TYPE` is any other type, call the standard `print` method on `data`, specifying one additional level of indentation than the current one&period; There will be a compile&hyphen;time error if `TYPE` does not provide a standard `print` method&period;

If `spacesPerLevel() &lt; 0`, format `data` on a single line&period; Otherwise, indent `data` by `(absLevel() &plus; 1) &ast; spacesPerLevel()` blank spaces&period; The behavior is undefined if `TYPE` is a `char &ast;`, but not a null&hyphen;terminated string&period;


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