aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-08-27 08:20:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-08-27 08:20:23 +0200
commit7c3e06b937e57bf57216b5c63b538d27da005227 (patch)
tree7215da225e37ddb9c997efb2a5de25b84b288b46
parent91830e3bd38a05c73d03a5dfb88997799d44274b (diff)
Add support for getting version and migration flag in one structure
-rw-r--r--odb/database.hxx8
-rw-r--r--odb/database.ixx15
-rw-r--r--odb/forward.hxx10
3 files changed, 24 insertions, 9 deletions
diff --git a/odb/database.hxx b/odb/database.hxx
index 6c70da7..a4ef058 100644
--- a/odb/database.hxx
+++ b/odb/database.hxx
@@ -335,6 +335,7 @@ namespace odb
//
public:
typedef odb::schema_version schema_version_type;
+ typedef odb::schema_version_migration schema_version_migration_type;
schema_version_type
schema_version (const std::string& schema_name = "") const;
@@ -342,6 +343,9 @@ namespace odb
bool
schema_migration (const std::string& schema_name = "") const;
+ const schema_version_migration_type&
+ schema_version_migration (const std::string& schema_name = "") const;
+
// Set schema version and migration state manually.
//
void
@@ -362,10 +366,8 @@ namespace odb
const std::string& schema_name);
protected:
- struct schema_version_info
+ struct schema_version_info: schema_version_migration_type
{
- schema_version_type version;
- bool migration;
std::string version_table;
};
diff --git a/odb/database.ixx b/odb/database.ixx
index 066afd6..817aebe 100644
--- a/odb/database.ixx
+++ b/odb/database.ixx
@@ -24,19 +24,22 @@ namespace odb
inline database::schema_version_type database::
schema_version (const std::string& name) const
{
- schema_version_map::const_iterator i (schema_version_map_.find (name));
- return i != schema_version_map_.end () && i->second.version != 0
- ? i->second.version
- : load_schema_version (name).version;
+ return schema_version_migration (name).version;
}
inline bool database::
schema_migration (const std::string& name) const
{
+ return schema_version_migration (name).migration;
+ }
+
+ inline const database::schema_version_migration_type& database::
+ schema_version_migration (const std::string& name) const
+ {
schema_version_map::const_iterator i (schema_version_map_.find (name));
return i != schema_version_map_.end () && i->second.version != 0
- ? i->second.migration
- : load_schema_version (name).migration;
+ ? i->second
+ : load_schema_version (name);
}
inline void database::
diff --git a/odb/forward.hxx b/odb/forward.hxx
index f8b3420..7a4cd98 100644
--- a/odb/forward.hxx
+++ b/odb/forward.hxx
@@ -28,6 +28,16 @@ namespace odb
//
//
typedef unsigned long long schema_version;
+
+ struct schema_version_migration
+ {
+ schema_version_migration (schema_version v = 0, bool m = false)
+ : version (v), migration (m) {}
+
+ schema_version version;
+ bool migration;
+ };
+
class database;
class connection;
typedef details::shared_ptr<connection> connection_ptr;