+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>
+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]:
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'");
- }
}
string const InsetVSpaceMailer::inset2string(Buffer const &) const
{
- return params2string(inset_.space_);
+ return params2string(inset_.space());
}
LyXLex lex(0,0);
lex.setStream(data);
string name, vsp;
- lex >> name >> vsp;
+ lex >> name >> vsp;
if (lex)
vspace = VSpace(vsp);
}
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:
///
DispatchResult
priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
-public:
- /// how much
+private:
+ ///
VSpace space_;
};
}
-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();
}
return *this;
}
-
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