ConfigItem::Ptr ConfigItemBuilder::Compile(void) { if (m_Type.IsEmpty()) { std::ostringstream msgbuf; msgbuf << "The type name of an object may not be empty: " << m_DebugInfo; BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); } if (!DynamicType::GetByName(m_Type)) { std::ostringstream msgbuf; msgbuf << "The type '" + m_Type + "' is unknown: " << m_DebugInfo; BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); } std::vector<Expression *> exprs; Array::Ptr templateArray = new Array(); templateArray->Add(m_Name); exprs.push_back(new SetExpression(MakeIndexer(ScopeThis, "templates"), OpSetAdd, new LiteralExpression(templateArray), m_DebugInfo)); DictExpression *dexpr = new DictExpression(m_Expressions, m_DebugInfo); dexpr->MakeInline(); exprs.push_back(dexpr); boost::shared_ptr<DictExpression> exprl = boost::make_shared<DictExpression>(exprs, m_DebugInfo); exprl->MakeInline(); return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter, m_DebugInfo, m_Scope, m_Zone); }
ConfigItem::Ptr ConfigItemBuilder::Compile(void) { if (m_Type.IsEmpty()) { std::ostringstream msgbuf; msgbuf << "The type name of an object may not be empty"; BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo)); } if (!ConfigType::GetByName(m_Type)) { std::ostringstream msgbuf; msgbuf << "The type '" + m_Type + "' is unknown"; BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo)); } if (m_Name.FindFirstOf("!") != String::NPos) { std::ostringstream msgbuf; msgbuf << "Name for object '" << m_Name << "' of type '" << m_Type << "' is invalid: Object names may not contain '!'"; BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo)); } std::vector<Expression *> exprs; Array::Ptr templateArray = new Array(); templateArray->Add(m_Name); exprs.push_back(new SetExpression(MakeIndexer(ScopeThis, "templates"), OpSetAdd, new LiteralExpression(templateArray), m_DebugInfo)); DictExpression *dexpr = new DictExpression(m_Expressions, m_DebugInfo); dexpr->MakeInline(); exprs.push_back(dexpr); boost::shared_ptr<DictExpression> exprl = boost::make_shared<DictExpression>(exprs, m_DebugInfo); exprl->MakeInline(); return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter, m_IgnoreOnError, m_DebugInfo, m_Scope, m_Zone, m_Package); }