#include "support/gzstream.h"
#include "support/lstrings.h"
#include "support/mutex.h"
+#include "support/optional.h"
#include "support/os.h"
#include "support/Package.h"
#include "support/PathChanger.h"
typedef map<DocIterator, MacroDefinition> MacroDefList;
typedef map<docstring, MacroDefList> MacroMap;
- 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
+ optional<MacroDefList> getMacroDefinitions(docstring const & name) const
{
MacroMap::const_iterator it = macro_map_.find(name);
- LBUFERR(it != macro_map_.end());
+ if (it == macro_map_.end())
+ return {};
return it->second;
}
MacroData const * bestData = nullptr;
// find macro definitions for name
- if (macro_table.haveMacro(name)) {
- MacroTable::MacroDefList const & mdl =
- macro_table.getMacroDefinitions(name);
+ if (optional<MacroTable::MacroDefList> m =
+ macro_table.getMacroDefinitions(name))
+ {
+ MacroTable::MacroDefList const & mdl = m.value();
// find last definition in front of pos
MacroTable::MacroDefList::const_iterator it =
greatest_below(mdl, pos);