From 2ba09e4b41b01cbd8f8756eb0e3b7e33136e06b3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 15 Feb 2017 22:41:18 +0100 Subject: Move static path stuff to its own header --- ingen/Node.hpp | 22 +--------------------- ingen/paths.hpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 ingen/paths.hpp (limited to 'ingen') diff --git a/ingen/Node.hpp b/ingen/Node.hpp index 72c0b3cb..a585d03a 100644 --- a/ingen/Node.hpp +++ b/ingen/Node.hpp @@ -19,6 +19,7 @@ #include "ingen/Resource.hpp" #include "ingen/ingen.h" +#include "ingen/paths.hpp" #include "ingen/types.hpp" #include "lilv/lilv.h" #include "raul/Path.hpp" @@ -84,27 +85,6 @@ public: return Raul::URI(uri() + '/'); } - static Raul::URI main_uri() { return Raul::URI("ingen:/main"); } - - static bool uri_is_path(const Raul::URI& uri) { - const size_t root_len = main_uri().length(); - if (uri == main_uri()) { - return true; - } else { - return uri.substr(0, root_len + 1) == main_uri() + "/"; - } - } - - static Raul::Path uri_to_path(const Raul::URI& uri) { - return (uri == main_uri()) - ? Raul::Path("/") - : Raul::Path(uri.substr(main_uri().length())); - } - - static Raul::URI path_to_uri(const Raul::Path& path) { - return Raul::URI(main_uri() + path.c_str()); - } - protected: friend class Store; virtual void set_path(const Raul::Path& p) = 0; diff --git a/ingen/paths.hpp b/ingen/paths.hpp new file mode 100644 index 00000000..4924a148 --- /dev/null +++ b/ingen/paths.hpp @@ -0,0 +1,51 @@ +/* + This file is part of Ingen. + Copyright 2007-2017 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or any later version. + + Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_PATHS_HPP +#define INGEN_PATHS_HPP + +#include "raul/URI.hpp" +#include "raul/Path.hpp" + +namespace Ingen { + +inline Raul::URI main_uri() { return Raul::URI("ingen:/main"); } + +inline bool uri_is_path(const Raul::URI& uri) +{ + const size_t root_len = main_uri().length(); + if (uri == main_uri()) { + return true; + } else { + return uri.substr(0, root_len + 1) == main_uri() + "/"; + } +} + +inline Raul::Path uri_to_path(const Raul::URI& uri) +{ + return (uri == main_uri()) + ? Raul::Path("/") + : Raul::Path(uri.substr(main_uri().length())); +} + +inline Raul::URI path_to_uri(const Raul::Path& path) +{ + return Raul::URI(main_uri() + path.c_str()); +} + +} // namespace Ingen + +#endif // INGEN_PATHS_HPP -- cgit v1.2.1