]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCommandParams.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetCommandParams.cpp
index dfbc902b9858d3da95b7d1acf735dd4568949614..2162c98666c43c2208de76fae948c6aebfe458a0 100644 (file)
@@ -35,7 +35,7 @@
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
-#include <boost/assert.hpp>
+#include "support/lassert.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -75,7 +75,7 @@ static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
        case TOC_CODE:
                return InsetTOC::findInfo(cmdName);
        default:
-               BOOST_ASSERT(false);
+               LASSERT(false, /**/);
        }
        static const ParamInfo pi;
        return pi; // to silence the warning
@@ -134,7 +134,7 @@ bool ParamInfo::operator==(ParamInfo const & rhs) const
 ParamInfo::ParamData const & 
        ParamInfo::operator[](std::string const & name) const
 {
-       BOOST_ASSERT(hasParam(name));
+       LASSERT(hasParam(name), /**/);
        const_iterator it = begin();
        const_iterator last = end();
        for (; it != last; ++it) {
@@ -202,7 +202,7 @@ string InsetCommandParams::getDefaultCmd(InsetCode code)
                case TOC_CODE:
                        return InsetTOC::defaultCommand();
                default:
-                       BOOST_ASSERT(false);
+                       LASSERT(false, /**/);
        }
        return string(); // silence the warning
 }
@@ -236,7 +236,7 @@ bool InsetCommandParams::isCompatibleCommand(InsetCode code, string const & s)
                case TOC_CODE:
                        return InsetTOC::isCompatibleCommand(s);
                default:
-                       BOOST_ASSERT(false);
+                       LASSERT(false, /**/);
        }
        return false; // silence the warning
 }
@@ -258,30 +258,12 @@ void InsetCommandParams::setCmdName(string const & name)
 
 void InsetCommandParams::read(Lexer & lex)
 {
-       if (lex.isOK()) {
-               lex.next();
-               string const insetType = lex.getString();
-               InsetCode const code = insetCode(insetType);
-               if (code != insetCode_) {
-                       lex.printError("InsetCommandParams: Attempt to change type of inset.");
-                       throw ExceptionMessage(WarningException, _("InsetCommandParams Error: "),
-                                        _("Attempt to change type of parameters."));
-               }
-       }
-
-       if (lex.isOK()) {
-               lex.next();
-               string const test = lex.getString();
-               if (test != "LatexCommand") {
-                       lex.printError("InsetCommandParams: No LatexCommand line found.");
-                       throw ExceptionMessage(WarningException, _("InsetCommandParams error: "),
-                                              _("Can't find LatexCommand line."));
-               }
-       }
-       lex.next();
-       cmdName_ = lex.getString();
-       if (!isCompatibleCommand(insetCode_, cmdName_)){
-               lex.printError("InsetCommandParams: Incompatible command name " + cmdName_ + ".");
+       lex.setContext("InsetCommandParams::read");
+       lex >> insetName(insetCode_).c_str();
+       lex >> "LatexCommand";
+       lex >> cmdName_;
+       if (!isCompatibleCommand(insetCode_, cmdName_)) {
+               lex.printError("Incompatible command name " + cmdName_ + ".");
                throw ExceptionMessage(WarningException, _("InsetCommandParams Error: "),
                                       _("Incompatible command name."));
        }
@@ -343,7 +325,7 @@ void InsetCommandParams::write(ostream & os) const
 bool InsetCommandParams::writeEmptyOptional(ParamInfo::const_iterator ci) const
 {
        if (!ci->isOptional())
-               BOOST_ASSERT(false);
+               LASSERT(false, /**/);
        ++ci; // we want to start with the next one
        ParamInfo::const_iterator end = info_.end();
        for (; ci != end; ++ci) {
@@ -413,7 +395,7 @@ docstring InsetCommandParams::getFirstNonOptParam() const
                find_if(info_.begin(), info_.end(), 
                        not1(mem_fun_ref(&ParamInfo::ParamData::isOptional)));
        if (it == info_.end())
-               BOOST_ASSERT(false);
+               LASSERT(false, return docstring());
        return (*this)[it->name()];
 }
 
@@ -421,7 +403,7 @@ docstring InsetCommandParams::getFirstNonOptParam() const
 docstring const & InsetCommandParams::operator[](string const & name) const
 {
        static const docstring dummy; //so we don't return a ref to temporary
-       BOOST_ASSERT(info_.hasParam(name));
+       LASSERT(info_.hasParam(name), return dummy);
        ParamMap::const_iterator data = params_.find(name);
        if (data == params_.end() || data->second.empty())
                return dummy;
@@ -431,7 +413,7 @@ docstring const & InsetCommandParams::operator[](string const & name) const
 
 docstring & InsetCommandParams::operator[](string const & name)
 {
-       BOOST_ASSERT(info_.hasParam(name));
+       LASSERT(info_.hasParam(name), /**/);
        return params_[name];
 }