]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacroTable.C
Fix comment according to Enricos explanation
[lyx.git] / src / mathed / MathMacroTable.C
index c22ce605cb370a11d3c365cb6cefea83b1486e93..da31ea15deb9e5408fe433122ee96d3ec4f831b2 100644 (file)
@@ -23,6 +23,9 @@
 
 #include <sstream>
 
+
+namespace lyx {
+
 using std::endl;
 using std::istringstream;
 using std::map;
@@ -37,7 +40,7 @@ MacroData::MacroData()
 {}
 
 
-MacroData::MacroData(string const & def, int numargs, string const & disp)
+MacroData::MacroData(docstring const & def, int numargs, docstring const & disp)
        : def_(def), numargs_(numargs), disp_(disp)
 {}
 
@@ -45,6 +48,7 @@ MacroData::MacroData(string const & def, int numargs, string const & disp)
 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;
@@ -74,21 +78,13 @@ MacroTable & MacroTable::globalMacros()
 }
 
 
-// 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());
@@ -96,18 +92,17 @@ MacroData const & MacroTable::get(string const & name) const
 }
 
 
-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)
 {
-       //lyxerr << "MacroTable::insert, def: " << def << endl;
-       istringstream is(def);
-       MathMacroTemplate mac(is);
+       //lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
+       MathMacroTemplate mac(def);
        insert(mac.name(), mac.asMacroData());
 }
 
@@ -116,9 +111,12 @@ void MacroTable::dump()
 {
        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