Move object name validation into ConfigItemBuilder class

fixes #9911
This commit is contained in:
Gunnar Beutner 2015-08-15 09:40:42 +02:00
parent ce2735f10b
commit 1b21faeb5d
2 changed files with 6 additions and 7 deletions

View File

@ -89,6 +89,12 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
}
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();

View File

@ -141,13 +141,6 @@ public:
}
item->SetType(type);
if (name.FindFirstOf("!") != String::NPos) {
std::ostringstream msgbuf;
msgbuf << "Name for object '" << name << "' of type '" << type << "' is invalid: Object names may not contain '!'";
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debugInfo));
}
item->SetName(name);
item->AddExpression(new OwnedExpression(expression));