aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/build.txx4
-rw-r--r--bdep/deinit.cxx4
-rw-r--r--bdep/new.cxx18
-rwxr-xr-xbdep/odb.sh1
-rw-r--r--bdep/project.cxx9
-rw-r--r--bdep/project.hxx14
-rw-r--r--bdep/project.xml2
-rw-r--r--bdep/status.cxx4
-rw-r--r--bdep/sync.cxx4
-rw-r--r--bdep/value-traits.hxx54
10 files changed, 90 insertions, 24 deletions
diff --git a/bdep/build.txx b/bdep/build.txx
index 804d590..a1690b4 100644
--- a/bdep/build.txx
+++ b/bdep/build.txx
@@ -65,7 +65,7 @@ namespace bdep
if (!all)
{
for (const package_location& p: pp.packages)
- pkgs.push_back (p.name.c_str ());
+ pkgs.push_back (p.name.string ().c_str ());
}
// Build in each configuration skipping empty ones.
@@ -88,7 +88,7 @@ namespace bdep
pkgs.clear ();
for (const package_state& p: c->packages)
- pkgs.push_back (p.name.c_str ());
+ pkgs.push_back (p.name.string ().c_str ());
}
// If we are printing multiple configurations, separate them with a
diff --git a/bdep/deinit.cxx b/bdep/deinit.cxx
index 87f478f..40c13a4 100644
--- a/bdep/deinit.cxx
+++ b/bdep/deinit.cxx
@@ -134,7 +134,7 @@ namespace bdep
if (!all)
{
for (const package_location& p: pp.packages)
- pkgs.push_back (p.name);
+ pkgs.push_back (p.name.string ());
}
// Deinitialize in each configuration skipping empty ones.
@@ -173,7 +173,7 @@ namespace bdep
pkgs.clear ();
for (const package_state& p: c->packages)
- pkgs.push_back (p.name);
+ pkgs.push_back (p.name.string ());
}
c->packages.erase (
diff --git a/bdep/new.cxx b/bdep/new.cxx
index e5f4329..505ed96 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -4,8 +4,6 @@
#include <bdep/new.hxx>
-#include <libbpkg/manifest.hxx> // validate_package_name()
-
#include <bdep/project.hxx>
#include <bdep/database.hxx>
#include <bdep/diagnostics.hxx>
@@ -86,23 +84,27 @@ namespace bdep
// Validate argument.
//
- string n (args.more () ? args.next () : "");
- if (n.empty ())
+ string a (args.more () ? args.next () : "");
+ if (a.empty ())
fail << "project name argument expected";
// If the project type is not empty then the project name is also a package
- // name, so let's validate it as such.
+ // name.
//
+ bpkg::package_name pn;
+
if (t != type::empty)
try
{
- bpkg::validate_package_name (n);
+ pn = bpkg::package_name (move (a));
}
catch (const invalid_argument& e)
{
fail << "invalid package name: " << e;
}
+ const string& n (t != type::empty ? pn.string () : a);
+
// Full name vs the name stem (e.g, 'hello' in 'libhello').
//
// We use the full name for filesystem directories and preprocessor macros
@@ -998,8 +1000,8 @@ namespace bdep
{
package_locations pkgs;
- if (t != type::empty)
- pkgs.push_back (package_location {n, dir_path ()}); // prj == pkg
+ if (t != type::empty) // prj == pkg
+ pkgs.push_back (package_location {move (pn), dir_path ()});
configurations cfgs {
cmd_init_config (
diff --git a/bdep/odb.sh b/bdep/odb.sh
index 07c744a..a2596e3 100755
--- a/bdep/odb.sh
+++ b/bdep/odb.sh
@@ -14,6 +14,7 @@ $odb $lib -I.. -I../../libbpkg -I../../libbutl \
-d sqlite --std c++14 --generate-query \
--odb-epilogue '#include <bdep/wrapper-traits.hxx>' \
--hxx-prologue '#include <bdep/wrapper-traits.hxx>' \
+ --hxx-prologue '#include <bdep/value-traits.hxx>' \
--include-with-brackets --include-prefix bdep --guard-prefix BDEP \
--sqlite-override-null project.hxx
diff --git a/bdep/project.cxx b/bdep/project.cxx
index 59ba21e..ec323cb 100644
--- a/bdep/project.cxx
+++ b/bdep/project.cxx
@@ -233,11 +233,11 @@ namespace bdep
dir_path d (path_cast<dir_path> (move (*m.location)));
d.normalize (false /* actualize */, true /* cur_empty */);
- pls.push_back (package_location {string (), move (d)});
+ pls.push_back (package_location {package_name (), move (d)});
}
}
else if (exists (prj / manifest_file))
- pls.push_back (package_location {string (), dir_path ()});
+ pls.push_back (package_location {package_name (), dir_path ()});
else if (!allow_empty)
fail << "no packages in project " << prj;
@@ -305,7 +305,8 @@ namespace bdep
{
// Name is to be extracted later.
//
- r.packages.push_back (package_location {"", move (*p.package)});
+ r.packages.push_back (
+ package_location {package_name (), move (*p.package)});
}
}
}
@@ -320,7 +321,7 @@ namespace bdep
{
// Name is to be extracted later.
//
- r.packages.push_back (package_location {"", *p.package});
+ r.packages.push_back (package_location {package_name (), *p.package});
}
}
diff --git a/bdep/project.hxx b/bdep/project.hxx
index 20d3cf7..612897d 100644
--- a/bdep/project.hxx
+++ b/bdep/project.hxx
@@ -7,6 +7,8 @@
#include <odb/core.hxx>
+#include <libbpkg/package-name.hxx>
+
#include <bdep/types.hxx>
#include <bdep/utility.hxx>
@@ -38,6 +40,12 @@ namespace bdep
to((?) ? (?)->string () : bdep::optional_string ()) \
from((?) ? bdep::dir_path (*(?)) : bdep::optional_dir_path ())
+ // package_name
+ //
+ using bpkg::package_name;
+
+ #pragma db value(package_name) type("TEXT") options("COLLATE NOCASE")
+
// State of a package in a configuration.
//
// Pretty much everything about the package can change (including location
@@ -51,7 +59,7 @@ namespace bdep
#pragma db value
struct package_state
{
- string name;
+ package_name name;
};
// Configuration associated with a project.
@@ -162,8 +170,8 @@ namespace bdep
//
struct package_location
{
- string name;
- dir_path path;
+ package_name name;
+ dir_path path;
};
using package_locations = vector<package_location>;
diff --git a/bdep/project.xml b/bdep/project.xml
index b9da262..e69af8b 100644
--- a/bdep/project.xml
+++ b/bdep/project.xml
@@ -21,7 +21,7 @@
<table name="configuration_packages" kind="container">
<column name="object_id" type="INTEGER" null="true"/>
<column name="index" type="INTEGER" null="true"/>
- <column name="name" type="TEXT" null="true"/>
+ <column name="name" type="TEXT" null="true" options="COLLATE NOCASE"/>
<foreign-key name="object_id_fk" on-delete="CASCADE">
<column name="object_id"/>
<references table="configuration">
diff --git a/bdep/status.cxx b/bdep/status.cxx
index c9f62d0..080e970 100644
--- a/bdep/status.cxx
+++ b/bdep/status.cxx
@@ -68,12 +68,12 @@ namespace bdep
if (ps.empty ())
{
for (const package_state& p: c->packages)
- pkgs.push_back (p.name);
+ pkgs.push_back (p.name.string ());
}
else
{
for (const package_location& p: ps)
- pkgs.push_back (p.name);
+ pkgs.push_back (p.name.string ());
}
cmd_status (o, prj, c->path, pkgs, fetch);
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index b1589ad..84cb715 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -254,7 +254,7 @@ namespace bdep
// since there is no guarantee a higher version isn't available from
// another repository.
//
- args.push_back (pkg.name + '@' + prj.path.string ());
+ args.push_back (pkg.name.string () + '@' + prj.path.string ());
}
}
@@ -402,7 +402,7 @@ namespace bdep
if (o != nullptr)
{
- dir_path out (dir_path (cfg) /= pkg.name);
+ dir_path out (dir_path (cfg) /= pkg.name.string ());
run_b (co,
o,
src.representation () + '@' + out.representation () +
diff --git a/bdep/value-traits.hxx b/bdep/value-traits.hxx
new file mode 100644
index 0000000..9984bae
--- /dev/null
+++ b/bdep/value-traits.hxx
@@ -0,0 +1,54 @@
+// file : bdep/value-traits.hxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef BDEP_VALUE_TRAITS_HXX
+#define BDEP_VALUE_TRAITS_HXX
+
+#include <string>
+#include <cstddef> // size_t
+#include <utility> // move()
+
+#include <odb/sqlite/traits.hxx>
+
+#include <libbpkg/package-name.hxx>
+
+namespace odb
+{
+ namespace sqlite
+ {
+ template <>
+ class value_traits<bpkg::package_name, id_text>:
+ value_traits<std::string, id_text>
+ {
+ public:
+ using value_type = bpkg::package_name;
+ using query_type = bpkg::package_name;
+ using image_type = details::buffer;
+
+ using base_type = value_traits<std::string, id_text>;
+
+ static void
+ set_value (value_type& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
+ {
+ std::string s;
+ base_type::set_value (s, b, n, is_null);
+ v = !s.empty () ? value_type (std::move (s)) : value_type ();
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const value_type& v)
+ {
+ base_type::set_image (b, n, is_null, v.string ());
+ }
+ };
+ };
+}
+
+#endif // BDEP_WRAPPER_TRAITS_HXX