]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
this we don't need anymore
[lyx.git] / src / Buffer.cpp
index 5f4fd995df57aee62e96d3d2974176008aafe42e..d6fdee79b1e6be755d81a32d2f88fa1885f1cd74 100644 (file)
@@ -77,6 +77,7 @@
 
 #include "graphics/Previews.h"
 
+#include "support/assert.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/ExceptionMessage.h"
@@ -116,7 +117,7 @@ namespace os = support::os;
 
 namespace {
 
-int const LYX_FORMAT = 325;
+int const LYX_FORMAT = 328;
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -214,6 +215,7 @@ public:
        InsetText inset;
 };
 
+
 /// Creates the per buffer temporary directory
 static FileName createBufferTmpDir()
 {
@@ -294,7 +296,7 @@ void Buffer::changed() const
 
 frontend::WorkAreaManager & Buffer::workAreaManager() const
 {
-       BOOST_ASSERT(d->wa_);
+       LASSERT(d->wa_, /**/);
        return *d->wa_;
 }
 
@@ -483,8 +485,8 @@ int Buffer::readHeader(Lexer & lex)
        ErrorList & errorList = d->errorLists["Parse"];
 
        while (lex.isOK()) {
-               lex.next();
-               string const token = lex.getString();
+               string token;
+               lex >> token;
 
                if (token.empty())
                        continue;
@@ -539,16 +541,14 @@ bool Buffer::readDocument(Lexer & lex)
        ErrorList & errorList = d->errorLists["Parse"];
        errorList.clear();
 
-       lex.next();
-       string const token = lex.getString();
-       if (token != "\\begin_document") {
+       if (!lex.checkFor("\\begin_document")) {
                docstring const s = _("\\begin_document is missing");
                errorList.push_back(ErrorItem(_("Document header error"),
                        s, -1, 0, 0));
        }
 
        // we are reading in a brand new document
-       BOOST_ASSERT(paragraphs().empty());
+       LASSERT(paragraphs().empty(), /**/);
 
        readHeader(lex);
 
@@ -729,38 +729,21 @@ void Buffer::setFullyLoaded(bool value)
 Buffer::ReadStatus Buffer::readFile(Lexer & lex, FileName const & filename,
                bool fromstring)
 {
-       BOOST_ASSERT(!filename.empty());
-
-       if (!lex.isOK()) {
-               Alert::error(_("Document could not be read"),
-                            bformat(_("%1$s could not be read."), from_utf8(filename.absFilename())));
-               return failure;
-       }
-
-       lex.next();
-       string const token = lex.getString();
-
-       if (!lex) {
-               Alert::error(_("Document could not be read"),
-                            bformat(_("%1$s could not be read."), from_utf8(filename.absFilename())));
-               return failure;
-       }
-
-       // the first token _must_ be...
-       if (token != "\\lyxformat") {
-               lyxerr << "Token: " << token << endl;
+       LASSERT(!filename.empty(), /**/);
 
+       // the first (non-comment) token _must_ be...
+       if (!lex.checkFor("\\lyxformat")) {
                Alert::error(_("Document format failure"),
-                            bformat(_("%1$s is not a LyX document."),
+                            bformat(_("%1$s is not a readable LyX document."),
                                       from_utf8(filename.absFilename())));
                return failure;
        }
 
-       lex.next();
-       string tmp_format = lex.getString();
+       string tmp_format;
+       lex >> tmp_format;
        //lyxerr << "LyX Format: `" << tmp_format << '\'' << endl;
        // if present remove ".," from string.
-       string::size_type dot = tmp_format.find_first_of(".,");
+       size_t dot = tmp_format.find_first_of(".,");
        //lyxerr << "           dot found at " << dot << endl;
        if (dot != string::npos)
                        tmp_format.erase(dot, 1);
@@ -1479,8 +1462,8 @@ bool Buffer::dispatch(FuncRequest const & func, bool * result)
 
 void Buffer::changeLanguage(Language const * from, Language const * to)
 {
-       BOOST_ASSERT(from);
-       BOOST_ASSERT(to);
+       LASSERT(from, /**/);
+       LASSERT(to, /**/);
 
        for_each(par_iterator_begin(),
                 par_iterator_end(),
@@ -1571,7 +1554,7 @@ bool Buffer::isBakClean() const
 
 bool Buffer::isExternallyModified(CheckMethod method) const
 {
-       BOOST_ASSERT(d->filename.exists());
+       LASSERT(d->filename.exists(), /**/);
        // if method == timestamp, check timestamp before checksum
        return (method == checksum_method 
                || d->timestamp_ != d->filename.lastModified())
@@ -2068,7 +2051,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
        InsetCode code)
 {
        //FIXME: This does not work for child documents yet.
-       BOOST_ASSERT(code == CITE_CODE);
+       LASSERT(code == CITE_CODE, /**/);
        // Check if the label 'from' appears more than once
        vector<docstring> labels;
        string paramName;