MCPcopy Index your code
hub / github.com/Kitware/CMake / isMultilineArray

Method isMultilineArray

Utilities/cmjsoncpp/src/lib_json/json_writer.cpp:558–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558bool StyledWriter::isMultilineArray(const Value& value) {
559 ArrayIndex const size = value.size();
560 bool isMultiLine = size * 3 >= rightMargin_;
561 childValues_.clear();
562 for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
563 const Value& childValue = value[index];
564 isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
565 !childValue.empty());
566 }
567 if (!isMultiLine) // check if line length > max line length
568 {
569 childValues_.reserve(size);
570 addChildValues_ = true;
571 ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
572 for (ArrayIndex index = 0; index < size; ++index) {
573 if (hasCommentForValue(value[index])) {
574 isMultiLine = true;
575 }
576 writeValue(value[index]);
577 lineLength += static_cast<ArrayIndex>(childValues_[index].length());
578 }
579 addChildValues_ = false;
580 isMultiLine = isMultiLine || lineLength >= rightMargin_;
581 }
582 return isMultiLine;
583}
584
585void StyledWriter::pushValue(const String& value) {
586 if (addChildValues_)

Callers

nothing calls this directly

Calls 7

isArrayMethod · 0.80
isObjectMethod · 0.80
reserveMethod · 0.80
lengthMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected