typedef map<DocIterator, MacroDefinition> MacroDefList;
typedef map<docstring, MacroDefList> MacroMap;
- pair<bool, MacroDefList const &> getMacroDefinitions(docstring const & name) const
+ bool haveMacro(docstring const & name) const
+ { return macro_map_.count(name) != 0; }
+
+ // Will assert if there is no such macro, so call haveMacro first!
+ MacroDefList const & getMacroDefinitions(docstring const & name) const
{
MacroMap::const_iterator it = macro_map_.find(name);
- if (it == macro_map_.end()) {
- static MacroDefList dummy;
- return {false, dummy};
- }
- return {true, it->second};
+ LBUFERR(it != macro_map_.end());
+ return it->second;
}
set<docstring> getMacroNames() const
MacroData const * bestData = nullptr;
// find macro definitions for name
- pair<bool, MacroTable::MacroDefList const &> mdl_pair =
- macro_table.getMacroDefinitions(name);
- if (mdl_pair.first) {
- MacroTable::MacroDefList const & mdl = mdl_pair.second;
+ if (macro_table.haveMacro(name)) {
+ MacroTable::MacroDefList const & mdl =
+ macro_table.getMacroDefinitions(name);
// find last definition in front of pos
MacroTable::MacroDefList::const_iterator it =
greatest_below(mdl, pos);
{
// look where the child buffer is included first
Impl::BufferPositionMap::iterator it = d->children_positions.find(&child);
- if (it == d->children_positions.end())
+ if (it == d->children_positions.end()) {
+ LYXERR0("Querying parent for macro when we are not a child!");
return nullptr;
+ }
// check for macros at the inclusion position
return getMacro(name, it->second, global);