text
stringlengths 0
2.2M
|
---|
bsl::ostream& Formatter_CompactImplUtil::closeElement(
|
bsl::ostream& stream,
|
State *state,
|
const bsl::string_view& name)
|
{
|
BSLS_ASSERT(StateId::e_IN_TAG == state->id() ||
|
StateId::e_FIRST_DATA_BETWEEN_TAGS == state->id() ||
|
StateId::e_TRAILING_DATA_BETWEEN_TAGS == state->id());
|
BSLS_ASSERT(0 != state->indentLevel());
|
// Step 1: Print a sequence of conditional tokens to 'stream' and update
|
// the column number and indentation level of 'state'.
|
if (StateId::e_IN_TAG == state->id()) {
|
stream << "/>";
|
state->column() += 2;
|
state->indentLevel() -= 1;
|
}
|
else {
|
stream << "</" << name << '>';
|
state->column() += 3 + static_cast<int>(name.length());
|
state->indentLevel() -= 1;
|
}
|
if (0 == state->indentLevel()) {
|
stream.flush();
|
}
|
// Step 2: Update the ID of 'state'.
|
state->id() = StateId::e_TRAILING_DATA_BETWEEN_TAGS;
|
return stream;
|
}
|
bsl::ostream& Formatter_CompactImplUtil::flush(bsl::ostream& stream,
|
State *state)
|
{
|
// Step 1: Print a sequence of conditional tokens to 'stream' and update
|
// the column number and indentation level of 'state'.
|
if (StateId::e_IN_TAG == state->id()) {
|
stream << '>';
|
state->column() += 1;
|
}
|
stream.flush();
|
// Step 2: Update the ID of 'state'.
|
if (StateId::e_IN_TAG == state->id()) {
|
state->id() = StateId::e_FIRST_DATA_BETWEEN_TAGS;
|
}
|
return stream;
|
}
|
bsl::ostream& Formatter_CompactImplUtil::openElement(
|
bsl::ostream& stream,
|
State *state,
|
const bsl::string_view& name,
|
WhitespaceType::Enum)
|
{
|
// Step 1: Print a sequence of conditional tokens to 'stream' and update
|
// the column number and indentation level of 'state'.
|
if (StateId::e_IN_TAG == state->id()) {
|
stream << '>';
|
state->column() += 1;
|
}
|
stream << '<' << name;
|
state->column() += 1 + static_cast<int>(name.length());
|
state->indentLevel() += 1;
|
// Step 2: Update the ID of 'state'.
|
state->id() = StateId::e_IN_TAG;
|
return stream;
|
}
|
} // close package namespace
|
} // close enterprise namespace
|
// ----------------------------------------------------------------------------
|
// Copyright 2021 Bloomberg Finance L.P.
|
//
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
// you may not use this file except in compliance with the License.
|
// You may obtain a copy of the License at
|
//
|
// http://www.apache.org/licenses/LICENSE-2.0
|
//
|
// Unless required by applicable law or agreed to in writing, software
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// See the License for the specific language governing permissions and
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.