]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MacroTable.h
g-brief loads babel internally. So don't load it ourselves.
[lyx.git] / src / mathed / MacroTable.h
index 6f8201f29e70c001b1ad7e93912622f47dee6f20..6c17d634709bfe7079ee06c805156914f9103046 100644 (file)
@@ -25,8 +25,8 @@ namespace lyx {
 
 class Buffer;
 class MathData;
-class MathMacroTemplate;
-class Paragraph;
+class InsetMathMacroTemplate;
+class latexkeys;
 
 enum MacroType {
        MacroTypeNewcommand,
@@ -38,11 +38,11 @@ enum MacroType {
 class MacroData {
 public:
        /// Constructor to make STL containers happy
-       MacroData(Buffer * buf = 0);
+       explicit MacroData(Buffer const * buf = 0);
        /// Create lazy MacroData which only queries the macro template when needed
-       MacroData(Buffer * buf, DocIterator const & pos);
+       MacroData(Buffer const * buf, DocIterator const & pos);
        /// Create non-lazy MacroData which directly queries the macro template
-       MacroData(Buffer * buf, MathMacroTemplate const & macro);
+       MacroData(Buffer const * buf, InsetMathMacroTemplate const & macro);
 
        ///
        docstring const & definition() const { updateData(); return definition_; }
@@ -52,15 +52,26 @@ public:
        size_t numargs() const { updateData(); return numargs_; }
        /// replace #1,#2,... by given MathAtom 0,1,.., _including_ the possible
        /// optional argument
-       void expand(std::vector<MathData> const & from, MathData & to) const;
+       /// \return whether anything was expanded
+       bool expand(std::vector<MathData> const & from, MathData & to) const;
        /// number of optional arguments
        size_t optionals() const;
        ///
        std::vector<docstring> const & defaults() const;
        ///
-       std::string const & requires() const { return requires_; }
+       std::string const required() const;
        ///
-       std::string & requires() { return requires_; }
+       bool hidden() const;
+       ///
+       docstring const xmlname() const;
+       ///
+       char const * MathMLtype() const;
+       ///
+       latexkeys const * symbol() const { return sym_; }
+       ///
+       void setSymbol(latexkeys const * sym) { sym_ = sym; }
+       ///
+       DocIterator const & pos() const { return pos_; }
 
        /// lock while being drawn to avoid recursions
        int lock() const { return ++lockCount_; }
@@ -85,7 +96,7 @@ public:
                return definition_ == x.definition_
                        && numargs_ == x.numargs_
                        && display_ == x.display_
-                       && requires_ == x.requires_
+                       && sym_ == x.sym_
                        && optionals_ == x.optionals_
                        && defaults_ == x.defaults_;
        }
@@ -94,7 +105,7 @@ public:
 
 private:
        ///
-       void queryData(MathMacroTemplate const & macro) const;
+       void queryData(InsetMathMacroTemplate const & macro) const;
        ///
        void updateData() const;
        ///
@@ -109,25 +120,25 @@ private:
        /// macros.
        mutable DocIterator pos_;
        ///
-       mutable bool queried_;
+       mutable bool queried_ = false;
        ///
        mutable docstring definition_;
        ///
-       mutable size_t numargs_;
+       mutable size_t numargs_ = 0;
        ///
        mutable docstring display_;
        ///
-       std::string requires_;
+       latexkeys const * sym_ = nullptr;
        ///
-       mutable size_t optionals_;
+       mutable size_t optionals_ = 0;
        ///
        mutable std::vector<docstring> defaults_;
        ///
-       mutable int lockCount_;
+       mutable int lockCount_ = 0;
        ///
-       mutable bool redefinition_;
+       mutable bool redefinition_ = false;
        ///
-       mutable MacroType type_;
+       mutable MacroType type_ = MacroTypeNewcommand;
 };
 
 
@@ -148,7 +159,7 @@ class MacroTable : public std::map<docstring, MacroData>
 {
 public:
        /// Parse full "\\def..." or "\\newcommand..." or ...
-       iterator insert(Buffer * buf, docstring const & definition, std::string const &);
+       iterator insert(Buffer * buf, docstring const & definition);
        /// Insert pre-digested macro definition
        iterator insert(docstring const & name, MacroData const & data);
        ///
@@ -156,7 +167,7 @@ public:
        ///
        void dump();
        ///
-       void getMacroNames(std::set<docstring> & names) const;
+       void getMacroNames(std::set<docstring> & names, bool gethidden) const;
 
        /// the global list
        static MacroTable & globalMacros();