From 8f3d3956b1e837c726859eb8bbe19dad79c54a42 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 29 Apr 2017 23:55:46 +0300 Subject: Add hxx extension for headers and lib prefix for library dirs --- mod/build-config | 23 -- mod/build-config.cxx | 2 +- mod/build-config.hxx | 23 ++ mod/buildfile | 10 +- mod/database | 27 --- mod/database-module | 73 ------ mod/database-module.cxx | 8 +- mod/database-module.hxx | 73 ++++++ mod/database.cxx | 2 +- mod/database.hxx | 27 +++ mod/diagnostics | 306 -------------------------- mod/diagnostics.cxx | 2 +- mod/diagnostics.hxx | 306 ++++++++++++++++++++++++++ mod/mod-build-force | 45 ---- mod/mod-build-force.cxx | 14 +- mod/mod-build-force.hxx | 45 ++++ mod/mod-build-log | 45 ---- mod/mod-build-log.cxx | 14 +- mod/mod-build-log.hxx | 45 ++++ mod/mod-build-result | 42 ---- mod/mod-build-result.cxx | 18 +- mod/mod-build-result.hxx | 42 ++++ mod/mod-build-task | 42 ---- mod/mod-build-task.cxx | 18 +- mod/mod-build-task.hxx | 42 ++++ mod/mod-package-details | 42 ---- mod/mod-package-details.cxx | 16 +- mod/mod-package-details.hxx | 42 ++++ mod/mod-package-search | 42 ---- mod/mod-package-search.cxx | 16 +- mod/mod-package-search.hxx | 42 ++++ mod/mod-package-version-details | 45 ---- mod/mod-package-version-details.cxx | 16 +- mod/mod-package-version-details.hxx | 45 ++++ mod/mod-repository-details | 42 ---- mod/mod-repository-details.cxx | 16 +- mod/mod-repository-details.hxx | 42 ++++ mod/mod-repository-root | 77 ------- mod/mod-repository-root.cxx | 26 +-- mod/mod-repository-root.hxx | 77 +++++++ mod/module | 201 ----------------- mod/module.cxx | 8 +- mod/module.hxx | 201 +++++++++++++++++ mod/options-types | 31 --- mod/options-types.hxx | 31 +++ mod/options.cli | 6 +- mod/page | 428 ------------------------------------ mod/page.cxx | 10 +- mod/page.hxx | 428 ++++++++++++++++++++++++++++++++++++ mod/services.cxx | 8 +- mod/types-parsers | 64 ------ mod/types-parsers.cxx | 4 +- mod/types-parsers.hxx | 64 ++++++ 53 files changed, 1682 insertions(+), 1682 deletions(-) delete mode 100644 mod/build-config create mode 100644 mod/build-config.hxx delete mode 100644 mod/database delete mode 100644 mod/database-module create mode 100644 mod/database-module.hxx create mode 100644 mod/database.hxx delete mode 100644 mod/diagnostics create mode 100644 mod/diagnostics.hxx delete mode 100644 mod/mod-build-force create mode 100644 mod/mod-build-force.hxx delete mode 100644 mod/mod-build-log create mode 100644 mod/mod-build-log.hxx delete mode 100644 mod/mod-build-result create mode 100644 mod/mod-build-result.hxx delete mode 100644 mod/mod-build-task create mode 100644 mod/mod-build-task.hxx delete mode 100644 mod/mod-package-details create mode 100644 mod/mod-package-details.hxx delete mode 100644 mod/mod-package-search create mode 100644 mod/mod-package-search.hxx delete mode 100644 mod/mod-package-version-details create mode 100644 mod/mod-package-version-details.hxx delete mode 100644 mod/mod-repository-details create mode 100644 mod/mod-repository-details.hxx delete mode 100644 mod/mod-repository-root create mode 100644 mod/mod-repository-root.hxx delete mode 100644 mod/module create mode 100644 mod/module.hxx delete mode 100644 mod/options-types create mode 100644 mod/options-types.hxx delete mode 100644 mod/page create mode 100644 mod/page.hxx delete mode 100644 mod/types-parsers create mode 100644 mod/types-parsers.hxx (limited to 'mod') diff --git a/mod/build-config b/mod/build-config deleted file mode 100644 index a5713d7..0000000 --- a/mod/build-config +++ /dev/null @@ -1,23 +0,0 @@ -// file : mod/build-config -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_BUILD_CONFIG -#define MOD_BUILD_CONFIG - -#include - -#include -#include - -namespace brep -{ - // Return pointer to the shared build configurations instance, creating one - // on the first call. Throw tab_parsing on parsing error, io_error on the - // underlying OS error. Is not thread-safe. - // - shared_ptr - shared_build_config (const path&); -} - -#endif // MOD_BUILD_CONFIG diff --git a/mod/build-config.cxx b/mod/build-config.cxx index 11be1b9..9cbd1bf 100644 --- a/mod/build-config.cxx +++ b/mod/build-config.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include diff --git a/mod/build-config.hxx b/mod/build-config.hxx new file mode 100644 index 0000000..13024dc --- /dev/null +++ b/mod/build-config.hxx @@ -0,0 +1,23 @@ +// file : mod/build-config.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_BUILD_CONFIG_HXX +#define MOD_BUILD_CONFIG_HXX + +#include + +#include +#include + +namespace brep +{ + // Return pointer to the shared build configurations instance, creating one + // on the first call. Throw tab_parsing on parsing error, io_error on the + // underlying OS error. Is not thread-safe. + // + shared_ptr + shared_build_config (const path&); +} + +#endif // MOD_BUILD_CONFIG_HXX diff --git a/mod/buildfile b/mod/buildfile index 771b52b..f845a42 100644 --- a/mod/buildfile +++ b/mod/buildfile @@ -16,7 +16,7 @@ import libs += libbutl%lib{butl} import libs += libbpkg%lib{bpkg} import libs += libbbot%lib{bbot} -include ../brep/ +include ../libbrep/ mod{brep}: \ {hxx cxx}{ build-config } \ @@ -46,7 +46,7 @@ mod{brep}: \ ../web/apache/{hxx ixx cxx}{ request } \ ../web/apache/{hxx txx cxx}{ service } \ ../web/apache/{hxx }{ stream } \ -../brep/lib{brep} $libs +../libbrep/lib{brep} $libs # Don't install any of the module's headers. # @@ -62,9 +62,9 @@ if $cli.configured # Set option prefix to the empty value to handle all unknown request # parameters uniformly with a single catch block. # - cli.options += --std c++11 -I $src_root --include-with-brackets \ ---include-prefix mod --guard-prefix MOD --generate-specifier \ ---cxx-prologue "#include " \ + cli.options += --std c++11 -I $src_root --include-with-brackets \ +--include-prefix mod --guard-prefix MOD --generate-specifier \ +--cxx-prologue "#include " \ --cli-namespace brep::cli --generate-file-scanner --suppress-usage \ --generate-modifier --generate-description --option-prefix "" diff --git a/mod/database b/mod/database deleted file mode 100644 index 9a83752..0000000 --- a/mod/database +++ /dev/null @@ -1,27 +0,0 @@ -// file : mod/database -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_DATABASE -#define MOD_DATABASE - -#include // database - -#include -#include - -namespace brep -{ - // Return pointer to the shared database instance, creating one on the first - // call. Throw odb::exception on failure. Is not thread-safe. - // - shared_ptr - shared_database (string user, - string password, - string name, - string host, - uint16_t port, - size_t max_connections); -} - -#endif // MOD_DATABASE diff --git a/mod/database-module b/mod/database-module deleted file mode 100644 index 3799e7b..0000000 --- a/mod/database-module +++ /dev/null @@ -1,73 +0,0 @@ -// file : mod/database-module -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_DATABASE_MODULE -#define MOD_DATABASE_MODULE - -#include // database - -#include -#include - -#include - -#include -#include - -namespace brep -{ - // A module that utilises the database. Specifically, it will retry the - // request in the face of recoverable database failures (deadlock, loss of - // connection, etc) up to a certain number of times. - // - class database_module: public module - { - protected: - database_module () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - database_module (const database_module&); - - // Required to avoid getting warning from clang that - // database_module::init() hides module::init() virtual functions. This - // way all functions get to the same scope and become overloaded set. - // - using module::init; - - // Initialize the package database instance. Throw odb::exception on - // failure. - // - void - init (const options::package_db&, size_t retry); - - // Initialize the build database instance and parse build configuration - // file. Throw odb::exception on database failure, tab_parsing on parsing - // error, system_error on the underlying OS error. - // - void - init (const options::build&, const options::build_db&, size_t retry); - - virtual bool - handle (request&, response&) = 0; - - protected: - size_t retry_ = 0; // Max of all retries. - - shared_ptr package_db_; - - // These are NULL if not building. - // - shared_ptr build_db_; - shared_ptr build_conf_; - - private: - virtual bool - handle (request&, response&, log&); - }; -} - -#endif // MOD_DATABASE_MODULE diff --git a/mod/database-module.cxx b/mod/database-module.cxx index e7a6883..3b5e1e1 100644 --- a/mod/database-module.cxx +++ b/mod/database-module.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // EIO @@ -12,9 +12,9 @@ #include // throw_generic_error() -#include -#include -#include +#include +#include +#include namespace brep { diff --git a/mod/database-module.hxx b/mod/database-module.hxx new file mode 100644 index 0000000..13fd529 --- /dev/null +++ b/mod/database-module.hxx @@ -0,0 +1,73 @@ +// file : mod/database-module.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_DATABASE_MODULE_HXX +#define MOD_DATABASE_MODULE_HXX + +#include // database + +#include +#include + +#include + +#include +#include + +namespace brep +{ + // A module that utilises the database. Specifically, it will retry the + // request in the face of recoverable database failures (deadlock, loss of + // connection, etc) up to a certain number of times. + // + class database_module: public module + { + protected: + database_module () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + database_module (const database_module&); + + // Required to avoid getting warning from clang that + // database_module::init() hides module::init() virtual functions. This + // way all functions get to the same scope and become overloaded set. + // + using module::init; + + // Initialize the package database instance. Throw odb::exception on + // failure. + // + void + init (const options::package_db&, size_t retry); + + // Initialize the build database instance and parse build configuration + // file. Throw odb::exception on database failure, tab_parsing on parsing + // error, system_error on the underlying OS error. + // + void + init (const options::build&, const options::build_db&, size_t retry); + + virtual bool + handle (request&, response&) = 0; + + protected: + size_t retry_ = 0; // Max of all retries. + + shared_ptr package_db_; + + // These are NULL if not building. + // + shared_ptr build_db_; + shared_ptr build_conf_; + + private: + virtual bool + handle (request&, response&, log&); + }; +} + +#endif // MOD_DATABASE_MODULE_HXX diff --git a/mod/database.cxx b/mod/database.cxx index 22a0563..67a862b 100644 --- a/mod/database.cxx +++ b/mod/database.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include diff --git a/mod/database.hxx b/mod/database.hxx new file mode 100644 index 0000000..623e65b --- /dev/null +++ b/mod/database.hxx @@ -0,0 +1,27 @@ +// file : mod/database.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_DATABASE_HXX +#define MOD_DATABASE_HXX + +#include // database + +#include +#include + +namespace brep +{ + // Return pointer to the shared database instance, creating one on the first + // call. Throw odb::exception on failure. Is not thread-safe. + // + shared_ptr + shared_database (string user, + string password, + string name, + string host, + uint16_t port, + size_t max_connections); +} + +#endif // MOD_DATABASE_HXX diff --git a/mod/diagnostics b/mod/diagnostics deleted file mode 100644 index 496f488..0000000 --- a/mod/diagnostics +++ /dev/null @@ -1,306 +0,0 @@ -// file : mod/diagnostics -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_DIAGNOSTICS -#define MOD_DIAGNOSTICS - -#include - -#include -#include - -namespace brep -{ - struct location - { - location (): line (0), column (0) {} - location (string f, uint64_t l, uint64_t c) - : file (move (f)), line (l), column (c) {} - - string file; - uint64_t line; - uint64_t column; - }; - - enum class severity {error, warning, info, trace}; - - struct diag_entry - { - severity sev; - const char* name {nullptr}; // E.g., a function name in tracing. - location loc; - string msg; - }; - - using diag_data = vector; - - // - // - template struct diag_prologue; - template struct diag_mark; - - using diag_epilogue = function; - - struct diag_record - { - template - friend const diag_record& - operator<< (const diag_record& r, const T& x) - { - r.os_ << x; - return r; - } - - diag_record () = default; - - template - explicit - diag_record (const diag_prologue& p) {*this << p;} // See below. - - template - explicit - diag_record (const diag_mark& m) {*this << m;} // See below. - - ~diag_record () noexcept(false); - - void - append (const diag_epilogue& e) const - { - if (epilogue_ == nullptr) // Keep the first epilogue (think 'fail'). - epilogue_ = &e; - - if (!data_.empty ()) - { - data_.back ().msg = os_.str (); - - // Reset the stream. There got to be a more efficient way to do it. - // - os_.clear (); - os_.str (""); - } - - data_.push_back (diag_entry ()); - } - - diag_entry& - current () const {return data_.back ();} - - // Move constructible-only type. - // - /* - @@ libstdc++ doesn't yet have the ostringstream move support. - - diag_record (diag_record&& r) - : data_ (move (r.data_)), os_ (move (r.os_)) - { - epilogue_ = r.epilogue_; - r.data_.clear (); // Empty. - } - */ - - diag_record (diag_record&& r): data_ (move (r.data_)) - { - if (!data_.empty ()) - os_ << r.os_.str (); - - epilogue_ = r.epilogue_; - r.data_.clear (); // Empty. - } - - diag_record& operator= (diag_record&&) = delete; - - diag_record (const diag_record&) = delete; - diag_record& operator= (const diag_record&) = delete; - - private: - mutable diag_data data_; - mutable std::ostringstream os_; - mutable const diag_epilogue* epilogue_ {nullptr}; - }; - - // Base (B) should provide operator() that configures diag_record. - // - template - struct diag_prologue: B - { - diag_prologue (const diag_epilogue& e): B (), epilogue_ (e) {} - - template - diag_prologue (const diag_epilogue& e, A&&... a) - : B (forward (a)...), epilogue_ (e) {} - - template - diag_record - operator<< (const T& x) const - { - diag_record r; - r.append (epilogue_); - B::operator() (r); - r << x; - return r; - } - - friend const diag_record& - operator<< (const diag_record& r, const diag_prologue& p) - { - r.append (p.epilogue_); - p (r); - return r; - } - - private: - const diag_epilogue& epilogue_; - }; - - // Base (B) should provide operator() that returns diag_prologue. - // - template - struct diag_mark: B - { - diag_mark (): B () {} - - template - diag_mark (A&&... a): B (forward (a)...) {} - - template - diag_record - operator<< (const T& x) const - { - return B::operator() () << x; - } - - friend const diag_record& - operator<< (const diag_record& r, const diag_mark& m) - { - return r << m (); - } - }; - - // Prologues. - // - struct simple_prologue_base - { - explicit - simple_prologue_base (severity s, const char* name) - : sev_ (s), name_ (name) {} - - void - operator() (const diag_record& r) const - { - diag_entry& e (r.current ()); - e.sev = sev_; - e.name = name_; - } - - private: - severity sev_; - const char* name_; - }; - typedef diag_prologue simple_prologue; - - struct location_prologue_base - { - location_prologue_base (severity s, - const char* name, - const location& l) - : sev_ (s), name_ (name), loc_ (l) {} - - void - operator() (const diag_record& r) const - { - diag_entry& e (r.current ()); - e.sev = sev_; - e.name = name_; - e.loc = loc_; //@@ I think we can probably move it. - } - - private: - severity sev_; - const char* name_; - const location loc_; - }; - typedef diag_prologue location_prologue; - - // Marks. - // - struct basic_mark_base - { - explicit - basic_mark_base (severity s, - const diag_epilogue& e, - const char* name = nullptr, - const void* data = nullptr) - : sev_ (s), epilogue_ (e), name_ (name), data_ (data) {} - - simple_prologue - operator() () const - { - return simple_prologue (epilogue_, sev_, name_); - } - - location_prologue - operator() (const location& l) const - { - return location_prologue (epilogue_, sev_, name_, l); - } - - template - location_prologue - operator() (const L& l) const - { - // get_location() is the user-supplied ADL-searched function. - // - return location_prologue ( - epilogue_, sev_, name_, get_location (l, data_)); - } - - private: - severity sev_; - const diag_epilogue& epilogue_; - const char* name_; - const void* data_; - }; - typedef diag_mark basic_mark; - - template - struct fail_mark_base - { - explicit - fail_mark_base (const char* name = nullptr, const void* data = nullptr) - : name_ (name), data_ (data) {} - - simple_prologue - operator() () const - { - return simple_prologue (epilogue_, severity::error, name_); - } - - location_prologue - operator() (const location& l) const - { - return location_prologue (epilogue_, severity::error, name_, l); - } - - template - location_prologue - operator() (const L& l) const - { - return location_prologue ( - epilogue_, severity::error, name_, get_location (l, data_)); - } - - static void - epilogue (diag_data&& d) {throw E (move (d));} - - private: - const diag_epilogue epilogue_ {&epilogue}; - const char* name_; - const void* data_; - }; - - template - using fail_mark = diag_mark>; -} - -#endif // MOD_DIAGNOSTICS diff --git a/mod/diagnostics.cxx b/mod/diagnostics.cxx index 066c4b2..c2f3f52 100644 --- a/mod/diagnostics.cxx +++ b/mod/diagnostics.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include using namespace std; diff --git a/mod/diagnostics.hxx b/mod/diagnostics.hxx new file mode 100644 index 0000000..e05d56a --- /dev/null +++ b/mod/diagnostics.hxx @@ -0,0 +1,306 @@ +// file : mod/diagnostics.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_DIAGNOSTICS_HXX +#define MOD_DIAGNOSTICS_HXX + +#include + +#include +#include + +namespace brep +{ + struct location + { + location (): line (0), column (0) {} + location (string f, uint64_t l, uint64_t c) + : file (move (f)), line (l), column (c) {} + + string file; + uint64_t line; + uint64_t column; + }; + + enum class severity {error, warning, info, trace}; + + struct diag_entry + { + severity sev; + const char* name {nullptr}; // E.g., a function name in tracing. + location loc; + string msg; + }; + + using diag_data = vector; + + // + // + template struct diag_prologue; + template struct diag_mark; + + using diag_epilogue = function; + + struct diag_record + { + template + friend const diag_record& + operator<< (const diag_record& r, const T& x) + { + r.os_ << x; + return r; + } + + diag_record () = default; + + template + explicit + diag_record (const diag_prologue& p) {*this << p;} // See below. + + template + explicit + diag_record (const diag_mark& m) {*this << m;} // See below. + + ~diag_record () noexcept(false); + + void + append (const diag_epilogue& e) const + { + if (epilogue_ == nullptr) // Keep the first epilogue (think 'fail'). + epilogue_ = &e; + + if (!data_.empty ()) + { + data_.back ().msg = os_.str (); + + // Reset the stream. There got to be a more efficient way to do it. + // + os_.clear (); + os_.str (""); + } + + data_.push_back (diag_entry ()); + } + + diag_entry& + current () const {return data_.back ();} + + // Move constructible-only type. + // + /* + @@ libstdc++ doesn't yet have the ostringstream move support. + + diag_record (diag_record&& r) + : data_ (move (r.data_)), os_ (move (r.os_)) + { + epilogue_ = r.epilogue_; + r.data_.clear (); // Empty. + } + */ + + diag_record (diag_record&& r): data_ (move (r.data_)) + { + if (!data_.empty ()) + os_ << r.os_.str (); + + epilogue_ = r.epilogue_; + r.data_.clear (); // Empty. + } + + diag_record& operator= (diag_record&&) = delete; + + diag_record (const diag_record&) = delete; + diag_record& operator= (const diag_record&) = delete; + + private: + mutable diag_data data_; + mutable std::ostringstream os_; + mutable const diag_epilogue* epilogue_ {nullptr}; + }; + + // Base (B) should provide operator() that configures diag_record. + // + template + struct diag_prologue: B + { + diag_prologue (const diag_epilogue& e): B (), epilogue_ (e) {} + + template + diag_prologue (const diag_epilogue& e, A&&... a) + : B (forward (a)...), epilogue_ (e) {} + + template + diag_record + operator<< (const T& x) const + { + diag_record r; + r.append (epilogue_); + B::operator() (r); + r << x; + return r; + } + + friend const diag_record& + operator<< (const diag_record& r, const diag_prologue& p) + { + r.append (p.epilogue_); + p (r); + return r; + } + + private: + const diag_epilogue& epilogue_; + }; + + // Base (B) should provide operator() that returns diag_prologue. + // + template + struct diag_mark: B + { + diag_mark (): B () {} + + template + diag_mark (A&&... a): B (forward (a)...) {} + + template + diag_record + operator<< (const T& x) const + { + return B::operator() () << x; + } + + friend const diag_record& + operator<< (const diag_record& r, const diag_mark& m) + { + return r << m (); + } + }; + + // Prologues. + // + struct simple_prologue_base + { + explicit + simple_prologue_base (severity s, const char* name) + : sev_ (s), name_ (name) {} + + void + operator() (const diag_record& r) const + { + diag_entry& e (r.current ()); + e.sev = sev_; + e.name = name_; + } + + private: + severity sev_; + const char* name_; + }; + typedef diag_prologue simple_prologue; + + struct location_prologue_base + { + location_prologue_base (severity s, + const char* name, + const location& l) + : sev_ (s), name_ (name), loc_ (l) {} + + void + operator() (const diag_record& r) const + { + diag_entry& e (r.current ()); + e.sev = sev_; + e.name = name_; + e.loc = loc_; //@@ I think we can probably move it. + } + + private: + severity sev_; + const char* name_; + const location loc_; + }; + typedef diag_prologue location_prologue; + + // Marks. + // + struct basic_mark_base + { + explicit + basic_mark_base (severity s, + const diag_epilogue& e, + const char* name = nullptr, + const void* data = nullptr) + : sev_ (s), epilogue_ (e), name_ (name), data_ (data) {} + + simple_prologue + operator() () const + { + return simple_prologue (epilogue_, sev_, name_); + } + + location_prologue + operator() (const location& l) const + { + return location_prologue (epilogue_, sev_, name_, l); + } + + template + location_prologue + operator() (const L& l) const + { + // get_location() is the user-supplied ADL-searched function. + // + return location_prologue ( + epilogue_, sev_, name_, get_location (l, data_)); + } + + private: + severity sev_; + const diag_epilogue& epilogue_; + const char* name_; + const void* data_; + }; + typedef diag_mark basic_mark; + + template + struct fail_mark_base + { + explicit + fail_mark_base (const char* name = nullptr, const void* data = nullptr) + : name_ (name), data_ (data) {} + + simple_prologue + operator() () const + { + return simple_prologue (epilogue_, severity::error, name_); + } + + location_prologue + operator() (const location& l) const + { + return location_prologue (epilogue_, severity::error, name_, l); + } + + template + location_prologue + operator() (const L& l) const + { + return location_prologue ( + epilogue_, severity::error, name_, get_location (l, data_)); + } + + static void + epilogue (diag_data&& d) {throw E (move (d));} + + private: + const diag_epilogue epilogue_ {&epilogue}; + const char* name_; + const void* data_; + }; + + template + using fail_mark = diag_mark>; +} + +#endif // MOD_DIAGNOSTICS_HXX diff --git a/mod/mod-build-force b/mod/mod-build-force deleted file mode 100644 index 3fa723d..0000000 --- a/mod/mod-build-force +++ /dev/null @@ -1,45 +0,0 @@ -// file : mod/mod-build-force -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_BUILD_FORCE -#define MOD_MOD_BUILD_FORCE - -#include -#include - -#include -#include - -namespace brep -{ - class build_force: public database_module - { - public: - build_force () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - build_force (const build_force&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const - { - return options::build_force::description (); - } - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_BUILD_FORCE diff --git a/mod/mod-build-force.cxx b/mod/mod-build-force.cxx index 1db25d1..e0c641e 100644 --- a/mod/mod-build-force.cxx +++ b/mod/mod-build-force.cxx @@ -2,21 +2,21 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // replace() #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include using namespace std; using namespace bbot; diff --git a/mod/mod-build-force.hxx b/mod/mod-build-force.hxx new file mode 100644 index 0000000..02b6ea4 --- /dev/null +++ b/mod/mod-build-force.hxx @@ -0,0 +1,45 @@ +// file : mod/mod-build-force.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_BUILD_FORCE_HXX +#define MOD_MOD_BUILD_FORCE_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class build_force: public database_module + { + public: + build_force () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + build_force (const build_force&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const + { + return options::build_force::description (); + } + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_BUILD_FORCE_HXX diff --git a/mod/mod-build-log b/mod/mod-build-log deleted file mode 100644 index 8395546..0000000 --- a/mod/mod-build-log +++ /dev/null @@ -1,45 +0,0 @@ -// file : mod/mod-build-log -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_BUILD_LOG -#define MOD_MOD_BUILD_LOG - -#include -#include - -#include -#include - -namespace brep -{ - class build_log: public database_module - { - public: - build_log () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - build_log (const build_log&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const - { - return options::build_log::description (); - } - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_BUILD_LOG diff --git a/mod/mod-build-log.cxx b/mod/mod-build-log.cxx index 3dddd82..09591b9 100644 --- a/mod/mod-build-log.cxx +++ b/mod/mod-build-log.cxx @@ -2,21 +2,21 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // find_if() #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include using namespace std; using namespace bbot; diff --git a/mod/mod-build-log.hxx b/mod/mod-build-log.hxx new file mode 100644 index 0000000..76e99c7 --- /dev/null +++ b/mod/mod-build-log.hxx @@ -0,0 +1,45 @@ +// file : mod/mod-build-log.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_BUILD_LOG_HXX +#define MOD_MOD_BUILD_LOG_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class build_log: public database_module + { + public: + build_log () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + build_log (const build_log&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const + { + return options::build_log::description (); + } + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_BUILD_LOG_HXX diff --git a/mod/mod-build-result b/mod/mod-build-result deleted file mode 100644 index 8afa697..0000000 --- a/mod/mod-build-result +++ /dev/null @@ -1,42 +0,0 @@ -// file : mod/mod-build-result -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_BUILD_RESULT -#define MOD_MOD_BUILD_RESULT - -#include -#include - -#include -#include - -namespace brep -{ - class build_result: public database_module - { - public: - build_result () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - build_result (const build_result&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const {return options::build_result::description ();} - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_BUILD_RESULT diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx index 23381de..d6ec5e9 100644 --- a/mod/mod-build-result.cxx +++ b/mod/mod-build-result.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // find_if() @@ -11,20 +11,20 @@ #include #include -#include +#include #include #include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/mod/mod-build-result.hxx b/mod/mod-build-result.hxx new file mode 100644 index 0000000..4af9b1b --- /dev/null +++ b/mod/mod-build-result.hxx @@ -0,0 +1,42 @@ +// file : mod/mod-build-result.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_BUILD_RESULT_HXX +#define MOD_MOD_BUILD_RESULT_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class build_result: public database_module + { + public: + build_result () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + build_result (const build_result&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const {return options::build_result::description ();} + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_BUILD_RESULT_HXX diff --git a/mod/mod-build-task b/mod/mod-build-task deleted file mode 100644 index 051357e..0000000 --- a/mod/mod-build-task +++ /dev/null @@ -1,42 +0,0 @@ -// file : mod/mod-build-task -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_BUILD_TASK -#define MOD_MOD_BUILD_TASK - -#include -#include - -#include -#include - -namespace brep -{ - class build_task: public database_module - { - public: - build_task () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - build_task (const build_task&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const {return options::build_task::description ();} - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_BUILD_TASK diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index 9a72f66..353e636 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include #include @@ -12,20 +12,20 @@ #include #include -#include -#include +#include +#include #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include using namespace std; using namespace butl; diff --git a/mod/mod-build-task.hxx b/mod/mod-build-task.hxx new file mode 100644 index 0000000..d69836f --- /dev/null +++ b/mod/mod-build-task.hxx @@ -0,0 +1,42 @@ +// file : mod/mod-build-task.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_BUILD_TASK_HXX +#define MOD_MOD_BUILD_TASK_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class build_task: public database_module + { + public: + build_task () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + build_task (const build_task&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const {return options::build_task::description ();} + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_BUILD_TASK_HXX diff --git a/mod/mod-package-details b/mod/mod-package-details deleted file mode 100644 index a19e0d7..0000000 --- a/mod/mod-package-details +++ /dev/null @@ -1,42 +0,0 @@ -// file : mod/mod-package-details -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_PACKAGE_DETAILS -#define MOD_MOD_PACKAGE_DETAILS - -#include -#include - -#include -#include - -namespace brep -{ - class package_details: public database_module - { - public: - package_details () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - package_details (const package_details&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const {return options::package_details::description ();} - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_PACKAGE_DETAILS diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx index fd3fd6d..9a9bfcc 100644 --- a/mod/mod-package-details.cxx +++ b/mod/mod-package-details.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include @@ -10,15 +10,15 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include using namespace odb::core; using namespace brep::cli; diff --git a/mod/mod-package-details.hxx b/mod/mod-package-details.hxx new file mode 100644 index 0000000..e3950aa --- /dev/null +++ b/mod/mod-package-details.hxx @@ -0,0 +1,42 @@ +// file : mod/mod-package-details.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_PACKAGE_DETAILS_HXX +#define MOD_MOD_PACKAGE_DETAILS_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class package_details: public database_module + { + public: + package_details () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + package_details (const package_details&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const {return options::package_details::description ();} + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_PACKAGE_DETAILS_HXX diff --git a/mod/mod-package-search b/mod/mod-package-search deleted file mode 100644 index d8d09be..0000000 --- a/mod/mod-package-search +++ /dev/null @@ -1,42 +0,0 @@ -// file : mod/mod-package-search -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_PACKAGE_SEARCH -#define MOD_MOD_PACKAGE_SEARCH - -#include -#include - -#include -#include - -namespace brep -{ - class package_search: public database_module - { - public: - package_search () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - package_search (const package_search&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const {return options::package_search::description ();} - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_PACKAGE_SEARCH diff --git a/mod/mod-package-search.cxx b/mod/mod-package-search.cxx index 6d73a69..8897792 100644 --- a/mod/mod-package-search.cxx +++ b/mod/mod-package-search.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include @@ -11,15 +11,15 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include using namespace odb::core; using namespace brep::cli; diff --git a/mod/mod-package-search.hxx b/mod/mod-package-search.hxx new file mode 100644 index 0000000..5e7385e --- /dev/null +++ b/mod/mod-package-search.hxx @@ -0,0 +1,42 @@ +// file : mod/mod-package-search.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_PACKAGE_SEARCH_HXX +#define MOD_MOD_PACKAGE_SEARCH_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class package_search: public database_module + { + public: + package_search () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + package_search (const package_search&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const {return options::package_search::description ();} + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_PACKAGE_SEARCH_HXX diff --git a/mod/mod-package-version-details b/mod/mod-package-version-details deleted file mode 100644 index 70ec82b..0000000 --- a/mod/mod-package-version-details +++ /dev/null @@ -1,45 +0,0 @@ -// file : mod/mod-package-version-details -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_PACKAGE_VERSION_DETAILS -#define MOD_MOD_PACKAGE_VERSION_DETAILS - -#include -#include - -#include -#include - -namespace brep -{ - class package_version_details: public database_module - { - public: - package_version_details () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - package_version_details (const package_version_details&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const - { - return options::package_version_details::description (); - } - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_PACKAGE_VERSION_DETAILS diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index 30b2567..34c7f3b 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include @@ -10,15 +10,15 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include using namespace std; using namespace odb::core; diff --git a/mod/mod-package-version-details.hxx b/mod/mod-package-version-details.hxx new file mode 100644 index 0000000..ef682d7 --- /dev/null +++ b/mod/mod-package-version-details.hxx @@ -0,0 +1,45 @@ +// file : mod/mod-package-version-details.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_PACKAGE_VERSION_DETAILS_HXX +#define MOD_MOD_PACKAGE_VERSION_DETAILS_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class package_version_details: public database_module + { + public: + package_version_details () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + package_version_details (const package_version_details&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const + { + return options::package_version_details::description (); + } + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_PACKAGE_VERSION_DETAILS_HXX diff --git a/mod/mod-repository-details b/mod/mod-repository-details deleted file mode 100644 index 5e797b2..0000000 --- a/mod/mod-repository-details +++ /dev/null @@ -1,42 +0,0 @@ -// file : mod/mod-repository-details -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_REPOSITORY_DETAILS -#define MOD_MOD_REPOSITORY_DETAILS - -#include -#include - -#include -#include - -namespace brep -{ - class repository_details: public database_module - { - public: - repository_details () = default; - - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - repository_details (const repository_details&); - - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const {return options::repository_details::description ();} - - private: - virtual void - init (cli::scanner&); - - private: - shared_ptr options_; - }; -} - -#endif // MOD_MOD_REPOSITORY_DETAILS diff --git a/mod/mod-repository-details.cxx b/mod/mod-repository-details.cxx index 9e791ef..78b309d 100644 --- a/mod/mod-repository-details.cxx +++ b/mod/mod-repository-details.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include // tzset() @@ -16,15 +16,15 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include using namespace std; using namespace odb::core; diff --git a/mod/mod-repository-details.hxx b/mod/mod-repository-details.hxx new file mode 100644 index 0000000..8a795dc --- /dev/null +++ b/mod/mod-repository-details.hxx @@ -0,0 +1,42 @@ +// file : mod/mod-repository-details.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_REPOSITORY_DETAILS_HXX +#define MOD_MOD_REPOSITORY_DETAILS_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class repository_details: public database_module + { + public: + repository_details () = default; + + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + repository_details (const repository_details&); + + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const {return options::repository_details::description ();} + + private: + virtual void + init (cli::scanner&); + + private: + shared_ptr options_; + }; +} + +#endif // MOD_MOD_REPOSITORY_DETAILS_HXX diff --git a/mod/mod-repository-root b/mod/mod-repository-root deleted file mode 100644 index b347cd3..0000000 --- a/mod/mod-repository-root +++ /dev/null @@ -1,77 +0,0 @@ -// file : mod/mod-repository-root -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MOD_REPOSITORY_ROOT -#define MOD_MOD_REPOSITORY_ROOT - -#include -#include - -#include -#include - -namespace brep -{ - class package_search; - class package_details; - class package_version_details; - class repository_details; - class build_task; - class build_result; - class build_force; - class build_log; - - class repository_root: public module - { - public: - repository_root (); - - // Copy constructible-only type. - // - // Create a shallow copy (handling instance) if initialized and a deep - // copy (context exemplar) otherwise. - // - explicit - repository_root (const repository_root&); - - private: - virtual bool - handle (request&, response&); - - virtual const cli::options& - cli_options () const {return options::repository_root::description ();} - - virtual option_descriptions - options (); - - virtual void - init (const name_values&); - - virtual void - init (cli::scanner&); - - virtual void - version (); - - private: - shared_ptr package_search_; - shared_ptr package_details_; - shared_ptr package_version_details_; - shared_ptr repository_details_; - shared_ptr build_task_; - shared_ptr build_result_; - shared_ptr build_force_; - shared_ptr build_log_; - shared_ptr options_; - - // Sub-module the request is dispatched to. Initially is NULL. It is set - // by the first call to handle() to a deep copy of the selected exemplar. - // The subsequent calls of handle() (that may take place after the retry - // exception is thrown) will use the existing handler instance. - // - unique_ptr handler_; - }; -} - -#endif // MOD_MOD_REPOSITORY_ROOT diff --git a/mod/mod-repository-root.cxx b/mod/mod-repository-root.cxx index 097c874..bac63ca 100644 --- a/mod/mod-repository-root.cxx +++ b/mod/mod-repository-root.cxx @@ -2,22 +2,22 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; using namespace brep::cli; diff --git a/mod/mod-repository-root.hxx b/mod/mod-repository-root.hxx new file mode 100644 index 0000000..f54fa62 --- /dev/null +++ b/mod/mod-repository-root.hxx @@ -0,0 +1,77 @@ +// file : mod/mod-repository-root.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MOD_REPOSITORY_ROOT_HXX +#define MOD_MOD_REPOSITORY_ROOT_HXX + +#include +#include + +#include +#include + +namespace brep +{ + class package_search; + class package_details; + class package_version_details; + class repository_details; + class build_task; + class build_result; + class build_force; + class build_log; + + class repository_root: public module + { + public: + repository_root (); + + // Copy constructible-only type. + // + // Create a shallow copy (handling instance) if initialized and a deep + // copy (context exemplar) otherwise. + // + explicit + repository_root (const repository_root&); + + private: + virtual bool + handle (request&, response&); + + virtual const cli::options& + cli_options () const {return options::repository_root::description ();} + + virtual option_descriptions + options (); + + virtual void + init (const name_values&); + + virtual void + init (cli::scanner&); + + virtual void + version (); + + private: + shared_ptr package_search_; + shared_ptr package_details_; + shared_ptr package_version_details_; + shared_ptr repository_details_; + shared_ptr build_task_; + shared_ptr build_result_; + shared_ptr build_force_; + shared_ptr build_log_; + shared_ptr options_; + + // Sub-module the request is dispatched to. Initially is NULL. It is set + // by the first call to handle() to a deep copy of the selected exemplar. + // The subsequent calls of handle() (that may take place after the retry + // exception is thrown) will use the existing handler instance. + // + unique_ptr handler_; + }; +} + +#endif // MOD_MOD_REPOSITORY_ROOT_HXX diff --git a/mod/module b/mod/module deleted file mode 100644 index f0743bb..0000000 --- a/mod/module +++ /dev/null @@ -1,201 +0,0 @@ -// file : mod/module -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_MODULE -#define MOD_MODULE - -#include - -#include -#include - -#include -#include - -namespace brep -{ - // Bring in commonly used names from the web namespace. - // - // @@ Maybe doing using namespace is the right way to handle this. - // There will, however, most likely be a conflict between - // web::module and our module. Or maybe not, need to try. - // - using web::status_code; - using web::invalid_request; - using web::sequence_error; - using web::option_descriptions; - using web::name_value; - using web::name_values; - using web::request; - using web::response; - using web::log; - - // This exception indicated a server error (5XX). In particular, - // it is thrown by the fail diagnostics stream and is caught by the - // module implementation where it is both logged as an error and - // returned to the user with the 5XX status code. - // - struct server_error - { - diag_data data; - - server_error (diag_data&& d): data (move (d)) {} - }; - - // Every module member function that needs to produce any diagnostics - // shall begin with: - // - // MODULE_DIAG; - // - // This will instantiate the fail, error, warn, info, and trace - // diagnostics streams with the function's name. - // -#define MODULE_DIAG \ - const fail_mark fail (__PRETTY_FUNCTION__); \ - const basic_mark error (severity::error, \ - this->log_writer_, \ - __PRETTY_FUNCTION__); \ - const basic_mark warn (severity::warning, \ - this->log_writer_, \ - __PRETTY_FUNCTION__); \ - const basic_mark info (severity::info, \ - this->log_writer_, \ - __PRETTY_FUNCTION__); \ - const basic_mark trace (severity::trace, \ - this->log_writer_, \ - __PRETTY_FUNCTION__) - - // Adaptation of the web::module to our needs. - // - class module: public web::module - { - // Diagnostics. - // - protected: - // Trace verbosity level. - // - // 0 - tracing disabled. - // 1 - brief information regarding irregular situations, which not being - // an error can be of some interest. - // 2 - @@ TODO: document - // - // While uint8 is more than enough, use uint16 for the ease of printing. - // - uint16_t verb_ = 0; - - template void l1 (const F& f) const {if (verb_ >= 1) f ();} - template void l2 (const F& f) const {if (verb_ >= 2) f ();} - - // Set to true when the module is successfully initialized. - // - bool initialized_ {false}; - - // Implementation details. - // - protected: - module (); - module (const module& ); - - static name_values - filter (const name_values&, const option_descriptions&); - - static option_descriptions - convert (const cli::options&); - - static void - append (option_descriptions& dst, const cli::options& src); - - static void - append (option_descriptions& dst, const option_descriptions& src); - - // Can be used by module implementation to parse HTTP request parameters. - // - class name_value_scanner: public cli::scanner - { - public: - name_value_scanner (const name_values&) noexcept; - - virtual bool - more (); - - virtual const char* - peek (); - - virtual const char* - next (); - - virtual void - skip (); - - private: - const name_values& name_values_; - name_values::const_iterator i_; - bool name_; - }; - - public: - virtual const cli::options& - cli_options () const = 0; - - virtual void - init (cli::scanner&) = 0; - - // Can be overriden by custom request dispatcher to initialize - // sub-modules. - // - virtual void - init (const name_values&); - - virtual void - init (const name_values&, log&); - - virtual bool - handle (request&, response&) = 0; - - virtual bool - handle (request&, response&, log&); - - // web::module interface. - // - public: - // Custom request dispatcher can aggregate its own option descriptions - // with sub-modules option descriptions. In this case it should still call - // the base implementation in order to include the brep::module's options. - // - virtual option_descriptions - options (); - - private: - virtual void - version (log&); - - // Can be overriden by the module implementation to log version, etc. - // - virtual void - version () {} - - name_values - expand_options (const name_values&); - - // Diagnostics implementation details. - // - protected: - log* log_ {nullptr}; // Diagnostics backend provided by the web server. - - private: - // Extract function name from a __PRETTY_FUNCTION__. - // Throw invalid_argument if fail to parse. - // - static string - func_name (const char* pretty_name); - - void - log_write (const diag_data&) const; - - protected: - const diag_epilogue log_writer_; - }; -} - -#endif // MOD_MODULE diff --git a/mod/module.cxx b/mod/module.cxx index e42f937..5db1fbe 100644 --- a/mod/module.cxx +++ b/mod/module.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include #include @@ -11,10 +11,10 @@ #include // strchr() #include // bind() -#include -#include +#include +#include -#include +#include using namespace std; using namespace placeholders; // For std::bind's _1, etc. diff --git a/mod/module.hxx b/mod/module.hxx new file mode 100644 index 0000000..1cd6b8d --- /dev/null +++ b/mod/module.hxx @@ -0,0 +1,201 @@ +// file : mod/module.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_MODULE_HXX +#define MOD_MODULE_HXX + +#include + +#include +#include + +#include +#include + +namespace brep +{ + // Bring in commonly used names from the web namespace. + // + // @@ Maybe doing using namespace is the right way to handle this. + // There will, however, most likely be a conflict between + // web::module and our module. Or maybe not, need to try. + // + using web::status_code; + using web::invalid_request; + using web::sequence_error; + using web::option_descriptions; + using web::name_value; + using web::name_values; + using web::request; + using web::response; + using web::log; + + // This exception indicated a server error (5XX). In particular, + // it is thrown by the fail diagnostics stream and is caught by the + // module implementation where it is both logged as an error and + // returned to the user with the 5XX status code. + // + struct server_error + { + diag_data data; + + server_error (diag_data&& d): data (move (d)) {} + }; + + // Every module member function that needs to produce any diagnostics + // shall begin with: + // + // MODULE_DIAG; + // + // This will instantiate the fail, error, warn, info, and trace + // diagnostics streams with the function's name. + // +#define MODULE_DIAG \ + const fail_mark fail (__PRETTY_FUNCTION__); \ + const basic_mark error (severity::error, \ + this->log_writer_, \ + __PRETTY_FUNCTION__); \ + const basic_mark warn (severity::warning, \ + this->log_writer_, \ + __PRETTY_FUNCTION__); \ + const basic_mark info (severity::info, \ + this->log_writer_, \ + __PRETTY_FUNCTION__); \ + const basic_mark trace (severity::trace, \ + this->log_writer_, \ + __PRETTY_FUNCTION__) + + // Adaptation of the web::module to our needs. + // + class module: public web::module + { + // Diagnostics. + // + protected: + // Trace verbosity level. + // + // 0 - tracing disabled. + // 1 - brief information regarding irregular situations, which not being + // an error can be of some interest. + // 2 - @@ TODO: document + // + // While uint8 is more than enough, use uint16 for the ease of printing. + // + uint16_t verb_ = 0; + + template void l1 (const F& f) const {if (verb_ >= 1) f ();} + template void l2 (const F& f) const {if (verb_ >= 2) f ();} + + // Set to true when the module is successfully initialized. + // + bool initialized_ {false}; + + // Implementation details. + // + protected: + module (); + module (const module& ); + + static name_values + filter (const name_values&, const option_descriptions&); + + static option_descriptions + convert (const cli::options&); + + static void + append (option_descriptions& dst, const cli::options& src); + + static void + append (option_descriptions& dst, const option_descriptions& src); + + // Can be used by module implementation to parse HTTP request parameters. + // + class name_value_scanner: public cli::scanner + { + public: + name_value_scanner (const name_values&) noexcept; + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + private: + const name_values& name_values_; + name_values::const_iterator i_; + bool name_; + }; + + public: + virtual const cli::options& + cli_options () const = 0; + + virtual void + init (cli::scanner&) = 0; + + // Can be overriden by custom request dispatcher to initialize + // sub-modules. + // + virtual void + init (const name_values&); + + virtual void + init (const name_values&, log&); + + virtual bool + handle (request&, response&) = 0; + + virtual bool + handle (request&, response&, log&); + + // web::module interface. + // + public: + // Custom request dispatcher can aggregate its own option descriptions + // with sub-modules option descriptions. In this case it should still call + // the base implementation in order to include the brep::module's options. + // + virtual option_descriptions + options (); + + private: + virtual void + version (log&); + + // Can be overriden by the module implementation to log version, etc. + // + virtual void + version () {} + + name_values + expand_options (const name_values&); + + // Diagnostics implementation details. + // + protected: + log* log_ {nullptr}; // Diagnostics backend provided by the web server. + + private: + // Extract function name from a __PRETTY_FUNCTION__. + // Throw invalid_argument if fail to parse. + // + static string + func_name (const char* pretty_name); + + void + log_write (const diag_data&) const; + + protected: + const diag_epilogue log_writer_; + }; +} + +#endif // MOD_MODULE_HXX diff --git a/mod/options-types b/mod/options-types deleted file mode 100644 index d9eaf9e..0000000 --- a/mod/options-types +++ /dev/null @@ -1,31 +0,0 @@ -// file : mod/options-types -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_OPTIONS_TYPES -#define MOD_OPTIONS_TYPES - -#include -#include - -namespace brep -{ - // brep types - // - enum class page_form - { - full, - brief - }; - - struct page_menu - { - string label; - string link; - - page_menu () = default; - page_menu (string b, string l): label (move (b)), link (move (l)) {} - }; -} - -#endif // MOD_OPTIONS_TYPES diff --git a/mod/options-types.hxx b/mod/options-types.hxx new file mode 100644 index 0000000..7808ca4 --- /dev/null +++ b/mod/options-types.hxx @@ -0,0 +1,31 @@ +// file : mod/options-types.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_OPTIONS_TYPES_HXX +#define MOD_OPTIONS_TYPES_HXX + +#include +#include + +namespace brep +{ + // brep types + // + enum class page_form + { + full, + brief + }; + + struct page_menu + { + string label; + string link; + + page_menu () = default; + page_menu (string b, string l): label (move (b)), link (move (l)) {} + }; +} + +#endif // MOD_OPTIONS_TYPES_HXX diff --git a/mod/options.cli b/mod/options.cli index 0f96e9c..3d6ac60 100644 --- a/mod/options.cli +++ b/mod/options.cli @@ -2,11 +2,11 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -include ; +include ; -include ; +include ; -include ; +include ; namespace brep { diff --git a/mod/page b/mod/page deleted file mode 100644 index a7aaf1b..0000000 --- a/mod/page +++ /dev/null @@ -1,428 +0,0 @@ -// file : mod/page -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef MOD_PAGE -#define MOD_PAGE - -#include - -#include - -#include -#include - -#include - -#include // page_menu - -namespace brep -{ - // Page common building blocks. - // - - // Generates CSS link elements. - // - class CSS_LINKS - { - public: - CSS_LINKS (const path& p, const dir_path& r): path_ (p), root_ (r) {} - - void - operator() (xml::serializer&) const; - - private: - const path& path_; - const dir_path& root_; - }; - - // Generates page header element. - // - class DIV_HEADER - { - public: - DIV_HEADER (const dir_path& root, - const web::xhtml::fragment& logo, - const vector& menu): - root_ (root), logo_ (logo), menu_ (menu) {} - - void - operator() (xml::serializer&) const; - - private: - const dir_path& root_; - const web::xhtml::fragment& logo_; - const vector& menu_; - }; - - // Generates package search form element. - // - class FORM_SEARCH - { - public: - FORM_SEARCH (const string& q): query_ (q) {} - - void - operator() (xml::serializer&) const; - - private: - const string& query_; - }; - - // Generates counter element. - // - // It could be redunant to distinguish between singular and plural word forms - // if it wouldn't be so cheap in English, and phrase '1 Packages' wouldn't - // look that ugly. - // - class DIV_COUNTER - { - public: - DIV_COUNTER (size_t c, const char* s, const char* p) - : count_ (c), singular_ (s), plural_ (p) {} - - void - operator() (xml::serializer&) const; - - private: - size_t count_; - const char* singular_; - const char* plural_; - }; - - // Generates package name element. - // - class TR_NAME - { - public: - TR_NAME (const string& n, const string& q, const dir_path& r) - : name_ (n), query_param_ (q), root_ (r) {} - - void - operator() (xml::serializer&) const; - - private: - const string& name_; - const string& query_param_; - const dir_path& root_; - }; - - // Generates package version element. - // - class TR_VERSION - { - public: - // Display the version as a link to the package version details page. - // - TR_VERSION (const string& p, const version& v, const dir_path& r) - : package_ (&p), - version_ (v.string ()), - stub_ (v.compare (wildcard_version, true) == 0), - root_ (&r) - { - } - - // Display the version as a regular text. - // - TR_VERSION (const version& v) - : package_ (nullptr), - version_ (v.string ()), - stub_ (v.compare (wildcard_version, true) == 0), - root_ (nullptr) - { - } - - void - operator() (xml::serializer&) const; - - private: - const string* package_; - string version_; - bool stub_; - const dir_path* root_; - }; - - // Generates package summary element. - // - class TR_SUMMARY - { - public: - TR_SUMMARY (const string& s): summary_ (s) {} - - void - operator() (xml::serializer&) const; - - private: - const string& summary_; - }; - - // Generates package license alternatives element. - // - class TR_LICENSE - { - public: - TR_LICENSE (const license_alternatives& l): licenses_ (l) {} - - void - operator() (xml::serializer&) const; - - private: - const license_alternatives& licenses_; - }; - - // Generates package license alternatives elements. Differs from TR_LICENSE - // by producing multiple rows instead of a single one. - // - class TR_LICENSES - { - public: - TR_LICENSES (const license_alternatives& l): licenses_ (l) {} - - void - operator() (xml::serializer&) const; - - private: - const license_alternatives& licenses_; - }; - - // Generates package tags element. - // - class TR_TAGS - { - public: - TR_TAGS (const strings& ts, const dir_path& r): tags_ (ts), root_ (r) {} - - void - operator() (xml::serializer&) const; - - private: - const strings& tags_; - const dir_path& root_; - }; - - // Generates package dependencies element. - // - class TR_DEPENDS - { - public: - TR_DEPENDS (const dependencies& d, const dir_path& r) - : dependencies_ (d), root_ (r) {} - - void - operator() (xml::serializer&) const; - - private: - const dependencies& dependencies_; - const dir_path& root_; - }; - - // Generates package requirements element. - // - class TR_REQUIRES - { - public: - TR_REQUIRES (const requirements& r): requirements_ (r) {} - - void - operator() (xml::serializer&) const; - - private: - const requirements& requirements_; - }; - - // Generates url element. - // - class TR_URL - { - public: - TR_URL (const url& u, const char* l = "url"): url_ (u), label_ (l) {} - - void - operator() (xml::serializer&) const; - - private: - const url& url_; - const char* label_; - }; - - // Generates email element. - // - class TR_EMAIL - { - public: - TR_EMAIL (const email& e, const char* l = "email") - : email_ (e), label_ (l) {} - - void - operator() (xml::serializer&) const; - - private: - const email& email_; - const char* label_; - }; - - // Generates package version priority element. - // - class TR_PRIORITY - { - public: - TR_PRIORITY (const priority& p): priority_ (p) {} - - void - operator() (xml::serializer&) const; - - private: - const priority& priority_; - }; - - // Generates repository name element. - // - class TR_REPOSITORY - { - public: - TR_REPOSITORY (const string& n, const dir_path& r) - : name_ (n), root_ (r) {} - - void - operator() (xml::serializer&) const; - - private: - const string& name_; - const dir_path& root_; - }; - - // Generates repository location element. - // - class TR_LOCATION - { - public: - TR_LOCATION (const repository_location& l): location_ (l) {} - - void - operator() (xml::serializer&) const; - - private: - const repository_location& location_; - }; - - // Generates package download URL element. - // - class TR_DOWNLOAD - { - public: - TR_DOWNLOAD (const string& u): url_ (u) {} - - void - operator() (xml::serializer&) const; - - private: - const string& url_; - }; - - // Generates sha256sum element. - // - class TR_SHA256SUM - { - public: - TR_SHA256SUM (const string& s): sha256sum_ (s) {} - - void - operator() (xml::serializer&) const; - - private: - const string& sha256sum_; - }; - - // Generates comment element. - // - class SPAN_COMMENT - { - public: - SPAN_COMMENT (const string& c): comment_ (c) {} - - void - operator() (xml::serializer&) const; - - private: - const string& comment_; - }; - - // Generates package description element. - // - class P_DESCRIPTION - { - public: - // Genereate full description. - // - P_DESCRIPTION (const string& d, const string& id = "") - : description_ (d), length_ (d.size ()), url_ (nullptr), id_ (id) {} - - // Genereate brief description. - // - P_DESCRIPTION (const string& d, size_t l, const string& u) - : description_ (d), length_ (l), url_ (&u) {} - - void - operator() (xml::serializer&) const; - - private: - const string& description_; - size_t length_; - const string* url_; // Full page url. - string id_; - }; - - // Generates package description element. - // - class PRE_CHANGES - { - public: - // Genereate full changes info. - // - PRE_CHANGES (const string& c) - : changes_ (c), length_ (c.size ()), url_ (nullptr) {} - - // Genereate brief changes info. - // - PRE_CHANGES (const string& c, size_t l, const string& u) - : changes_ (c), length_ (l), url_ (&u) {} - - void - operator() (xml::serializer&) const; - - private: - const string& changes_; - size_t length_; - const string* url_; // Full page url. - }; - - // Generates paging element. - // - class DIV_PAGER - { - public: - DIV_PAGER (size_t current_page, - size_t item_count, - size_t item_per_page, - size_t page_number_count, - const string& url); - - void - operator() (xml::serializer&) const; - - private: - size_t current_page_; - size_t item_count_; - size_t item_per_page_; - size_t page_number_count_; - const string& url_; - }; - - // Convert the argument to a string representing the valid HTML 5 'id' - // attribute value. - // - string - html_id (const string&); -} - -#endif // MOD_PAGE diff --git a/mod/page.cxx b/mod/page.cxx index 1ee18ce..8d8e6e6 100644 --- a/mod/page.cxx +++ b/mod/page.cxx @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include #include #include // hex, uppercase, right @@ -12,11 +12,11 @@ #include -#include -#include +#include +#include -#include -#include +#include +#include using namespace std; using namespace xml; diff --git a/mod/page.hxx b/mod/page.hxx new file mode 100644 index 0000000..d79860d --- /dev/null +++ b/mod/page.hxx @@ -0,0 +1,428 @@ +// file : mod/page.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_PAGE_HXX +#define MOD_PAGE_HXX + +#include + +#include + +#include +#include + +#include + +#include // page_menu + +namespace brep +{ + // Page common building blocks. + // + + // Generates CSS link elements. + // + class CSS_LINKS + { + public: + CSS_LINKS (const path& p, const dir_path& r): path_ (p), root_ (r) {} + + void + operator() (xml::serializer&) const; + + private: + const path& path_; + const dir_path& root_; + }; + + // Generates page header element. + // + class DIV_HEADER + { + public: + DIV_HEADER (const dir_path& root, + const web::xhtml::fragment& logo, + const vector& menu): + root_ (root), logo_ (logo), menu_ (menu) {} + + void + operator() (xml::serializer&) const; + + private: + const dir_path& root_; + const web::xhtml::fragment& logo_; + const vector& menu_; + }; + + // Generates package search form element. + // + class FORM_SEARCH + { + public: + FORM_SEARCH (const string& q): query_ (q) {} + + void + operator() (xml::serializer&) const; + + private: + const string& query_; + }; + + // Generates counter element. + // + // It could be redunant to distinguish between singular and plural word forms + // if it wouldn't be so cheap in English, and phrase '1 Packages' wouldn't + // look that ugly. + // + class DIV_COUNTER + { + public: + DIV_COUNTER (size_t c, const char* s, const char* p) + : count_ (c), singular_ (s), plural_ (p) {} + + void + operator() (xml::serializer&) const; + + private: + size_t count_; + const char* singular_; + const char* plural_; + }; + + // Generates package name element. + // + class TR_NAME + { + public: + TR_NAME (const string& n, const string& q, const dir_path& r) + : name_ (n), query_param_ (q), root_ (r) {} + + void + operator() (xml::serializer&) const; + + private: + const string& name_; + const string& query_param_; + const dir_path& root_; + }; + + // Generates package version element. + // + class TR_VERSION + { + public: + // Display the version as a link to the package version details page. + // + TR_VERSION (const string& p, const version& v, const dir_path& r) + : package_ (&p), + version_ (v.string ()), + stub_ (v.compare (wildcard_version, true) == 0), + root_ (&r) + { + } + + // Display the version as a regular text. + // + TR_VERSION (const version& v) + : package_ (nullptr), + version_ (v.string ()), + stub_ (v.compare (wildcard_version, true) == 0), + root_ (nullptr) + { + } + + void + operator() (xml::serializer&) const; + + private: + const string* package_; + string version_; + bool stub_; + const dir_path* root_; + }; + + // Generates package summary element. + // + class TR_SUMMARY + { + public: + TR_SUMMARY (const string& s): summary_ (s) {} + + void + operator() (xml::serializer&) const; + + private: + const string& summary_; + }; + + // Generates package license alternatives element. + // + class TR_LICENSE + { + public: + TR_LICENSE (const license_alternatives& l): licenses_ (l) {} + + void + operator() (xml::serializer&) const; + + private: + const license_alternatives& licenses_; + }; + + // Generates package license alternatives elements. Differs from TR_LICENSE + // by producing multiple rows instead of a single one. + // + class TR_LICENSES + { + public: + TR_LICENSES (const license_alternatives& l): licenses_ (l) {} + + void + operator() (xml::serializer&) const; + + private: + const license_alternatives& licenses_; + }; + + // Generates package tags element. + // + class TR_TAGS + { + public: + TR_TAGS (const strings& ts, const dir_path& r): tags_ (ts), root_ (r) {} + + void + operator() (xml::serializer&) const; + + private: + const strings& tags_; + const dir_path& root_; + }; + + // Generates package dependencies element. + // + class TR_DEPENDS + { + public: + TR_DEPENDS (const dependencies& d, const dir_path& r) + : dependencies_ (d), root_ (r) {} + + void + operator() (xml::serializer&) const; + + private: + const dependencies& dependencies_; + const dir_path& root_; + }; + + // Generates package requirements element. + // + class TR_REQUIRES + { + public: + TR_REQUIRES (const requirements& r): requirements_ (r) {} + + void + operator() (xml::serializer&) const; + + private: + const requirements& requirements_; + }; + + // Generates url element. + // + class TR_URL + { + public: + TR_URL (const url& u, const char* l = "url"): url_ (u), label_ (l) {} + + void + operator() (xml::serializer&) const; + + private: + const url& url_; + const char* label_; + }; + + // Generates email element. + // + class TR_EMAIL + { + public: + TR_EMAIL (const email& e, const char* l = "email") + : email_ (e), label_ (l) {} + + void + operator() (xml::serializer&) const; + + private: + const email& email_; + const char* label_; + }; + + // Generates package version priority element. + // + class TR_PRIORITY + { + public: + TR_PRIORITY (const priority& p): priority_ (p) {} + + void + operator() (xml::serializer&) const; + + private: + const priority& priority_; + }; + + // Generates repository name element. + // + class TR_REPOSITORY + { + public: + TR_REPOSITORY (const string& n, const dir_path& r) + : name_ (n), root_ (r) {} + + void + operator() (xml::serializer&) const; + + private: + const string& name_; + const dir_path& root_; + }; + + // Generates repository location element. + // + class TR_LOCATION + { + public: + TR_LOCATION (const repository_location& l): location_ (l) {} + + void + operator() (xml::serializer&) const; + + private: + const repository_location& location_; + }; + + // Generates package download URL element. + // + class TR_DOWNLOAD + { + public: + TR_DOWNLOAD (const string& u): url_ (u) {} + + void + operator() (xml::serializer&) const; + + private: + const string& url_; + }; + + // Generates sha256sum element. + // + class TR_SHA256SUM + { + public: + TR_SHA256SUM (const string& s): sha256sum_ (s) {} + + void + operator() (xml::serializer&) const; + + private: + const string& sha256sum_; + }; + + // Generates comment element. + // + class SPAN_COMMENT + { + public: + SPAN_COMMENT (const string& c): comment_ (c) {} + + void + operator() (xml::serializer&) const; + + private: + const string& comment_; + }; + + // Generates package description element. + // + class P_DESCRIPTION + { + public: + // Genereate full description. + // + P_DESCRIPTION (const string& d, const string& id = "") + : description_ (d), length_ (d.size ()), url_ (nullptr), id_ (id) {} + + // Genereate brief description. + // + P_DESCRIPTION (const string& d, size_t l, const string& u) + : description_ (d), length_ (l), url_ (&u) {} + + void + operator() (xml::serializer&) const; + + private: + const string& description_; + size_t length_; + const string* url_; // Full page url. + string id_; + }; + + // Generates package description element. + // + class PRE_CHANGES + { + public: + // Genereate full changes info. + // + PRE_CHANGES (const string& c) + : changes_ (c), length_ (c.size ()), url_ (nullptr) {} + + // Genereate brief changes info. + // + PRE_CHANGES (const string& c, size_t l, const string& u) + : changes_ (c), length_ (l), url_ (&u) {} + + void + operator() (xml::serializer&) const; + + private: + const string& changes_; + size_t length_; + const string* url_; // Full page url. + }; + + // Generates paging element. + // + class DIV_PAGER + { + public: + DIV_PAGER (size_t current_page, + size_t item_count, + size_t item_per_page, + size_t page_number_count, + const string& url); + + void + operator() (xml::serializer&) const; + + private: + size_t current_page_; + size_t item_count_; + size_t item_per_page_; + size_t page_number_count_; + const string& url_; + }; + + // Convert the argument to a string representing the valid HTML 5 'id' + // attribute value. + // + string + html_id (const string&); +} + +#endif // MOD_PAGE_HXX diff --git a/mod/services.cxx b/mod/services.cxx index fa788b3..dfa14a8 100644 --- a/mod/services.cxx +++ b/mod/services.cxx @@ -4,12 +4,12 @@ #include // AP_MODULE_DECLARE_DATA -#include +#include -#include -#include +#include +#include -#include +#include static brep::repository_root mod; web::apache::service AP_MODULE_DECLARE_DATA brep_module ("brep", mod); diff --git a/mod/types-parsers b/mod/types-parsers deleted file mode 100644 index eb206e4..0000000 --- a/mod/types-parsers +++ /dev/null @@ -1,64 +0,0 @@ -// file : mod/types-parsers -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -// CLI parsers, included into the generated source files. -// - -#ifndef MOD_TYPES_PARSERS -#define MOD_TYPES_PARSERS - -#include - -#include -#include - -#include - -namespace brep -{ - namespace cli - { - class scanner; - - template - struct parser; - - template <> - struct parser - { - static void - parse (path&, bool&, scanner&); - }; - - template <> - struct parser - { - static void - parse (dir_path&, bool&, scanner&); - }; - - template <> - struct parser - { - static void - parse (page_form&, bool&, scanner&); - }; - - template <> - struct parser - { - static void - parse (page_menu&, bool&, scanner&); - }; - - template <> - struct parser - { - static void - parse (web::xhtml::fragment&, bool&, scanner&); - }; - } -} - -#endif // MOD_TYPES_PARSERS diff --git a/mod/types-parsers.cxx b/mod/types-parsers.cxx index fb293a3..65d9c6c 100644 --- a/mod/types-parsers.cxx +++ b/mod/types-parsers.cxx @@ -2,9 +2,9 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#include +#include -#include +#include using namespace std; using namespace web::xhtml; diff --git a/mod/types-parsers.hxx b/mod/types-parsers.hxx new file mode 100644 index 0000000..03c54fe --- /dev/null +++ b/mod/types-parsers.hxx @@ -0,0 +1,64 @@ +// file : mod/types-parsers.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +// CLI parsers, included into the generated source files. +// + +#ifndef MOD_TYPES_PARSERS_HXX +#define MOD_TYPES_PARSERS_HXX + +#include + +#include +#include + +#include + +namespace brep +{ + namespace cli + { + class scanner; + + template + struct parser; + + template <> + struct parser + { + static void + parse (path&, bool&, scanner&); + }; + + template <> + struct parser + { + static void + parse (dir_path&, bool&, scanner&); + }; + + template <> + struct parser + { + static void + parse (page_form&, bool&, scanner&); + }; + + template <> + struct parser + { + static void + parse (page_menu&, bool&, scanner&); + }; + + template <> + struct parser + { + static void + parse (web::xhtml::fragment&, bool&, scanner&); + }; + } +} + +#endif // MOD_TYPES_PARSERS_HXX -- cgit v1.1