| 157 | } |
| 158 | |
| 159 | void EmitterState::EndedGroup(GroupType::value type) { |
| 160 | if (m_groups.empty()) { |
| 161 | if (type == GroupType::Seq) { |
| 162 | return SetError(ErrorMsg::UNEXPECTED_END_SEQ); |
| 163 | } |
| 164 | return SetError(ErrorMsg::UNEXPECTED_END_MAP); |
| 165 | } |
| 166 | |
| 167 | if (m_hasTag) { |
| 168 | SetError(ErrorMsg::INVALID_TAG); |
| 169 | } |
| 170 | if (m_hasAnchor) { |
| 171 | SetError(ErrorMsg::INVALID_ANCHOR); |
| 172 | } |
| 173 | |
| 174 | // get rid of the current group |
| 175 | { |
| 176 | std::unique_ptr<Group> pFinishedGroup = std::move(m_groups.back()); |
| 177 | m_groups.pop_back(); |
| 178 | if (pFinishedGroup->type != type) { |
| 179 | return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // reset old settings |
| 184 | std::size_t lastIndent = (m_groups.empty() ? 0 : m_groups.back()->indent); |
| 185 | assert(m_curIndent >= lastIndent); |
| 186 | m_curIndent -= lastIndent; |
| 187 | |
| 188 | // some global settings that we changed may have been overridden |
| 189 | // by a local setting we just popped, so we need to restore them |
| 190 | m_globalModifiedSettings.restore(); |
| 191 | |
| 192 | ClearModifiedSettings(); |
| 193 | m_hasAnchor = false; |
| 194 | m_hasTag = false; |
| 195 | m_hasNonContent = false; |
| 196 | } |
| 197 | |
| 198 | EmitterNodeType::value EmitterState::CurGroupNodeType() const { |
| 199 | if (m_groups.empty()) { |
no test coverage detected