Simplify constructors

This commit is contained in:
Yuriy Skalko 2020-11-19 13:24:04 +02:00
parent ff1ab048f1
commit f953d88c88
6 changed files with 40 additions and 49 deletions

View File

@ -18,16 +18,12 @@ namespace lyx {
class Dimension { class Dimension {
public: public:
/// constructor /// constructor
Dimension() : wid(0), asc(0), des(0) {} Dimension() = default;
/// initialize data /// initialize data
Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {} Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
///
Dimension & operator=(Dimension const & dim) = default;
Dimension & operator=(Dimension const & dim) {
wid = dim.wid;
asc = dim.asc;
des = dim.des;
return *this;
}
/// glue horizontally /// glue horizontally
void operator+=(Dimension const & dim); void operator+=(Dimension const & dim);
/// set to empty box /// set to empty box
@ -59,35 +55,33 @@ public:
/// ///
/// makes the code neither faster nor clearer /// makes the code neither faster nor clearer
/// width /// width
int wid; int wid = 0;
/// ascent /// ascent
int asc; int asc = 0;
/// descent /// descent
int des; int des = 0;
}; };
inline inline
bool operator==(Dimension const & a, Dimension const & b) bool operator==(Dimension const & a, Dimension const & b)
{ {
return a.wid == b.wid && a.asc == b.asc && a.des == b.des ; return a.wid == b.wid && a.asc == b.asc && a.des == b.des;
} }
inline inline
bool operator!=(Dimension const & a, Dimension const & b) bool operator!=(Dimension const & a, Dimension const & b)
{ {
return a.wid != b.wid || a.asc != b.asc || a.des != b.des ; return !(a == b);
} }
class Point { class Point {
public: public:
Point() Point() = default;
: x_(0), y_(0)
{}
Point(int x, int y); Point(int x, int y);
int x_, y_; int x_ = 0;
int y_ = 0;
}; };
} // namespace lyx } // namespace lyx

View File

@ -631,7 +631,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
// Set \jobname of previews to the document name (see bug 9627) // Set \jobname of previews to the document name (see bug 9627)
of << "\\def\\jobname{" of << "\\def\\jobname{"
<< from_utf8(changeExtension(buffer_.latexName(true), "")) << from_utf8(changeExtension(buffer_.latexName(), ""))
<< "}\n"; << "}\n";
LYXERR(Debug::LATEX, "Format = " << buffer_.params().getDefaultOutputFormat()); LYXERR(Debug::LATEX, "Format = " << buffer_.params().getDefaultOutputFormat());

View File

@ -47,8 +47,7 @@ namespace lyx {
MathData::MathData(Buffer * buf, const_iterator from, const_iterator to) MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
: base_type(from, to), minasc_(0), mindes_(0), slevel_(0), : base_type(from, to), buffer_(buf)
sshift_(0), buffer_(buf)
{} {}

View File

@ -68,8 +68,9 @@ public:
public: public:
/// ///
explicit MathData(Buffer * buf = 0) : minasc_(0), mindes_(0), slevel_(0), MathData() = default;
sshift_(0), buffer_(buf) {} ///
explicit MathData(Buffer * buf) : buffer_(buf) {}
/// ///
MathData(Buffer * buf, const_iterator from, const_iterator to); MathData(Buffer * buf, const_iterator from, const_iterator to);
/// ///
@ -186,11 +187,11 @@ public:
protected: protected:
/// cached values for super/subscript placement /// cached values for super/subscript placement
mutable int minasc_; mutable int minasc_ = 0;
mutable int mindes_; mutable int mindes_ = 0;
mutable int slevel_; mutable int slevel_ = 0;
mutable int sshift_; mutable int sshift_ = 0;
Buffer * buffer_; Buffer * buffer_ = nullptr;
private: private:
/// is this an exact match at this position? /// is this an exact match at this position?

View File

@ -126,11 +126,8 @@ WriteStream & operator<<(WriteStream & ws, docstring const & s)
WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex, WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex,
OutputType output, Encoding const * encoding) OutputType output, Encoding const * encoding)
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex), : os_(os), fragile_(fragile), latex_(latex),
output_(output), pendingspace_(false), pendingbrace_(false), output_(output), encoding_(encoding)
textmode_(false), locked_(false), ascii_(false), canbreakline_(true),
mathsout_(false), ulemcmd_(NONE), line_(0), encoding_(encoding),
row_entry_(TexRow::row_none), mathclass_(false)
{} {}

View File

@ -49,7 +49,7 @@ public:
/// ///
explicit WriteStream(otexrowstream & os, bool fragile = false, explicit WriteStream(otexrowstream & os, bool fragile = false,
bool latex = false, OutputType output = wsDefault, bool latex = false, OutputType output = wsDefault,
Encoding const * encoding = 0); Encoding const * encoding = nullptr);
/// ///
~WriteStream(); ~WriteStream();
/// ///
@ -116,37 +116,37 @@ private:
/// ///
otexrowstream & os_; otexrowstream & os_;
/// do we have to write \\protect sometimes /// do we have to write \\protect sometimes
bool fragile_; bool fragile_ = false;
/// are we at the beginning of an MathData? /// are we at the beginning of an MathData?
bool firstitem_; bool firstitem_ = false;
/// are we writing to .tex? /// are we writing to .tex?
int latex_; int latex_ = false;
/// output type (default, source preview, instant preview)? /// output type (default, source preview, instant preview)?
OutputType output_; OutputType output_ = wsDefault;
/// do we have a space pending? /// do we have a space pending?
bool pendingspace_; bool pendingspace_ = false;
/// do we have a brace pending? /// do we have a brace pending?
bool pendingbrace_; bool pendingbrace_ = false;
/// are we in text mode when producing latex code? /// are we in text mode when producing latex code?
bool textmode_; bool textmode_ = false;
/// are we allowed to switch mode when producing latex code? /// are we allowed to switch mode when producing latex code?
bool locked_; bool locked_ = false;
/// should we use only ascii chars when producing latex code? /// should we use only ascii chars when producing latex code?
bool ascii_; bool ascii_ = false;
/// are we allowed to output an immediately following newline? /// are we allowed to output an immediately following newline?
bool canbreakline_; bool canbreakline_ = true;
/// should we take care for striking out display math? /// should we take care for striking out display math?
bool mathsout_; bool mathsout_ = false;
/// what ulem command are we inside (none, underline, strikeout)? /// what ulem command are we inside (none, underline, strikeout)?
UlemCmdType ulemcmd_; UlemCmdType ulemcmd_ = NONE;
/// ///
int line_; int line_ = 0;
/// ///
Encoding const * encoding_; Encoding const * encoding_ = nullptr;
/// Row entry we are in /// Row entry we are in
TexRow::RowEntry row_entry_; TexRow::RowEntry row_entry_ = TexRow::row_none;
/// whether we are in a MathClass inset /// whether we are in a MathClass inset
bool mathclass_; bool mathclass_ = false;
}; };
/// ///