本文整理汇总了C++中MacroInfo::getMacroEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ MacroInfo::getMacroEnd方法的具体用法?C++ MacroInfo::getMacroEnd怎么用?C++ MacroInfo::getMacroEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MacroInfo
的用法示例。
在下文中一共展示了MacroInfo::getMacroEnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NamespaceUDT
DDR_RC
MacroTool::addMacrosToIR(Symbol_IR *ir)
{
DDR_RC rc = DDR_RC_OK;
/* Create a map of name to IR Type for all types in the IR which
* can contain macros. This is used to add macros to existing types.
*/
unordered_map<string, Type *> irMap;
for (vector<Type *>::iterator it = ir->_types.begin(); it != ir->_types.end(); it += 1) {
NamespaceUDT *ns = dynamic_cast<NamespaceUDT *>(*it);
if (NULL != ns) {
irMap[(*it)->_name] = *it;
}
}
for (vector<MacroInfo>::iterator it = macroList.begin(); it != macroList.end(); it += 1) {
/* For each found MacroInfo which contains macros, add the macros to the IR. */
MacroInfo *macroInfo = &*it;
if (macroInfo->getNumMacros() > 0) {
NamespaceUDT *ns = NULL;
/* If there is a type of the correct name already, use it. Otherwise,
* create a new namespace to contain the macros.
*/
if (irMap.find(macroInfo->getTypeName()) == irMap.end()) {
ns = new NamespaceUDT();
ns->_name = macroInfo->getTypeName();
ir->_types.push_back(ns);
irMap[macroInfo->getTypeName()] = ns;
} else {
ns = dynamic_cast<NamespaceUDT *>(irMap[macroInfo->getTypeName()]);
}
if (NULL == ns) {
ERRMSG("Cannot find or create UDT to add macro");
rc = DDR_RC_ERROR;
break;
} else {
for (set<pair<string, string> >::iterator it = macroInfo->getMacroStart(); it != macroInfo->getMacroEnd(); ++it) {
/* Check if the macro already exists before adding it. */
bool alreadyExists = false;
for (vector<Macro>::iterator it2 = ns->_macros.begin(); it2 != ns->_macros.end(); ++it2) {
if (it2->_name == it->first) {
alreadyExists = true;
break;
}
}
if (!alreadyExists) {
ns->_macros.push_back(Macro(it->first, it->second));
}
}
}
}
}
return rc;
}