[#BloombergLP-balxml-Formatter_CompactImplUtil-addValidComment] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balxml.adoc[balxml]::xref:BloombergLP/balxml/Formatter_CompactImplUtil.adoc[Formatter_CompactImplUtil]::addValidComment :relfileprefix: ../../../ :mrdocs: Write a valid XML comment into the specified `stream`. == Synopsis Declared in `<balxml_formatter_compactimpl.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static int addValidComment( std::ostream& stream, xref:BloombergLP/balxml/Formatter_CompactImplUtil/State.adoc[State]* state, std::string_view const& comment, bool forceNewline = true, bool omitEnclosingWhitespace = false); ---- == Description Formatting depends on the specified `state`, and the `state` is updated accordingly. If the optionally specified `forceNewline` is `true` then a new line is inserted for comments not already on a new line. Also optionally specify an `omitEnclosingWhitespace` that specifies if a space character should be omitted before and after `comment`. If `omitEnclosingWhitespace` is not specified then a space character is inserted before and after `comment`. Return 0 on success, and non‐zero value otherwise. Note that a non‐zero return value is returned if either `comment` contains `‐‐` or if `omitEnclosingWhitespace` is `true` and `comment` ends with `‐`. Also note that if an element‐opening tag is not completed with a `>`, `addValidComment` will add `>`. == Return Value 0 on success, and a non‐zero value otherwise == Parameters [cols="1,4"] |=== | Name| Description | *stream* | output stream | *state* | formatter state to consult and update | *comment* | comment text to write | *forceNewline* | if `true`, start on a new line | *omitEnclosingWhitespace* | if `true`, omit spaces around text |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#