void EmitterState::StartedGroup(GroupType::value type) { StartedNode(); const int lastGroupIndent = (m_groups.empty() ? 0 : m_groups.back()->indent); m_curIndent += lastGroupIndent; // TODO: Create move constructors for settings types to simplify transfer std::unique_ptr<Group> pGroup(new Group(type)); // transfer settings (which last until this group is done) // // NB: if pGroup->modifiedSettings == m_modifiedSettings, // m_modifiedSettings is not changed! pGroup->modifiedSettings = std::move(m_modifiedSettings); // set up group if (GetFlowType(type) == Block) { pGroup->flowType = FlowType::Block; } else { pGroup->flowType = FlowType::Flow; } pGroup->indent = GetIndent(); m_groups.push_back(std::move(pGroup)); }
EmitterNodeType::value EmitterState::NextGroupType( GroupType::value type) const { if (type == GroupType::Seq) { if (GetFlowType(type) == Block) return EmitterNodeType::BlockSeq; else return EmitterNodeType::FlowSeq; } else { if (GetFlowType(type) == Block) return EmitterNodeType::BlockMap; else return EmitterNodeType::FlowMap; } // can't happen assert(false); return EmitterNodeType::NoType; }
void EmitterState::BeginGroup(GROUP_TYPE type) { unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top()->indent); m_curIndent += lastIndent; std::unique_ptr <Group> pGroup(new Group(type)); // transfer settings (which last until this group is done) pGroup->modifiedSettings = m_modifiedSettings; // set up group pGroup->flow = GetFlowType(type); pGroup->indent = GetIndent(); pGroup->usingLongKey = (GetMapKeyFormat() == LongKey ? true : false); m_groups.push(pGroup.release()); }