aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-08 18:21:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-08 18:21:32 +0200
commitda00d54b5704d33057a1569366d0e497606dc1a0 (patch)
tree6582eed64989a61db113881824c276a69804ff61
parent9502ebbff304fdd970cbbe3d3e7847851ca89141 (diff)
Add schema_catalog::exists() function
-rw-r--r--odb/schema-catalog.cxx7
-rw-r--r--odb/schema-catalog.hxx9
2 files changed, 16 insertions, 0 deletions
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx
index cd1ded4..f834b1d 100644
--- a/odb/schema-catalog.cxx
+++ b/odb/schema-catalog.cxx
@@ -27,6 +27,13 @@ namespace odb
schema_catalog_impl* schema_catalog_init::catalog = 0;
size_t schema_catalog_init::count = 0;
+ bool schema_catalog::
+ exists (database_id id, const std::string& name)
+ {
+ const schema_catalog_impl& c (*schema_catalog_init::catalog);
+ return c.find (key (id, name)) != c.end ();
+ }
+
void schema_catalog::
create_schema (database& db, const string& name)
{
diff --git a/odb/schema-catalog.hxx b/odb/schema-catalog.hxx
index 861c3d0..0048644 100644
--- a/odb/schema-catalog.hxx
+++ b/odb/schema-catalog.hxx
@@ -20,6 +20,15 @@ namespace odb
public:
static void
create_schema (database&, const std::string& name = "");
+
+ static bool
+ exists (database_id, const std::string& name);
+
+ static bool
+ exists (const database& db, const std::string& name)
+ {
+ return exists (db.id (), name);
+ }
};
namespace common