}
if (global) {
- data = MacroTable::globalMacros().get(name);
+ data = MacroTable::get().getMacro(name);
if (data != nullptr)
return data;
}
{
if (macro())
return &d->macroBackup_;
- if (MacroData const * data = MacroTable::globalMacros().get(name()))
+ if (MacroData const * data = MacroTable::get().getMacro(name()))
return data;
return nullptr;
}
features.require(d->required_);
else if (!d->macro_) {
// Update requires for known global macros.
- MacroData const * data = MacroTable::globalMacros().get(name());
+ MacroData const * data = MacroTable::get().getMacro(name());
if (data && !data->required().empty())
features.require(data->required());
}
// fill in global macros
macros.clear();
- MacroTable::globalMacros().getMacroNames(macros, false);
+ MacroTable::get().getMacroNames(macros, false);
//lyxerr << "Globals completion macros: ";
for (it = macros.begin(); it != macros.end(); ++it) {
//lyxerr << "\\" + *it << " ";
//
/////////////////////////////////////////////////////////////////////
-MacroTable & MacroTable::globalMacros()
+MacroTable & MacroTable::get()
{
static MacroTable theGlobalMacros;
return theGlobalMacros;
}
-MacroData const * MacroTable::get(docstring const & name) const
+MacroData const * MacroTable::getMacro(docstring const & name) const
{
const_iterator it = find(name);
return it == end() ? 0 : &it->second;
class MacroTable : public std::map<docstring, MacroData>
{
public:
+ /// We are a singleton
+ MacroTable() = default;
+ MacroTable(MacroTable const &) = delete;
+ void operator=(MacroTable const &) = delete;
+ /// the global list: our unique instance
+ static MacroTable & get();
/// Parse full "\\def..." or "\\newcommand..." or ...
iterator insert(Buffer * buf, docstring const & definition);
/// Insert pre-digested macro definition
iterator insert(docstring const & name, MacroData const & data);
///
- MacroData const * get(docstring const & name) const;
+ MacroData const * getMacro(docstring const & name) const;
///
void dump();
///
void getMacroNames(std::set<docstring> & names, bool gethidden) const;
-
- /// the global list
- static MacroTable & globalMacros();
};
required = "";
} else
htmlname = xmlname = "";
- MacroTable::iterator it = MacroTable::globalMacros().insert(
+ MacroTable::iterator it = MacroTable::get().insert(
0, from_utf8(macro));
if (!extra.empty() || !htmlname.empty() || !xmlname.empty() || !required.empty()) {
MathWordList::iterator wit = theMathWordList.find(it->first);