MCPcopy Create free account
hub / github.com/PlayFab/gsdk / writeArrayValue

Method writeArrayValue

cpp/cppsdk/jsoncpp.cpp:4677–4718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4675}
4676
4677void StyledWriter::writeArrayValue(const Value& value) {
4678 unsigned size = value.size();
4679 if (size == 0)
4680 pushValue("[]");
4681 else {
4682 bool isArrayMultiLine = isMultilineArray(value);
4683 if (isArrayMultiLine) {
4684 writeWithIndent("[");
4685 indent();
4686 bool hasChildValue = !childValues_.empty();
4687 unsigned index = 0;
4688 for (;;) {
4689 const Value& childValue = value[index];
4690 writeCommentBeforeValue(childValue);
4691 if (hasChildValue)
4692 writeWithIndent(childValues_[index]);
4693 else {
4694 writeIndent();
4695 writeValue(childValue);
4696 }
4697 if (++index == size) {
4698 writeCommentAfterValueOnSameLine(childValue);
4699 break;
4700 }
4701 document_ += ',';
4702 writeCommentAfterValueOnSameLine(childValue);
4703 }
4704 unindent();
4705 writeWithIndent("]");
4706 } else // output on a single line
4707 {
4708 assert(childValues_.size() == size);
4709 document_ += "[ ";
4710 for (unsigned index = 0; index < size; ++index) {
4711 if (index > 0)
4712 document_ += ", ";
4713 document_ += childValues_[index];
4714 }
4715 document_ += " ]";
4716 }
4717 }
4718}
4719
4720bool StyledWriter::isMultilineArray(const Value& value) {
4721 ArrayIndex const size = value.size();

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected