From bbc39ffe31c67506b4c03fc56fa3adcb925b6325 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 3 Jun 2015 21:35:43 +0200 Subject: Remove gratuitous classes In the process also get rid of global class processor which conflicts with enum processor on MIPS. --- odb/context.hxx | 3 ++- odb/generator.cxx | 24 ++++++++++++------------ odb/generator.hxx | 26 ++++++++------------------ odb/plugin.cxx | 18 +++++++----------- odb/processor.cxx | 4 ++-- odb/processor.hxx | 22 ++++++---------------- odb/relational/validator.cxx | 6 +++--- odb/relational/validator.hxx | 29 +++++++++-------------------- odb/validator.cxx | 13 ++++++------- odb/validator.hxx | 28 +++++++++------------------- 10 files changed, 64 insertions(+), 109 deletions(-) diff --git a/odb/context.hxx b/odb/context.hxx index 1cf002a..351bc61 100644 --- a/odb/context.hxx +++ b/odb/context.hxx @@ -41,7 +41,8 @@ typedef cutl::re::format regex_format; typedef std::vector regex_mapping; -// +// Generic exception thrown to indicate a failure when diagnostics +// has already been issued (to stderr). // class operation_failed {}; diff --git a/odb/generator.cxx b/odb/generator.cxx index e165faf..6aa5151 100644 --- a/odb/generator.cxx +++ b/odb/generator.cxx @@ -58,7 +58,7 @@ namespace if (!ifs.is_open ()) { cerr << "error: unable to open '" << p << "' in read mode" << endl; - throw generator::failed (); + throw generator_failed (); } } @@ -70,7 +70,7 @@ namespace if (!ofs.is_open ()) { cerr << "error: unable to open '" << p << "' in write mode" << endl; - throw generator::failed (); + throw generator_failed (); } } @@ -118,7 +118,7 @@ namespace } } -void generator:: +void generate (options const& ops, features& fts, semantics::unit& unit, @@ -259,7 +259,7 @@ generate (options const& ops, cerr << in_log_path << ": error: wrong database '" << old_changelog->database () << "', expected '" << db << "'" << endl; - throw generator::failed (); + throw generator_failed (); } string sn (ops.schema_name ()[db]); @@ -268,18 +268,18 @@ generate (options const& ops, cerr << in_log_path << ": error: wrong schema name '" << old_changelog->schema_name () << "', expected '" << sn << "'" << endl; - throw generator::failed (); + throw generator_failed (); } } catch (const ios_base::failure& e) { cerr << in_log_path << ": read failure" << endl; - throw failed (); + throw generator_failed (); } catch (const xml::parsing& e) { cerr << e.what () << endl; - throw failed (); + throw generator_failed (); } } @@ -976,12 +976,12 @@ generate (options const& ops, catch (const ios_base::failure& e) { cerr << out_log_path << ": write failure" << endl; - throw failed (); + throw generator_failed (); } catch (const xml::serialization& e) { cerr << e.what () << endl; - throw failed (); + throw generator_failed (); } } @@ -998,18 +998,18 @@ generate (options const& ops, { // Code generation failed. Diagnostics has already been issued. // - throw failed (); + throw generator_failed (); } catch (semantics::invalid_path const& e) { cerr << "error: '" << e.path () << "' is not a valid filesystem path" << endl; - throw failed (); + throw generator_failed (); } catch (fs::error const&) { // Auto-removal of generated files failed. Ignore it. // - throw failed (); + throw generator_failed (); } } diff --git a/odb/generator.hxx b/odb/generator.hxx index ce49295..e83d94d 100644 --- a/odb/generator.hxx +++ b/odb/generator.hxx @@ -11,23 +11,13 @@ #include #include -class generator -{ -public: - class failed {}; - - void - generate (options const&, - features&, - semantics::unit&, - semantics::path const& file, - std::vector const& inputs); - - generator () {} - -private: - generator (generator const&); - generator& operator= (generator const&); -}; +class generator_failed {}; + +void +generate (options const&, + features&, + semantics::unit&, + semantics::path const& file, + std::vector const& inputs); #endif // ODB_GENERATOR_HXX diff --git a/odb/plugin.cxx b/odb/plugin.cxx index e32f225..51f0cb1 100644 --- a/odb/plugin.cxx +++ b/odb/plugin.cxx @@ -199,27 +199,23 @@ gate_callback (void*, void*) parser p (*options_, loc_pragmas_, ns_loc_pragmas_, decl_pragmas_); auto_ptr u (p.parse (global_namespace, file_)); - features f; // Validate, pass 1. // - validator v; - v.validate (*options_, f, *u, file_, 1); + validate (*options_, f, *u, file_, 1); // Process. // - processor pr; - pr.process (*options_, f, *u, file_); + process (*options_, f, *u, file_); // Validate, pass 2. // - v.validate (*options_, f, *u, file_, 2); + validate (*options_, f, *u, file_, 2); // Generate. // - generator g; - g.generate (*options_, f, *u, file_, inputs_); + generate (*options_, f, *u, file_, inputs_); } catch (cutl::re::format const& e) { @@ -239,19 +235,19 @@ gate_callback (void*, void*) // r = 1; } - catch (validator::failed const&) + catch (validator_failed const&) { // Diagnostics has aready been issued. // r = 1; } - catch (processor::failed const&) + catch (processor_failed const&) { // Diagnostics has aready been issued. // r = 1; } - catch (generator::failed const&) + catch (generator_failed const&) { // Diagnostics has aready been issued. // diff --git a/odb/processor.cxx b/odb/processor.cxx index a808a52..3a2cb1d 100644 --- a/odb/processor.cxx +++ b/odb/processor.cxx @@ -3064,7 +3064,7 @@ namespace }; } -void processor:: +void process (options const& ops, features& f, semantics::unit& unit, @@ -3120,6 +3120,6 @@ process (options const& ops, { // Processing failed. Diagnostics has already been issued. // - throw failed (); + throw processor_failed (); } } diff --git a/odb/processor.hxx b/odb/processor.hxx index 602b999..e62dd25 100644 --- a/odb/processor.hxx +++ b/odb/processor.hxx @@ -9,22 +9,12 @@ #include #include -class processor -{ -public: - class failed {}; +class processor_failed {}; - void - process (options const&, - features&, - semantics::unit&, - semantics::path const&); - - processor () {} - -private: - processor (processor const&); - processor& operator= (processor const&); -}; +void +process (options const&, + features&, + semantics::unit&, + semantics::path const&); #endif // ODB_PROCESSOR_HXX diff --git a/odb/relational/validator.cxx b/odb/relational/validator.cxx index 1d51c9a..47f089c 100644 --- a/odb/relational/validator.cxx +++ b/odb/relational/validator.cxx @@ -528,7 +528,7 @@ namespace relational }; } - void validator:: + void validate (options const&, features&, semantics::unit& u, @@ -608,7 +608,7 @@ namespace relational } if (!valid) - throw failed (); + throw operation_failed (); if (pass == 1) { @@ -636,6 +636,6 @@ namespace relational } if (!valid) - throw failed (); + throw operation_failed (); } } diff --git a/odb/relational/validator.hxx b/odb/relational/validator.hxx index f0ede53..93360c3 100644 --- a/odb/relational/validator.hxx +++ b/odb/relational/validator.hxx @@ -11,26 +11,15 @@ namespace relational { - class validator - { - public: - struct failed {}; - - // The first pass is performed before processing. The second -- after. - // - void - validate (options const&, - features&, - semantics::unit&, - semantics::path const&, - unsigned short pass); - - validator () {} - - private: - validator (validator const&); - validator& operator= (validator const&); - }; + // The first pass is performed before processing. The second -- after. + // Throws operation_failed to signal a failure. + // + void + validate (options const&, + features&, + semantics::unit&, + semantics::path const&, + unsigned short pass); } #endif // ODB_RELATIONAL_VALIDATOR_HXX diff --git a/odb/validator.cxx b/odb/validator.cxx index 8afdeb3..938ce7d 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -1471,7 +1471,7 @@ namespace }; } -void validator:: +void validate (options const& ops, features& f, semantics::unit& u, @@ -1520,7 +1520,7 @@ validate (options const& ops, } if (!valid) - throw failed (); + throw validator_failed (); auto_ptr ctx (create_context (cerr, u, ops, f, 0)); @@ -1573,7 +1573,7 @@ validate (options const& ops, } if (!valid) - throw failed (); + throw validator_failed (); switch (db) { @@ -1589,12 +1589,11 @@ validate (options const& ops, { try { - relational::validator v; - v.validate (ops, f, u, p, pass); + relational::validate (ops, f, u, p, pass); } - catch (relational::validator::failed const&) + catch (operation_failed const&) { - throw failed (); + throw validator_failed (); } break; diff --git a/odb/validator.hxx b/odb/validator.hxx index f913049..3ffa470 100644 --- a/odb/validator.hxx +++ b/odb/validator.hxx @@ -9,25 +9,15 @@ #include #include -class validator -{ -public: - struct failed {}; +class validator_failed {}; - // The first pass is performed before processing. The second -- after. - // - void - validate (options const&, - features&, - semantics::unit&, - semantics::path const&, - unsigned short pass); - - validator () {} - -private: - validator (validator const&); - validator& operator= (validator const&); -}; +// The first pass is performed before processing. The second -- after. +// +void +validate (options const&, + features&, + semantics::unit&, + semantics::path const&, + unsigned short pass); #endif // ODB_VALIDATOR_HXX -- cgit v1.1