#include <sstream>
+
+namespace lyx {
+
using std::endl;
using std::istringstream;
using std::map;
{}
-MacroData::MacroData(string const & def, int numargs, string const & disp)
- : def_(def), numargs_(numargs), disp_(disp)
+MacroData::MacroData(docstring const & def, int numargs, docstring const & disp, string const & requires)
+ : def_(def), numargs_(numargs), disp_(disp), requires_(requires)
{}
void MacroData::expand(vector<MathArray> const & args, MathArray & to) const
{
InsetMathSqrt inset; // Hack. Any inset with a cell would do.
+ // FIXME UNICODE
asArray(disp_.empty() ? def_ : disp_, inset.cell(0));
//lyxerr << "MathData::expand: args: " << args << endl;
//lyxerr << "MathData::expand: ar: " << inset.cell(0) << endl;
}
-// The local table.
-//MacroTable & MacroTable::localMacros()
-//{
-// static MacroTable theLocalMacros;
-// return theLocalMacros;
-//}
-
-
-bool MacroTable::has(string const & name) const
+bool MacroTable::has(docstring const & name) const
{
return find(name) != end();
}
-MacroData const & MacroTable::get(string const & name) const
+MacroData const & MacroTable::get(docstring const & name) const
{
const_iterator it = find(name);
BOOST_ASSERT(it != end());
}
-void MacroTable::insert(string const & name, MacroData const & data)
+void MacroTable::insert(docstring const & name, MacroData const & data)
{
- //lyxerr << "MacroTable::insert: " << name << endl;
+ //lyxerr << "MacroTable::insert: " << to_utf8(name) << endl;
operator[](name) = data;
}
-void MacroTable::insert(string const & def)
+void MacroTable::insert(docstring const & def, string const & requires)
{
- //lyxerr << "MacroTable::insert, def: " << def << endl;
- istringstream is(def);
- MathMacroTemplate mac(is);
- insert(mac.name(), mac.asMacroData());
+ //lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
+ MathMacroTemplate mac(def);
+ MacroData data = mac.asMacroData();
+ data.requires() = requires;
+ insert(mac.name(), data);
}
{
lyxerr << "\n------------------------------------------" << endl;
for (const_iterator it = begin(); it != end(); ++it)
- lyxerr << it->first
- << " [" << it->second.def() << "] : "
- << " [" << it->second.disp() << "] : "
+ lyxerr << to_utf8(it->first)
+ << " [" << to_utf8(it->second.def()) << "] : "
+ << " [" << to_utf8(it->second.disp()) << "] : "
<< endl;
lyxerr << "------------------------------------------" << endl;
}
+
+
+} // namespace lyx