| 385 | } |
| 386 | |
| 387 | JSONCONS_VISITOR_RETURN_TYPE visit_begin_array(semantic_tag, const ser_context&, std::error_code& ec) final |
| 388 | { |
| 389 | if (JSONCONS_UNLIKELY(++nesting_depth_ > options_.max_nesting_depth())) |
| 390 | { |
| 391 | ec = json_errc::max_nesting_depth_exceeded; |
| 392 | JSONCONS_VISITOR_RETURN; |
| 393 | } |
| 394 | if (!stack_.empty() && stack_.back().is_array() && stack_.back().count() > 0) |
| 395 | { |
| 396 | sink_.append(comma_str_.data(),comma_str_.length()); |
| 397 | column_ += comma_str_.length(); |
| 398 | } |
| 399 | if (!stack_.empty()) |
| 400 | { |
| 401 | if (stack_.back().is_object()) |
| 402 | { |
| 403 | line_split_kind split_kind = static_cast<uint8_t>(options_.object_array_line_splits()) >= static_cast<uint8_t>(stack_.back().split_kind()) ? |
| 404 | options_.object_array_line_splits() : |
| 405 | stack_.back().split_kind(); |
| 406 | switch (split_kind) |
| 407 | { |
| 408 | case line_split_kind::same_line: |
| 409 | stack_.emplace_back(container_type::array,split_kind,false, |
| 410 | column_, column_ + open_bracket_str_.length()); |
| 411 | break; |
| 412 | case line_split_kind::new_line: |
| 413 | { |
| 414 | stack_.emplace_back(container_type::array,split_kind,true, |
| 415 | column_, column_+open_bracket_str_.length()); |
| 416 | break; |
| 417 | } |
| 418 | default: // multi_line |
| 419 | stack_.emplace_back(container_type::array,split_kind,true, |
| 420 | column_, column_+open_bracket_str_.length()); |
| 421 | break; |
| 422 | } |
| 423 | } |
| 424 | else // array |
| 425 | { |
| 426 | line_split_kind split_kind = static_cast<uint8_t>(options_.array_array_line_splits()) >= static_cast<uint8_t>(stack_.back().split_kind()) ? |
| 427 | options_.array_array_line_splits() : stack_.back().split_kind(); |
| 428 | switch (split_kind) |
| 429 | { |
| 430 | case line_split_kind::same_line: |
| 431 | if (stack_.back().is_multi_line()) |
| 432 | { |
| 433 | stack_.back().new_line_after(true); |
| 434 | new_line(); |
| 435 | } |
| 436 | stack_.emplace_back(container_type::array,split_kind, false, |
| 437 | column_, column_+open_bracket_str_.length()); |
| 438 | break; |
| 439 | case line_split_kind::new_line: |
| 440 | stack_.back().new_line_after(true); |
| 441 | new_line(); |
| 442 | stack_.emplace_back(container_type::array,split_kind, true, |
| 443 | column_, column_+open_bracket_str_.length()); |
| 444 | break; |
no test coverage detected