From 8e866579cb459c5104c532d5e41d562d45236ea5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Jun 2015 19:20:16 +0200 Subject: Implement loader --- brep/package.cxx | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 5 deletions(-) (limited to 'brep/package.cxx') diff --git a/brep/package.cxx b/brep/package.cxx index 11cd974..585a0b5 100644 --- a/brep/package.cxx +++ b/brep/package.cxx @@ -4,19 +4,129 @@ #include +#include // move() +#include + #include -#include +#include + +using namespace std; +using namespace odb::core; namespace brep { + // Utility functions + // + static inline bool + alpha (char c) + { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + } + + static inline bool + digit (char c) + { + return c >= '0' && c <= '9'; + } + + // package + // + package:: + package (string n, + string s, + strings t, + optional d, + url_type u, + optional pu, + email_type e, + optional pe) + : name (move (n)), + summary (move (s)), + tags (move (t)), + description (move (d)), + url (move (u)), + package_url (move (pu)), + email (move (e)), + package_email (move (pe)) + { + } + // package_version // + package_version:: + package_version (lazy_shared_ptr rp, + lazy_shared_ptr pk, + version_type vr, + priority_type pr, + license_alternatives_type la, + string ch, + dependencies_type dp, + requirements_type rq) + : repository (move (rp)), + package (move (pk)), + version (move (vr)), + priority (move (pr)), + license_alternatives (move (la)), + changes (move (ch)), + dependencies (move (dp)), + requirements (move (rq)) + { + } + + package_version::_id_type package_version:: + _id () const + { + return _id_type { + { + repository.object_id (), + package.object_id (), + version.epoch (), + version.canonical_upstream () + }, + version.upstream (), + version.revision ()}; + } + void package_version:: - id (const package_version_id& v, odb::database& db) + _id (_id_type&& v, database& db) + { + repository = lazy_shared_ptr (db, v.data.repository); + package = lazy_shared_ptr (db, v.data.package); + version = version_type (v.data.epoch, move (v.upstream), v.revision); + assert (version.canonical_upstream () == v.data.canonical_upstream); + } + + // max_package_version + // + void max_package_version:: + _id (package_version::_id_type&& v) + { + version = version_type (v.data.epoch, move (v.upstream), v.revision); + assert (version.canonical_upstream () == v.data.canonical_upstream); + } + + // repository + // + repository:: + repository (repository_location l, string d, dir_path p) + : location (move (l)), + display_name (move (d)), + local_path (move (p)), + internal (true) + { + } + + repository::_id_type repository:: + _id () const + { + return _id_type {location.canonical_name (), location.string ()}; + } + + void repository:: + _id (_id_type&& l) { - version.epoch = v.epoch; - version.canonical = v.canonical; - package = db.load (v.package); + location = repository_location (move (l.location)); + assert (location.canonical_name () == l.canonical_name); } } -- cgit v1.1