From: Angus Leeming Date: Tue, 2 Dec 2003 12:27:07 +0000 (+0000) Subject: Ensure that InsetVSpace works with the new, simpler lyxlex syntax. X-Git-Tag: 1.6.10~15705 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=51fa9803d336848b91306997d3ba61b1a4b9f78b;p=features.git Ensure that InsetVSpace works with the new, simpler lyxlex syntax. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8182 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index a3dd0b1679..6f61ab7116 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-12-02 Angus Leeming + + * 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 diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index a420f98a92..1a79f265ae 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2003-12-02 Angus Leeming + + * insetvspace.[Ch] (space): new member function. Make space_ private. + (read): use the new, simpler lyxlex syntax. + 2003-12-01 André Pönitz * insetcollapsable.[Ch]: diff --git a/src/insets/insetvspace.C b/src/insets/insetvspace.C index 8dd06adfa3..595db97a73 100644 --- a/src/insets/insetvspace.C +++ b/src/insets/insetvspace.C @@ -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); } diff --git a/src/insets/insetvspace.h b/src/insets/insetvspace.h index c4fa920337..42113b4e0f 100644 --- a/src/insets/insetvspace.h +++ b/src/insets/insetvspace.h @@ -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_; }; diff --git a/src/lyxlex.C b/src/lyxlex.C index 50e02c027f..afda6e35eb 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -256,15 +256,19 @@ int LyXLex::findToken(char const * str[]) } -LyXLex::operator void *() const +LyXLex::operator void const *() const { - return isOK() ? const_cast(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; } - diff --git a/src/lyxlex.h b/src/lyxlex.h index 05ab00ad25..41da529789 100644 --- a/src/lyxlex.h +++ b/src/lyxlex.h @@ -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