From: Yuriy Skalko Date: Sun, 6 Dec 2020 09:24:01 +0000 (+0200) Subject: Extract InsetParams superclass X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a6bf0d3f44b2c479ba7f27258da9a6154a33c93c;p=features.git Extract InsetParams superclass --- diff --git a/src/Makefile.am b/src/Makefile.am index 31701f2fb1..7dec8a1a6d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -639,6 +639,7 @@ HEADERFILESINSETS = \ insets/InsetNewpage.h \ insets/InsetNomencl.h \ insets/InsetNote.h \ + insets/InsetParams.h \ insets/InsetPhantom.h \ insets/InsetQuotes.h \ insets/InsetRef.h \ diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 824ba46172..e0834a0001 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -17,6 +17,7 @@ #include "ColorCode.h" #include "InsetCode.h" +#include "InsetParams.h" #include "LayoutEnums.h" #include "OutputEnums.h" #include "OutputParams.h" diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index cc80da3ecd..a0a2334df9 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -21,15 +21,15 @@ namespace lyx { -class InsetBoxParams +class InsetBoxParams : public InsetParams { public: /// explicit InsetBoxParams(std::string const &); /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// std::string type; diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index 6106ce5a5c..fdde0a1816 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -16,7 +16,7 @@ namespace lyx { -class InsetBranchParams { +class InsetBranchParams : public InsetParams { public: /// explicit InsetBranchParams(docstring const & b = docstring()) @@ -24,9 +24,9 @@ public: InsetBranchParams(docstring const & b, bool i) : branch(b), inverted(i) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// docstring branch; /// diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h index 1800fb599d..4e417ad94d 100644 --- a/src/insets/InsetCommandParams.h +++ b/src/insets/InsetCommandParams.h @@ -15,6 +15,7 @@ #define INSETCOMMANDPARAMS_H #include "InsetCode.h" +#include "InsetParams.h" #include "support/docstring.h" @@ -115,7 +116,7 @@ private: }; -class InsetCommandParams { +class InsetCommandParams : public InsetParams { public: /// Construct parameters for inset of type \p code. explicit InsetCommandParams(InsetCode code); @@ -128,11 +129,11 @@ public: /// InsetCode code() const { return insetCode_; } /// Parse the command - void read(Lexer &); + void read(Lexer &) override; /// void Read(Lexer &, Buffer const *); /// - void write(std::ostream &) const; + void write(std::ostream &) const override; /// void Write(std::ostream & os, Buffer const * buf) const; /// Build the complete LaTeX command diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index 0fc0fba398..daa5b3181d 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -21,16 +21,16 @@ namespace lyx { struct TexString; -class InsetFloatParams +class InsetFloatParams : public InsetParams { public: /// InsetFloatParams() : type("senseless"), placement("document"), alignment("document"), wide(false), sideways(false), subfloat(false) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// std::string type; /// diff --git a/src/insets/InsetIPAMacro.h b/src/insets/InsetIPAMacro.h index 3305e6bf6e..432bb5a897 100644 --- a/src/insets/InsetIPAMacro.h +++ b/src/insets/InsetIPAMacro.h @@ -21,7 +21,7 @@ namespace lyx { class LaTeXFeatures; -class InsetIPADecoParams +class InsetIPADecoParams : public InsetParams { public: enum Type { @@ -31,9 +31,9 @@ public: /// InsetIPADecoParams(); /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Type type; }; diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h index bddb8ba380..b2038536f2 100644 --- a/src/insets/InsetIndex.h +++ b/src/insets/InsetIndex.h @@ -19,15 +19,15 @@ namespace lyx { -class InsetIndexParams { +class InsetIndexParams : public InsetParams { public: /// explicit InsetIndexParams(docstring const & b = docstring()) : index(b) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// docstring index; }; diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 41be4394ce..1a80078645 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -12,9 +12,9 @@ #ifndef INSET_LISTINGS_H #define INSET_LISTINGS_H +#include "InsetCaptionable.h" #include "InsetListingsParams.h" - namespace lyx { class LaTeXFeatures; diff --git a/src/insets/InsetListingsParams.cpp b/src/insets/InsetListingsParams.cpp index 9390d6bbe4..8ffb438797 100644 --- a/src/insets/InsetListingsParams.cpp +++ b/src/insets/InsetListingsParams.cpp @@ -9,18 +9,18 @@ */ #include -#include #include "InsetListingsParams.h" -#include "support/Length.h" #include "Lexer.h" #include "support/convert.h" #include "support/gettext.h" +#include "support/Length.h" #include "support/lstrings.h" #include "support/textutils.h" +#include #include using namespace std; diff --git a/src/insets/InsetListingsParams.h b/src/insets/InsetListingsParams.h index 90c5adb763..7497110738 100644 --- a/src/insets/InsetListingsParams.h +++ b/src/insets/InsetListingsParams.h @@ -12,13 +12,13 @@ #ifndef INSETLISTINGSPARAMS_H #define INSETLISTINGSPARAMS_H -#include "InsetCaptionable.h" +#include "InsetCollapsible.h" #include namespace lyx { -class InsetListingsParams { +class InsetListingsParams : public InsetParams { public: /// InsetListingsParams(); @@ -28,10 +28,10 @@ public: InsetCollapsible::CollapseStatus s = InsetCollapsible::Open); /// write parameters to an ostream - void write(std::ostream &) const; + void write(std::ostream &) const override; /// read parameters from an ostream - void read(Lexer &); + void read(Lexer &) override; /// valid parameter string std::string params(std::string const & sep=",") const; diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h index 3d540a8618..10f894d1e6 100644 --- a/src/insets/InsetNewline.h +++ b/src/insets/InsetNewline.h @@ -17,7 +17,7 @@ namespace lyx { -class InsetNewlineParams +class InsetNewlineParams : public InsetParams { public: /// The different kinds of spaces we support @@ -30,9 +30,9 @@ public: /// InsetNewlineParams() : kind(NEWLINE) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Kind kind; }; diff --git a/src/insets/InsetNewpage.h b/src/insets/InsetNewpage.h index f02048804d..633b81ffd7 100644 --- a/src/insets/InsetNewpage.h +++ b/src/insets/InsetNewpage.h @@ -17,7 +17,7 @@ namespace lyx { -class InsetNewpageParams +class InsetNewpageParams : public InsetParams { public: /// The different kinds of spaces we support @@ -36,9 +36,9 @@ public: /// InsetNewpageParams() : kind(NEWPAGE) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Kind kind; }; diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index aeab8f038b..bf14e14758 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -17,7 +17,7 @@ namespace lyx { -class InsetNoteParams +class InsetNoteParams : public InsetParams { public: enum Type { @@ -28,9 +28,9 @@ public: /// \c type defaults to Note InsetNoteParams(); /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Type type; }; diff --git a/src/insets/InsetParams.h b/src/insets/InsetParams.h new file mode 100644 index 0000000000..0d7060317a --- /dev/null +++ b/src/insets/InsetParams.h @@ -0,0 +1,36 @@ +// -*- C++ -*- +/** + * \file InsetParams.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Yuriy Skalko + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef INSETPARAMS_H +#define INSETPARAMS_H + +#include + +namespace lyx { + +class Lexer; + + +class InsetParams +{ +public: + /// + virtual ~InsetParams() = default; + /// + virtual void write(std::ostream & os) const = 0; + /// + virtual void read(Lexer & lex) = 0; +}; + + +} // namespace lyx + +#endif // INSETPARAMS_H diff --git a/src/insets/InsetPhantom.h b/src/insets/InsetPhantom.h index 72281df2ae..2ca9b05622 100644 --- a/src/insets/InsetPhantom.h +++ b/src/insets/InsetPhantom.h @@ -17,7 +17,7 @@ namespace lyx { -class InsetPhantomParams +class InsetPhantomParams : public InsetParams { public: enum Type { @@ -28,9 +28,9 @@ public: /// \c type defaults to Phantom InsetPhantomParams(); /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Type type; }; diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h index 9eb80dbbd5..e4a9da7621 100644 --- a/src/insets/InsetScript.h +++ b/src/insets/InsetScript.h @@ -18,7 +18,7 @@ namespace lyx { -class InsetScriptParams +class InsetScriptParams : public InsetParams { public: enum Type { @@ -28,9 +28,9 @@ public: /// \c type defaults to Subscript InsetScriptParams(); /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// int shift(FontInfo const & font) const; /// diff --git a/src/insets/InsetSeparator.h b/src/insets/InsetSeparator.h index f7e0ab9059..212d3894b4 100644 --- a/src/insets/InsetSeparator.h +++ b/src/insets/InsetSeparator.h @@ -17,7 +17,7 @@ namespace lyx { -class InsetSeparatorParams +class InsetSeparatorParams : public InsetParams { public: /// The different kinds of separators we support @@ -29,9 +29,9 @@ public: /// InsetSeparatorParams() : kind(PLAIN) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Kind kind; }; diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index 5cf7aa7303..a4fb63357f 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -24,7 +24,7 @@ namespace lyx { class LaTeXFeatures; -struct InsetSpaceParams { +struct InsetSpaceParams : public InsetParams { /// The different kinds of spaces we support enum Kind { /// Normal space ('\ ') @@ -77,9 +77,9 @@ struct InsetSpaceParams { /// explicit InsetSpaceParams(bool m = false) : kind(NORMAL), math(m) {} /// - void write(std::ostream & os) const; + void write(std::ostream & os) const override; /// - void read(Lexer & lex); + void read(Lexer & lex) override; /// Kind kind; /// diff --git a/src/insets/InsetWrap.h b/src/insets/InsetWrap.h index 02e0a202b6..bbf4000820 100644 --- a/src/insets/InsetWrap.h +++ b/src/insets/InsetWrap.h @@ -20,12 +20,12 @@ namespace lyx { -class InsetWrapParams { +class InsetWrapParams : public InsetParams { public: /// - void write(std::ostream &) const; + void write(std::ostream &) const override; /// - void read(Lexer &); + void read(Lexer &) override; /// std::string type;