@brief Assign node value to the current node. @param node_value A rvalue basic_node_type object to be assigned to the current node.
| 8196 | /// @brief Assign node value to the current node. |
| 8197 | /// @param node_value A rvalue basic_node_type object to be assigned to the current node. |
| 8198 | void assign_node_value(basic_node_type&& node_value, const uint32_t line, const uint32_t indent) { |
| 8199 | if (mp_current_node->is_sequence()) { |
| 8200 | FK_YAML_ASSERT(m_flow_context_depth > 0); |
| 8201 | |
| 8202 | if FK_YAML_UNLIKELY (m_flow_token_state != flow_token_state_t::NEEDS_VALUE_OR_SUFFIX) { |
| 8203 | // Flow sequence entries are not allowed to be empty. |
| 8204 | // ```yaml |
| 8205 | // [foo,,bar] |
| 8206 | // ``` |
| 8207 | throw parse_error("flow sequence entry is found without separated with a comma.", line, indent); |
| 8208 | } |
| 8209 | |
| 8210 | mp_current_node->as_seq().emplace_back(std::move(node_value)); |
| 8211 | m_flow_token_state = flow_token_state_t::NEEDS_SEPARATOR_OR_SUFFIX; |
| 8212 | return; |
| 8213 | } |
| 8214 | |
| 8215 | // a scalar node |
| 8216 | *mp_current_node = std::move(node_value); |
| 8217 | if FK_YAML_UNLIKELY (m_context_stack.empty()) { |
| 8218 | // single scalar document. |
| 8219 | return; |
| 8220 | } |
| 8221 | |
| 8222 | if FK_YAML_LIKELY (m_context_stack.back().state != context_state_t::BLOCK_MAPPING_EXPLICIT_KEY) { |
| 8223 | m_context_stack.pop_back(); |
| 8224 | mp_current_node = m_context_stack.back().p_node; |
| 8225 | |
| 8226 | if (m_flow_context_depth > 0) { |
| 8227 | m_flow_token_state = flow_token_state_t::NEEDS_SEPARATOR_OR_SUFFIX; |
| 8228 | } |
| 8229 | } |
| 8230 | } |
| 8231 | |
| 8232 | /// @brief Deserialize a detected scalar node. |
| 8233 | /// @param lexer The lexical analyzer to be used. |
no test coverage detected