diff options
author | David Robillard <d@drobilla.net> | 2012-08-12 23:42:17 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-12 23:42:17 +0000 |
commit | 40516c23f43aaf4ca785014dff596d8f66677de3 (patch) | |
tree | 5333face1ac86aaa7576fa6a5e684481415e32e0 /raul/URI.hpp | |
parent | 4fe22a4f393e5e7731a07405767571da021602da (diff) | |
download | raul-40516c23f43aaf4ca785014dff596d8f66677de3.tar.gz raul-40516c23f43aaf4ca785014dff596d8f66677de3.tar.bz2 raul-40516c23f43aaf4ca785014dff596d8f66677de3.zip |
Use ingen:root as the path for the root patch, opening up path space for engine/driver/etc.
Strict conversion between Path and URI (Path no longer is-a URI).
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4672 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul/URI.hpp')
-rw-r--r-- | raul/URI.hpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/raul/URI.hpp b/raul/URI.hpp index bc64b8c..83454ca 100644 --- a/raul/URI.hpp +++ b/raul/URI.hpp @@ -23,6 +23,8 @@ #include <ostream> #include <glib.h> +#include "raul/Path.hpp" + namespace Raul { /** Simple wrapper around standard string with useful URI-specific methods. @@ -47,11 +49,12 @@ public: * It is a fatal error to construct a URI from an invalid string, * use is_valid first to check. */ - URI(const std::basic_string<char>& uri="nil:0") + URI(const std::basic_string<char>& uri="nil:0") throw(BadURI) : _str(g_intern_string(uri.c_str())) { - if (!is_valid(uri)) + if (!is_valid(uri)) { throw BadURI(uri); + } } /** Construct a URI from a C string. @@ -59,13 +62,18 @@ public: * It is a fatal error to construct a URI from an invalid string, * use is_valid first to check. */ - URI(const char* uri) + URI(const char* uri) throw(BadURI) : _str(g_intern_string(uri)) { if (!is_valid(uri)) throw BadURI(uri); } + /** Construct a URI from a base URI and a Path. */ + URI(const URI& base, const Path& path) + : _str(g_intern_string((base.str() + path.c_str()).c_str())) + {} + static bool is_valid(const std::basic_string<char>& uri) { return uri.find(":") != std::string::npos; } @@ -95,22 +103,23 @@ public: inline char operator[](int i) const { return _str[i]; } - inline size_t length() const { return str().length(); } - inline size_t find(const std::string& s) const { return str().find(s); } - inline size_t find_last_of(char c) const { return str().find_last_of(c); } + inline size_t length() const { return str().length(); } + inline size_t find(const std::string& s) const { return str().find(s); } + inline size_t find_last_of(char c) const { return str().find_last_of(c); } private: const char* _str; }; +} // namespace Raul + static inline std::ostream& -operator<<(std::ostream& os, const URI& uri) +operator<<(std::ostream& os, const Raul::URI& uri) { return (os << uri.c_str()); } -} // namespace Raul #endif // RAUL_URI_HPP |