From f0629555a5cafded4649eebaf46a47a4ea88a7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Wed, 20 Jul 2022 13:22:21 +0200 Subject: [PATCH] Remove useless constructors (aggregate initialization is enough for those) By the way, turn those classes into structs since all their members are public. --- src/DataTree.hh | 18 +++--------------- src/DynamicModel.hh | 6 +----- src/EquationTags.hh | 7 +------ src/ExprNode.hh | 6 +----- src/ExternalFunctionsTable.hh | 6 +----- src/SymbolList.hh | 6 +----- src/SymbolTable.hh | 30 +++++------------------------- src/macro/Driver.hh | 6 +----- 8 files changed, 14 insertions(+), 71 deletions(-) diff --git a/src/DataTree.hh b/src/DataTree.hh index 73f8a7e8..192f788f 100644 --- a/src/DataTree.hh +++ b/src/DataTree.hh @@ -140,13 +140,9 @@ public: expr_t MinusOne, MinusInfinity; //! Raised when a local parameter is declared twice - class LocalVariableException + struct LocalVariableException { - public: string name; - explicit LocalVariableException(string name_arg) : name{move(name_arg)} - { - } }; class DivisionByZeroException @@ -291,13 +287,9 @@ public: }; //! Raised when a trend is declared twice - class TrendException + struct TrendException { - public: string name; - explicit TrendException(string name_arg) : name{move(name_arg)} - { - } }; // Returns the derivation ID, or throws an exception if the derivation ID does not exist @@ -341,14 +333,10 @@ public: return false; }; - class UnknownLocalVariableException + struct UnknownLocalVariableException { - public: //! Symbol ID int id; - explicit UnknownLocalVariableException(int id_arg) : id(id_arg) - { - } }; expr_t diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index 972128f9..4d44f883 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -551,13 +551,9 @@ public: void analyzePacEquationStructure(const string &name, map<string, string> &pac_eq_name, PacModelTable::equation_info_t &pac_equation_info); // Exception thrown by getPacTargetSymbId() - class PacTargetNotIdentifiedException + struct PacTargetNotIdentifiedException { - public: const string model_name, message; - PacTargetNotIdentifiedException(string model_name_arg, string message_arg) : model_name{move(model_name_arg)}, message{move(message_arg)} - { - } }; //! Return target of the pac equation diff --git a/src/EquationTags.hh b/src/EquationTags.hh index 009c3fbb..e57753b8 100644 --- a/src/EquationTags.hh +++ b/src/EquationTags.hh @@ -31,14 +31,9 @@ class EquationTags private: map<int, map<string, string>> eqn_tags; public: - class TagNotFoundException + struct TagNotFoundException { - public: const string key, value; - explicit TagNotFoundException(string key_arg, string value_arg) - : key{move(key_arg)}, value{move(value_arg)} - { - } }; // Add multiple equation tags for the given equation diff --git a/src/ExprNode.hh b/src/ExprNode.hh index 5f5b6bfc..1fdee2c6 100644 --- a/src/ExprNode.hh +++ b/src/ExprNode.hh @@ -763,13 +763,9 @@ public: virtual pair<int, expr_t> matchEndogenousTimesConstant() const; //! Exception thrown when matching fails - class MatchFailureException + struct MatchFailureException { - public: const string message; - MatchFailureException(string message_arg) : message{move(message_arg)} - { - }; }; /* Match an expression of the form ∏ x(l)ᵏ, where x are endogenous, as used diff --git a/src/ExternalFunctionsTable.hh b/src/ExternalFunctionsTable.hh index 997f8db2..1de10d9c 100644 --- a/src/ExternalFunctionsTable.hh +++ b/src/ExternalFunctionsTable.hh @@ -33,14 +33,10 @@ class ExternalFunctionsTable { public: //! Thrown when trying to access an unknown symbol (by id) - class UnknownExternalFunctionSymbolIDException + struct UnknownExternalFunctionSymbolIDException { - public: //! Symbol ID int id; - explicit UnknownExternalFunctionSymbolIDException(int id_arg) : id{id_arg} - { - } }; /* For all arguments, -2 means not set diff --git a/src/SymbolList.hh b/src/SymbolList.hh index 6964a8bc..f8db55db 100644 --- a/src/SymbolList.hh +++ b/src/SymbolList.hh @@ -41,13 +41,9 @@ public: // This constructor is deliberately not marked explicit, to allow implicit conversion SymbolList(vector<string> symbols_arg); - class SymbolListException + struct SymbolListException { - public: const string message; - SymbolListException(string message_arg) : message{move(message_arg)} - { - }; }; //! Remove duplicate symbols void removeDuplicates(const string &dynare_command, WarningConsolidation &warnings); diff --git a/src/SymbolTable.hh b/src/SymbolTable.hh index 2e1fd2eb..fb321d2a 100644 --- a/src/SymbolTable.hh +++ b/src/SymbolTable.hh @@ -188,56 +188,36 @@ private: public: //! Thrown when trying to access an unknown symbol (by name) - class UnknownSymbolNameException + struct UnknownSymbolNameException { - public: //! Symbol name const string name; - explicit UnknownSymbolNameException(string name_arg) : name{move(name_arg)} - { - } }; //! Thrown when trying to access an unknown symbol (by id) - class UnknownSymbolIDException + struct UnknownSymbolIDException { - public: //! Symbol ID const int id; - explicit UnknownSymbolIDException(int id_arg) : id{id_arg} - { - } }; //! Thrown when trying to access an unknown type specific ID - class UnknownTypeSpecificIDException + struct UnknownTypeSpecificIDException { - public: const int tsid; const SymbolType type; - UnknownTypeSpecificIDException(int tsid_arg, SymbolType type_arg) : tsid{tsid_arg}, type{type_arg} - { - } }; /* Thrown when requesting the type specific ID of a symbol which doesn’t have one */ - class NoTypeSpecificIDException + struct NoTypeSpecificIDException { - public: const int symb_id; - explicit NoTypeSpecificIDException(int symb_id_arg) : symb_id{symb_id_arg} - { - } }; //! Thrown when trying to declare a symbol twice - class AlreadyDeclaredException + struct AlreadyDeclaredException { - public: //! Symbol name const string name; //! Was the previous declaration done with the same symbol type ? const bool same_type; - AlreadyDeclaredException(string name_arg, bool same_type_arg) : name{move(name_arg)}, same_type{same_type_arg} - { - } }; //! Thrown when table is frozen and trying to modify it class FrozenException diff --git a/src/macro/Driver.hh b/src/macro/Driver.hh index 7110c3ca..b3a897dc 100644 --- a/src/macro/Driver.hh +++ b/src/macro/Driver.hh @@ -69,13 +69,9 @@ namespace macro Driver &operator=(const Driver &) = delete; //! Exception thrown when value of an unknown variable is requested - class UnknownVariable + struct UnknownVariable { - public: const string name; - explicit UnknownVariable(string name_arg) : name{move(name_arg)} - { - } }; //! Starts parsing a file, modifies `env`, `paths` and `output` -- GitLab