]> git.lyx.org Git - features.git/commitdiff
Ensure that InsetVSpace works with the new, simpler lyxlex syntax.
authorAngus Leeming <leeming@lyx.org>
Tue, 2 Dec 2003 12:27:07 +0000 (12:27 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 2 Dec 2003 12:27:07 +0000 (12:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8182 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetvspace.C
src/insets/insetvspace.h
src/lyxlex.C
src/lyxlex.h

index a3dd0b167929938e9b911890f1643ae453fd6bc2..6f61ab7116d12994489a60481ea123500f551883 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-02  Angus Leeming  <leeming@lyx.org>
+
+       * lyxlex.[Ch] (operator void const *): add the 'const' to the return
+       type. Add a comment in the implementation that the function uses
+       the stream's bad() function rather than fail() as the std::streams
+       would do.
 
 2003-12-02  André Pönitz  <poenitz@gmx.net>
 
index a420f98a926248b4f454149b29c0b3ccfec71df7..1a79f265ae291ac007fe8e7002cef5b406363e93 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-02  Angus Leeming  <leeming@lyx.org>
+
+       * insetvspace.[Ch] (space): new member function. Make space_ private.
+       (read): use the new, simpler lyxlex syntax.
+
 2003-12-01  André Pönitz  <poenitz@gmx.net>
 
        * insetcollapsable.[Ch]:
index 8dd06adfa313d5380edcb6916f98dea3fd6a0442..595db97a73eb406617b9757c27623a8fbcd3471b 100644 (file)
@@ -78,21 +78,21 @@ InsetVSpace::priv_dispatch(FuncRequest const & cmd,
                return InsetOld::priv_dispatch(cmd, idx, pos);
        }
 }
-               
+
 
 void InsetVSpace::read(Buffer const &, LyXLex & lex)
 {
-       if (lex.isOK()) {
-               lex.next();
-               space_ = VSpace(lex.getString());
-       }
+       BOOST_ASSERT(lex.isOK());
+       string vsp;
+       lex >> vsp;
+       if (lex)
+               space_ = VSpace(vsp);
 
-       if (lex.isOK())
-               lex.next();
-       if (lex.getString() != "\\end_inset") {
+       string end_token;
+       lex >> end_token;
+       if (end_token != "\\end_inset")
                lex.printError("Missing \\end_inset at this point. "
                               "Read: `$$Token'");
-       }
 }
 
 
@@ -232,7 +232,7 @@ InsetVSpaceMailer::InsetVSpaceMailer(InsetVSpace & inset)
 
 string const InsetVSpaceMailer::inset2string(Buffer const &) const
 {
-       return params2string(inset_.space_);
+       return params2string(inset_.space());
 }
 
 
@@ -247,7 +247,7 @@ void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
        LyXLex lex(0,0);
        lex.setStream(data);
        string name, vsp;
-       lex >> name >> vsp; 
+       lex >> name >> vsp;
        if (lex)
                vspace = VSpace(vsp);
 }
index c4fa92033780a17a24d6d33a8bf153058af6fcd3..42113b4e0ff52cb154d4e18ee638c5790e4daa36 100644 (file)
@@ -36,19 +36,21 @@ public:
                  OutputParams const &) const;
        ///
        int plaintext(Buffer const &, std::ostream &,
-           OutputParams const &) const;
+                     OutputParams const &) const;
        ///
        int linuxdoc(Buffer const &, std::ostream &,
-           OutputParams const &) const;
+                    OutputParams const &) const;
        ///
        int docbook(Buffer const &, std::ostream &,
-           OutputParams const &) const;
+                   OutputParams const &) const;
        ///
        void read(Buffer const &, LyXLex & lex);
        ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
        bool display() const { return true; }
+       /// How much?
+       VSpace const & space() const { return space_; }
 
 protected:
        ///
@@ -56,8 +58,8 @@ protected:
        DispatchResult
        priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
 
-public:
-       /// how much
+private:
+       ///
        VSpace space_;
 };
 
index 50e02c027f304c6df28b035e67c231e4ee120b6d..afda6e35ebf616a77a9bfe2911950278290a5e4f 100644 (file)
@@ -256,15 +256,19 @@ int LyXLex::findToken(char const * str[])
 }
 
 
-LyXLex::operator void *() const
+LyXLex::operator void const *() const
 {
-       return isOK() ? const_cast<LyXLex *>(this) : 0;
+       // This behaviour is NOT the same as the std::streams which would
+       // use fail() here. However, our implementation of getString() et al.
+       // can cause the eof() and fail() bits to be set, even though we
+       // haven't tried to read 'em.
+       return pimpl_->is.bad() ? 0 : this;
 }
 
 
 bool LyXLex::operator!() const
 {
-       return !isOK();
+       return pimpl_->is.bad();
 }
 
 
@@ -317,4 +321,3 @@ LyXLex & LyXLex::operator>>(bool & s)
        return *this;
 }
 
-
index 05ab00ad25358221d5d41b5baa7ebd3b950a7b9e..41da5297898f521ada2011e0e6a43def3d9b9df3 100644 (file)
@@ -55,10 +55,10 @@ public:
                LEX_TOKEN = -4
        };
 
-       /// straem is open and end of straem is not reached
+       /// stream is open and end of stream is not reached
        bool isOK() const;
        /// stream is ok
-       operator void *() const;
+       operator void const *() const;
        /// stream is not ok
        bool operator!() const;
        /// return true if able to open file, else false