From 5734c3f3ac74a80cc36ecd5a08048b917056f65b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Jun 2015 17:01:33 +0200 Subject: Fix simulated 2-dimensional value type containers table column naming --- brep/package | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/brep/package b/brep/package index 6b43d30..f0906b8 100644 --- a/brep/package +++ b/brep/package @@ -142,6 +142,26 @@ namespace brep using requirements = std::vector; + // Intended for instantiating key classes for maps used for simulation of + // 2-dimensional value type containers. Parameter type T not being used in + // template implementation is required to instantiate unrelated key + // classes to achieve proper table column naming with ODB pragmas. + // + template + struct index_pair + { + std::size_t first; + std::size_t second; + + index_pair (std::size_t f = 0, std::size_t s = 0): first (f), second (s) {} + + bool + operator< (const index_pair& v) const + { + return first < v.first || first == v.first && second < v.second; + } + }; + #pragma db object pointer(std::shared_ptr) session struct package { @@ -218,7 +238,7 @@ namespace brep // license // - using _license_key = std::pair; + using _license_key = index_pair; using _licenses_type = std::map<_license_key, std::string>; #pragma db value(_license_key) @@ -235,7 +255,7 @@ namespace brep // dependencies // - using _dependency_key = std::pair; + using _dependency_key = index_pair; using _dependency_alternatives_type = std::map<_dependency_key, dependency>; @@ -253,7 +273,7 @@ namespace brep // requirements // - using _requirement_key = std::pair; + using _requirement_key = index_pair; using _requirement_alternatives_type = std::map<_requirement_key, std::string>; @@ -295,13 +315,13 @@ namespace odb struct _inner: std::remove_reference ()[0])> {}; template - std::map, typename _inner::type> + std::map, typename _inner::type> _get (const std::vector& v) { using namespace std; using I = typename _inner::type; - using key = pair; + using key = brep::index_pair; map r; for (size_t n (0); n != v.size (); ++n) @@ -315,14 +335,12 @@ namespace odb //@@ Second argument should be && once ODB uses move(). // - template + template void - _set (std::vector& v, std::map, I>& r) + _set (std::vector& v, std::map& r) { using namespace std; - using key = pair; - for (auto& p: r) { size_t n (p.first.first); -- cgit v1.1