[#BloombergLP-balxml-Formatter-addValidComment]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balxml.adoc[balxml]::xref:BloombergLP/balxml/Formatter.adoc[Formatter]::addValidComment
:relfileprefix: ../../../
:mrdocs:

Write the specified `comment` into the stream&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
addValidComment(
    std::string&lowbar;view const& comment,
    bool forceNewline = true,
    bool omitEnclosingWhitespace = false);
----

== Description

Optionally specify `forceNewline` that specifies if a new line should be added before the comment if it is not already on a new line&period; If `forceNewline` is not specified then a new line is inserted for comments not already on a new line&period; Also optionally specify an `omitEnclosingWhitespace` that specifies if a space character should be omitted before and after `comment`&period; If `omitEnclosingWhitespace` is not specified then a space character is inserted before and after `comment`&period; Return 0 on success, and non&hyphen;zero value otherwise&period; Note that a non&hyphen;zero return value is returned if either `comment` contains `&hyphen;&hyphen;` or if `omitEnclosingWhitespace` is `true` and `comment` ends with `&hyphen;`&period; Also note that if an element&hyphen;opening tag is not completed with a `&gt;`, `addValidComment` will add `&gt;`&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *comment*
| text of the comment to write
| *forceNewline*
| whether to force the comment onto a new line
| *omitEnclosingWhitespace*
| whether to omit spaces around the comment
|===


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