diff options
-rw-r--r-- | include/ingen/AtomReader.hpp | 9 | ||||
-rw-r--r-- | include/ingen/Parser.hpp | 33 | ||||
-rw-r--r-- | src/AtomReader.cpp | 31 | ||||
-rw-r--r-- | src/ClashAvoider.cpp | 5 | ||||
-rw-r--r-- | src/Parser.cpp | 405 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 16 | ||||
-rw-r--r-- | src/gui/GraphCanvas.cpp | 4 | ||||
-rw-r--r-- | src/gui/LoadGraphWindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/ThreadedLoader.cpp | 27 | ||||
-rw-r--r-- | src/gui/ThreadedLoader.hpp | 23 | ||||
-rw-r--r-- | src/ingen/ingen.cpp | 7 | ||||
-rw-r--r-- | src/server/BlockImpl.hpp | 10 | ||||
-rw-r--r-- | src/server/LV2Block.cpp | 2 | ||||
-rw-r--r-- | src/server/LV2Block.hpp | 6 | ||||
-rw-r--r-- | src/server/events/Copy.cpp | 11 | ||||
-rw-r--r-- | src/server/events/CreatePort.hpp | 5 | ||||
-rw-r--r-- | src/server/events/Delta.hpp | 5 |
17 files changed, 309 insertions, 296 deletions
diff --git a/include/ingen/AtomReader.hpp b/include/ingen/AtomReader.hpp index c83e7e4a..6e5d83fd 100644 --- a/include/ingen/AtomReader.hpp +++ b/include/ingen/AtomReader.hpp @@ -22,9 +22,8 @@ #include "ingen/ingen.h" #include "lv2/atom/atom.h" -#include <boost/optional/optional.hpp> - #include <cstdint> +#include <optional> namespace raul { class Path; @@ -58,9 +57,9 @@ public: private: void get_atom(const LV2_Atom* in, Atom& out); - boost::optional<URI> atom_to_uri(const LV2_Atom* atom); - boost::optional<raul::Path> atom_to_path(const LV2_Atom* atom); - Resource::Graph atom_to_context(const LV2_Atom* atom); + std::optional<URI> atom_to_uri(const LV2_Atom* atom); + std::optional<raul::Path> atom_to_path(const LV2_Atom* atom); + Resource::Graph atom_to_context(const LV2_Atom* atom); void get_props(const LV2_Atom_Object* obj, ingen::Properties& props); diff --git a/include/ingen/Parser.hpp b/include/ingen/Parser.hpp index 485a5fa8..16ee4070 100644 --- a/include/ingen/Parser.hpp +++ b/include/ingen/Parser.hpp @@ -24,8 +24,7 @@ #include "raul/Path.hpp" // IWYU pragma: keep #include "raul/Symbol.hpp" // IWYU pragma: keep -#include <boost/optional/optional.hpp> - +#include <optional> #include <set> #include <string> #include <utility> @@ -80,21 +79,21 @@ public: * @return whether or not load was successful. */ virtual bool parse_file( - World& world, - Interface& target, - const FilePath& path, - const boost::optional<raul::Path>& parent = boost::optional<raul::Path>(), - const boost::optional<raul::Symbol>& symbol = boost::optional<raul::Symbol>(), - const boost::optional<Properties>& data = boost::optional<Properties>()); - - virtual boost::optional<URI> parse_string( - World& world, - Interface& target, - const std::string& str, - const URI& base_uri, - const boost::optional<raul::Path>& parent = boost::optional<raul::Path>(), - const boost::optional<raul::Symbol>& symbol = boost::optional<raul::Symbol>(), - const boost::optional<Properties>& data = boost::optional<Properties>()); + World& world, + Interface& target, + const FilePath& path, + const std::optional<raul::Path>& parent = std::optional<raul::Path>(), + const std::optional<raul::Symbol>& symbol = std::optional<raul::Symbol>(), + const std::optional<Properties>& data = std::optional<Properties>()); + + virtual std::optional<URI> parse_string( + World& world, + Interface& target, + const std::string& str, + const URI& base_uri, + const std::optional<raul::Path>& parent = std::optional<raul::Path>(), + const std::optional<raul::Symbol>& symbol = std::optional<raul::Symbol>(), + const std::optional<Properties>& data = std::optional<Properties>()); }; } // namespace ingen diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index ac52082f..87c6f541 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -31,10 +31,9 @@ #include "lv2/atom/util.h" #include "raul/Path.hpp" -#include <boost/optional/optional.hpp> - #include <cstdint> #include <cstring> +#include <optional> #include <string> namespace ingen { @@ -79,7 +78,7 @@ AtomReader::get_props(const LV2_Atom_Object* obj, } } -boost::optional<URI> +std::optional<URI> AtomReader::atom_to_uri(const LV2_Atom* atom) { if (!atom) { @@ -115,10 +114,10 @@ AtomReader::atom_to_uri(const LV2_Atom* atom) return {}; } -boost::optional<raul::Path> +std::optional<raul::Path> AtomReader::atom_to_path(const LV2_Atom* atom) { - boost::optional<URI> uri = atom_to_uri(atom); + std::optional<URI> uri = atom_to_uri(atom); if (uri && uri_is_path(*uri)) { return uri_to_path(*uri); } @@ -130,7 +129,7 @@ AtomReader::atom_to_context(const LV2_Atom* atom) { Resource::Graph ctx = Resource::Graph::DEFAULT; if (atom) { - boost::optional<URI> maybe_uri = atom_to_uri(atom); + std::optional<URI> maybe_uri = atom_to_uri(atom); if (maybe_uri) { ctx = Resource::uri_to_graph(*maybe_uri); } else { @@ -174,7 +173,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) _uris.patch_sequenceNumber.urid(), &number, nullptr); - const boost::optional<URI> subject_uri = atom_to_uri(subject); + const std::optional<URI> subject_uri = atom_to_uri(subject); const int32_t seq = ((number && number->type == _uris.atom_Int) ? reinterpret_cast<const LV2_Atom_Int*>(number)->body @@ -213,10 +212,10 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) _uris.ingen_incidentTo.urid(), &incidentTo, nullptr); - boost::optional<raul::Path> subject_path(atom_to_path(subject)); - boost::optional<raul::Path> tail_path(atom_to_path(tail)); - boost::optional<raul::Path> head_path(atom_to_path(head)); - boost::optional<raul::Path> other_path(atom_to_path(incidentTo)); + std::optional<raul::Path> subject_path(atom_to_path(subject)); + std::optional<raul::Path> tail_path(atom_to_path(tail)); + std::optional<raul::Path> head_path(atom_to_path(head)); + std::optional<raul::Path> other_path(atom_to_path(incidentTo)); if (tail_path && head_path) { _iface(Disconnect{seq, *tail_path, *head_path}); } else if (subject_path && other_path) { @@ -255,8 +254,8 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) return false; } - boost::optional<raul::Path> tail_path(atom_to_path(tail)); - boost::optional<raul::Path> head_path(atom_to_path(head)); + std::optional<raul::Path> tail_path(atom_to_path(tail)); + std::optional<raul::Path> head_path(atom_to_path(head)); if (tail_path && head_path) { _iface(Connect{seq, *tail_path, *head_path}); } else { @@ -350,7 +349,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) } - boost::optional<URI> dest_uri(atom_to_uri(dest)); + std::optional<URI> dest_uri(atom_to_uri(dest)); if (!dest_uri) { _log.warn("Copy message has non-URI destination\n"); return false; @@ -370,13 +369,13 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) return false; } - boost::optional<raul::Path> subject_path(atom_to_path(subject)); + std::optional<raul::Path> subject_path(atom_to_path(subject)); if (!subject_path) { _log.warn("Move message has non-path subject\n"); return false; } - boost::optional<raul::Path> dest_path(atom_to_path(dest)); + std::optional<raul::Path> dest_path(atom_to_path(dest)); if (!dest_path) { _log.warn("Move message has non-path destination\n"); return false; diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp index 428dd8ba..9c1d8f28 100644 --- a/src/ClashAvoider.cpp +++ b/src/ClashAvoider.cpp @@ -21,12 +21,11 @@ #include "raul/Path.hpp" #include "raul/Symbol.hpp" -#include <boost/optional/optional.hpp> - #include <cassert> #include <cctype> #include <cstdio> #include <cstdlib> +#include <optional> #include <sstream> #include <string> #include <utility> @@ -143,7 +142,7 @@ ClashAvoider::exists(const raul::Path& path) const return _store.find(path) != _store.end(); } -static boost::optional<size_t> +static std::optional<size_t> numeric_suffix_start(const std::string& str) { if (!isdigit(str[str.length() - 1])) { diff --git a/src/Parser.cpp b/src/Parser.cpp index a27dc2b3..58801dba 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -45,10 +45,11 @@ #include <sstream> #include <string> #include <string_view> +#include <type_traits> #include <utility> -#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" -#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" +#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" +#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" namespace ingen { @@ -57,24 +58,25 @@ Parser::find_resources(Sord::World& world, const URI& manifest_uri, const URI& type_uri) { - const Sord::URI base (world, manifest_uri.string()); - const Sord::URI type (world, type_uri.string()); - const Sord::URI rdf_type (world, NS_RDF "type"); + const Sord::URI base(world, manifest_uri.string()); + const Sord::URI type(world, type_uri.string()); + const Sord::URI rdf_type(world, NS_RDF "type"); const Sord::URI rdfs_seeAlso(world, NS_RDFS "seeAlso"); const Sord::Node nil; - SerdEnv* env = serd_env_new(sord_node_to_serd_node(base.c_obj())); + SerdEnv* env = serd_env_new(sord_node_to_serd_node(base.c_obj())); Sord::Model model(world, manifest_uri.string()); model.load_file(env, SERD_TURTLE, manifest_uri.string()); std::set<ResourceRecord> resources; for (auto i = model.find(nil, rdf_type, type); !i.end(); ++i) { - const auto resource = i.get_subject(); - auto f = model.find(resource, rdfs_seeAlso, nil); + const auto resource = i.get_subject(); + auto f = model.find(resource, rdfs_seeAlso, nil); std::string file_path; if (!f.end()) { - uint8_t* p = serd_file_uri_parse(f.get_object().to_u_string(), nullptr); + uint8_t* p = + serd_file_uri_parse(f.get_object().to_u_string(), nullptr); file_path = reinterpret_cast<const char*>(p); serd_free(p); } @@ -86,30 +88,28 @@ Parser::find_resources(Sord::World& world, return resources; } -static boost::optional<raul::Path> +static std::optional<raul::Path> get_path(const URI& base, const URI& uri) { const URI relative = uri.make_relative(base); const std::string uri_str = "/" + relative.string(); return raul::Path::is_valid(uri_str) ? raul::Path(uri_str) - : boost::optional<raul::Path>(); + : std::optional<raul::Path>(); } static bool skip_property(ingen::URIs& uris, const Sord::Node& predicate) { - return (predicate == INGEN__file || - predicate == uris.ingen_arc || - predicate == uris.ingen_block || - predicate == uris.lv2_port); + return (predicate == INGEN__file || predicate == uris.ingen_arc || + predicate == uris.ingen_block || predicate == uris.lv2_port); } static Properties -get_properties(ingen::World& world, - Sord::Model& model, - const Sord::Node& subject, - Resource::Graph ctx, - const boost::optional<Properties>& data = {}) +get_properties(ingen::World& world, + Sord::Model& model, + const Sord::Node& subject, + Resource::Graph ctx, + const std::optional<Properties>& data = {}) { AtomForge forge(world.uri_map().urid_map()); @@ -118,12 +118,13 @@ get_properties(ingen::World& world, for (auto i = model.find(subject, nil, nil); !i.end(); ++i) { if (!skip_property(world.uris(), i.get_predicate())) { forge.clear(); - forge.read( - *world.rdf_world(), model.c_obj(), i.get_object().c_obj()); + forge.read(*world.rdf_world(), + model.c_obj(), + i.get_object().c_obj()); const LV2_Atom* atom = forge.atom(); Atom atomm; - atomm = Forge::alloc( - atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); + atomm = + Forge::alloc(atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); props.emplace(i.get_predicate(), Property(atomm, ctx)); } } @@ -150,7 +151,7 @@ get_properties(ingen::World& world, using PortRecord = std::pair<raul::Path, Properties>; -static boost::optional<PortRecord> +static std::optional<PortRecord> get_port(ingen::World& world, Sord::Model& model, const Sord::Node& subject, @@ -166,9 +167,8 @@ get_port(ingen::World& world, // Get index if requested (for Graphs) if (index) { const auto i = props.find(uris.lv2_index); - if (i == props.end() - || i->second.type() != world.forge().Int - || i->second.get<int32_t>() < 0) { + if (i == props.end() || i->second.type() != world.forge().Int || + i->second.get<int32_t>() < 0) { world.log().error("Port %1% has no valid index\n", subject); return {}; } @@ -185,8 +185,8 @@ get_port(ingen::World& world, const size_t last_slash = subject_str.find_last_of('/'); sym = ((last_slash == std::string::npos) - ? subject_str - : subject_str.substr(last_slash + 1)); + ? subject_str + : subject_str.substr(last_slash + 1)); } if (!raul::Symbol::is_valid(sym)) { @@ -201,64 +201,62 @@ get_port(ingen::World& world, return make_pair(port_path, props); } -static boost::optional<raul::Path> -parse( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - Sord::Node& subject, - const boost::optional<raul::Path>& parent = boost::optional<raul::Path>(), - const boost::optional<raul::Symbol>& symbol = boost::optional<raul::Symbol>(), - const boost::optional<Properties>& data = boost::optional<Properties>()); - -static boost::optional<raul::Path> +static std::optional<raul::Path> +parse(World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + Sord::Node& subject, + const std::optional<raul::Path>& parent = std::optional<raul::Path>(), + const std::optional<raul::Symbol>& symbol = std::optional<raul::Symbol>(), + const std::optional<Properties>& data = std::optional<Properties>()); + +static std::optional<raul::Path> parse_graph( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - Resource::Graph ctx, - const boost::optional<raul::Path>& parent = boost::optional<raul::Path>(), - const boost::optional<raul::Symbol>& symbol = boost::optional<raul::Symbol>(), - const boost::optional<Properties>& data = boost::optional<Properties>()); - -static boost::optional<raul::Path> + World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + Resource::Graph ctx, + const std::optional<raul::Path>& parent = std::optional<raul::Path>(), + const std::optional<raul::Symbol>& symbol = std::optional<raul::Symbol>(), + const std::optional<Properties>& data = std::optional<Properties>()); + +static std::optional<raul::Path> parse_block( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const raul::Path& path, - const boost::optional<Properties>& data = boost::optional<Properties>()); + World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const raul::Path& path, + const std::optional<Properties>& data = std::optional<Properties>()); static bool -parse_arcs( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const raul::Path& graph); - -static boost::optional<raul::Path> -parse_block(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const raul::Path& path, - const boost::optional<Properties>& data) +parse_arcs(World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const raul::Path& graph); + +static std::optional<raul::Path> +parse_block(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const raul::Path& path, + const std::optional<Properties>& data) { const URIs& uris = world.uris(); // Try lv2:prototype and old ingen:prototype for backwards compatibility - const Sord::URI prototype_predicates[] = { - Sord::URI(*world.rdf_world(), uris.lv2_prototype), - Sord::URI(*world.rdf_world(), uris.ingen_prototype) - }; + const Sord::URI prototype_predicates[] = {Sord::URI(*world.rdf_world(), + uris.lv2_prototype), + Sord::URI(*world.rdf_world(), + uris.ingen_prototype)}; // Get prototype Sord::Node prototype; @@ -271,7 +269,8 @@ parse_block(ingen::World& world, if (!prototype.is_valid()) { world.log().error("Block %1% (%2%) missing mandatory lv2:prototype\n", - subject, path); + subject, + path); return {}; } @@ -286,55 +285,66 @@ parse_block(ingen::World& world, &base_uri_parts); SerdURI ignored; - SerdNode sub_uri = serd_node_new_uri_from_string( - type_uri, - &base_uri_parts, - &ignored); + SerdNode sub_uri = + serd_node_new_uri_from_string(type_uri, &base_uri_parts, &ignored); - const std::string sub_uri_str = reinterpret_cast<const char*>(sub_uri.buf); - const std::string sub_file = sub_uri_str + "/main.ttl"; + const std::string sub_uri_str = + reinterpret_cast<const char*>(sub_uri.buf); + const std::string sub_file = sub_uri_str + "/main.ttl"; const SerdNode sub_base = serd_node_from_string( SERD_URI, reinterpret_cast<const uint8_t*>(sub_file.c_str())); Sord::Model sub_model(*world.rdf_world(), sub_file); - SerdEnv* env = serd_env_new(&sub_base); + SerdEnv* env = serd_env_new(&sub_base); sub_model.load_file(env, SERD_TURTLE, sub_file); serd_env_free(env); Sord::URI sub_node(*world.rdf_world(), sub_file); - parse_graph(world, target, sub_model, sub_base, - sub_node, Resource::Graph::INTERNAL, - path.parent(), raul::Symbol(path.symbol()), data); - - parse_graph(world, target, model, base_uri, - subject, Resource::Graph::EXTERNAL, - path.parent(), raul::Symbol(path.symbol()), data); + parse_graph(world, + target, + sub_model, + sub_base, + sub_node, + Resource::Graph::INTERNAL, + path.parent(), + raul::Symbol(path.symbol()), + data); + + parse_graph(world, + target, + model, + base_uri, + subject, + Resource::Graph::EXTERNAL, + path.parent(), + raul::Symbol(path.symbol()), + data); } else { // Prototype is non-file URI, plugin Properties props = get_properties( - world, model, subject, Resource::Graph::DEFAULT, data); + world, model, subject, Resource::Graph::DEFAULT, data); props.emplace(uris.rdf_type, uris.forge.make_urid(uris.ingen_Block)); target.put(path_to_uri(path), props); } return path; } -static boost::optional<raul::Path> -parse_graph(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - Resource::Graph ctx, - const boost::optional<raul::Path>& parent, - const boost::optional<raul::Symbol>& symbol, - const boost::optional<Properties>& data) +static std::optional<raul::Path> +parse_graph(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + Resource::Graph ctx, + const std::optional<raul::Path>& parent, + const std::optional<raul::Symbol>& symbol, + const std::optional<Properties>& data) { const URIs& uris = world.uris(); const Sord::URI ingen_block(*world.rdf_world(), uris.ingen_block); - const Sord::URI lv2_port(*world.rdf_world(), LV2_CORE__port); + const Sord::URI lv2_port(*world.rdf_world(), LV2_CORE__port); const Sord::Node& graph = subject; const Sord::Node nil; @@ -358,9 +368,9 @@ parse_graph(ingen::World& world, Sord::Node port = p.get_object(); // Get all properties - uint32_t index = 0; - boost::optional<PortRecord> port_record = get_port( - world, model, port, ctx, graph_path, &index); + uint32_t index = 0; + std::optional<PortRecord> port_record = + get_port(world, model, port, ctx, graph_path, &index); if (!port_record) { world.log().error("Invalid port %1%\n", port); return {}; @@ -371,15 +381,14 @@ parse_graph(ingen::World& world, ports[index] = *port_record; } else { world.log().error("Ignored port %1% with duplicate index %2%\n", - port, index); + port, + index); } } // Create ports in order by index for (const auto& p : ports) { - target.put(path_to_uri(p.second.first), - p.second.second, - ctx); + target.put(path_to_uri(p.second.first), p.second.second, ctx); } if (ctx != Resource::Graph::INTERNAL) { @@ -392,26 +401,28 @@ parse_graph(ingen::World& world, URI node_uri = node; assert(!node_uri.path().empty() && node_uri.path() != "/"); const raul::Path block_path = graph_path.child( - raul::Symbol(FilePath(node_uri.path()).stem().string())); + raul::Symbol(FilePath(node_uri.path()).stem().string())); // Parse and create block - parse_block(world, target, model, base_uri, node, block_path, - boost::optional<Properties>()); + parse_block( + world, target, model, base_uri, node, block_path, std::nullopt); // For each port on this block for (auto p = model.find(node, lv2_port, nil); !p.end(); ++p) { Sord::Node port = p.get_object(); Resource::Graph subctx = Resource::Graph::DEFAULT; - if (!model.find(node, - Sord::URI(*world.rdf_world(), uris.rdf_type), - Sord::URI(*world.rdf_world(), uris.ingen_Graph)).end()) { + if (!model + .find(node, + Sord::URI(*world.rdf_world(), uris.rdf_type), + Sord::URI(*world.rdf_world(), uris.ingen_Graph)) + .end()) { subctx = Resource::Graph::EXTERNAL; } // Get all properties - boost::optional<PortRecord> port_record = get_port( - world, model, port, subctx, block_path, nullptr); + std::optional<PortRecord> port_record = + get_port(world, model, port, subctx, block_path, nullptr); if (!port_record) { world.log().error("Invalid port %1%\n", port); return {}; @@ -431,12 +442,12 @@ parse_graph(ingen::World& world, } static bool -parse_arc(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const raul::Path& graph) +parse_arc(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const raul::Path& graph) { const URIs& uris = world.uris(); @@ -457,15 +468,15 @@ parse_arc(ingen::World& world, return false; } - const boost::optional<raul::Path> tail_path = get_path( - base_uri, t.get_object()); + const std::optional<raul::Path> tail_path = + get_path(base_uri, t.get_object()); if (!tail_path) { world.log().error("Arc tail has invalid URI\n"); return false; } - const boost::optional<raul::Path> head_path = get_path( - base_uri, h.get_object()); + const std::optional<raul::Path> head_path = + get_path(base_uri, h.get_object()); if (!head_path) { world.log().error("Arc head has invalid URI\n"); return false; @@ -487,12 +498,12 @@ parse_arc(ingen::World& world, } static bool -parse_arcs(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const raul::Path& graph) +parse_arcs(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const raul::Path& graph) { const Sord::URI ingen_arc(*world.rdf_world(), world.uris().ingen_arc); const Sord::Node nil; @@ -504,37 +515,43 @@ parse_arcs(ingen::World& world, return true; } -static boost::optional<raul::Path> -parse(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - Sord::Node& subject, - const boost::optional<raul::Path>& parent, - const boost::optional<raul::Symbol>& symbol, - const boost::optional<Properties>& data) +static std::optional<raul::Path> +parse(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + Sord::Node& subject, + const std::optional<raul::Path>& parent, + const std::optional<raul::Symbol>& symbol, + const std::optional<Properties>& data) { const URIs& uris = world.uris(); - const Sord::URI graph_class (*world.rdf_world(), uris.ingen_Graph); - const Sord::URI block_class (*world.rdf_world(), uris.ingen_Block); - const Sord::URI arc_class (*world.rdf_world(), uris.ingen_Arc); + const Sord::URI graph_class(*world.rdf_world(), uris.ingen_Graph); + const Sord::URI block_class(*world.rdf_world(), uris.ingen_Block); + const Sord::URI arc_class(*world.rdf_world(), uris.ingen_Arc); const Sord::URI internal_class(*world.rdf_world(), uris.ingen_Internal); - const Sord::URI in_port_class (*world.rdf_world(), LV2_CORE__InputPort); + const Sord::URI in_port_class(*world.rdf_world(), LV2_CORE__InputPort); const Sord::URI out_port_class(*world.rdf_world(), LV2_CORE__OutputPort); - const Sord::URI lv2_class (*world.rdf_world(), LV2_CORE__Plugin); - const Sord::URI rdf_type (*world.rdf_world(), uris.rdf_type); + const Sord::URI lv2_class(*world.rdf_world(), LV2_CORE__Plugin); + const Sord::URI rdf_type(*world.rdf_world(), uris.rdf_type); const Sord::Node nil; // Parse explicit subject graph if (subject.is_valid()) { - return parse_graph(world, target, model, base_uri, - subject, Resource::Graph::INTERNAL, - parent, symbol, data); + return parse_graph(world, + target, + model, + base_uri, + subject, + Resource::Graph::INTERNAL, + parent, + symbol, + data); } // Get all subjects and their types (?subject a ?type) - using Subjects = std::map< Sord::Node, std::set<Sord::Node> >; + using Subjects = std::map<Sord::Node, std::set<Sord::Node>>; Subjects subjects; for (auto i = model.find(subject, rdf_type, nil); !i.end(); ++i) { const Sord::Node& rdf_class = i.get_object(); @@ -554,11 +571,17 @@ parse(ingen::World& world, for (const auto& i : subjects) { const Sord::Node& s = i.first; const std::set<Sord::Node>& types = i.second; - boost::optional<raul::Path> ret; + std::optional<raul::Path> ret; if (types.find(graph_class) != types.end()) { - ret = parse_graph(world, target, model, base_uri, - s, Resource::Graph::INTERNAL, - parent, symbol, data); + ret = parse_graph(world, + target, + model, + base_uri, + s, + Resource::Graph::INTERNAL, + parent, + symbol, + data); } else if (types.find(block_class) != types.end()) { const raul::Path rel_path(*get_path(base_uri, s)); const raul::Path path = parent ? parent->child(rel_path) : rel_path; @@ -567,12 +590,12 @@ parse(ingen::World& world, types.find(out_port_class) != types.end()) { const raul::Path rel_path(*get_path(base_uri, s)); const raul::Path path = parent ? parent->child(rel_path) : rel_path; - const Properties properties = get_properties( - world, model, s, Resource::Graph::DEFAULT, data); + const Properties properties = + get_properties(world, model, s, Resource::Graph::DEFAULT, data); target.put(path_to_uri(path), properties); ret = path; } else if (types.find(arc_class) != types.end()) { - raul::Path parent_path(parent ? parent.get() : raul::Path("/")); + raul::Path parent_path(parent ? parent.value() : raul::Path("/")); parse_arc(world, target, model, base_uri, s, parent_path); } else { world.log().error("Subject has no known types\n"); @@ -583,12 +606,12 @@ parse(ingen::World& world, } bool -Parser::parse_file(ingen::World& world, - ingen::Interface& target, - const FilePath& path, - const boost::optional<raul::Path>& parent, - const boost::optional<raul::Symbol>& symbol, - const boost::optional<Properties>& data) +Parser::parse_file(ingen::World& world, + ingen::Interface& target, + const FilePath& path, + const std::optional<raul::Path>& parent, + const std::optional<raul::Symbol>& symbol, + const std::optional<Properties>& data) { // Get absolute file path FilePath file_path = path; @@ -599,26 +622,26 @@ Parser::parse_file(ingen::World& world, // Find file to use as manifest const bool is_bundle = std::filesystem::is_directory(file_path); const FilePath manifest_path = - (is_bundle ? file_path / "manifest.ttl" : file_path); + (is_bundle ? file_path / "manifest.ttl" : file_path); URI manifest_uri(manifest_path); // Find graphs in manifest - const std::set<ResourceRecord> resources = find_resources( - *world.rdf_world(), manifest_uri, URI(INGEN__Graph)); + const std::set<ResourceRecord> resources = + find_resources(*world.rdf_world(), manifest_uri, URI(INGEN__Graph)); if (resources.empty()) { world.log().error("No graphs found in %1%\n", path); return false; } - /* Choose the graph to load. If this is a manifest, then there should only be - one, but if this is a graph file, subgraphs will be returned as well. + /* Choose the graph to load. If this is a manifest, then there should only + be one, but if this is a graph file, subgraphs will be returned as well. In this case, choose the one with the file URI. */ URI uri; for (const ResourceRecord& r : resources) { if (r.uri == URI(manifest_path)) { - uri = r.uri; + uri = r.uri; file_path = r.filename; break; } @@ -642,7 +665,10 @@ Parser::parse_file(ingen::World& world, SerdEnv* env = serd_env_new(&base_node); // Load graph into model - Sord::Model model(*world.rdf_world(), uri.string(), SORD_SPO|SORD_PSO, false); + Sord::Model model(*world.rdf_world(), + uri.string(), + SORD_SPO | SORD_PSO, + false); model.load_file(env, SERD_TURTLE, file_uri); serd_env_free(env); @@ -655,9 +681,8 @@ Parser::parse_file(ingen::World& world, } Sord::Node subject(*world.rdf_world(), Sord::Node::URI, uri.string()); - boost::optional<raul::Path> parsed_path - = parse(world, target, model, model.base_uri(), - subject, parent, symbol, data); + std::optional<raul::Path> parsed_path = parse( + world, target, model, model.base_uri(), subject, parent, symbol, data); if (parsed_path) { target.set_property(path_to_uri(*parsed_path), @@ -670,22 +695,22 @@ Parser::parse_file(ingen::World& world, return false; } -boost::optional<URI> -Parser::parse_string(ingen::World& world, - ingen::Interface& target, - const std::string& str, - const URI& base_uri, - const boost::optional<raul::Path>& parent, - const boost::optional<raul::Symbol>& symbol, - const boost::optional<Properties>& data) +std::optional<URI> +Parser::parse_string(ingen::World& world, + ingen::Interface& target, + const std::string& str, + const URI& base_uri, + const std::optional<raul::Path>& parent, + const std::optional<raul::Symbol>& symbol, + const std::optional<Properties>& data) { // Load string into model - Sord::Model model(*world.rdf_world(), base_uri, SORD_SPO|SORD_PSO, false); + Sord::Model model(*world.rdf_world(), base_uri, SORD_SPO | SORD_PSO, false); SerdEnv* env = serd_env_new(nullptr); if (!base_uri.empty()) { const SerdNode base = serd_node_from_string( - SERD_URI, reinterpret_cast<const uint8_t*>(base_uri.c_str())); + SERD_URI, reinterpret_cast<const uint8_t*>(base_uri.c_str())); serd_env_set_base_uri(env, &base); } model.load_string(env, SERD_TURTLE, str.c_str(), str.length(), base_uri); diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 306846ee..4e0391f2 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -20,8 +20,6 @@ #include "ingen/client/PluginUI.hpp" #include "lv2/core/lv2.h" -#include <boost/optional/optional.hpp> - #include <cctype> #include <cstring> #include <memory> @@ -115,32 +113,32 @@ PluginModel::get_property(const URI& key) const } if (_lilv_plugin) { - boost::optional<const Atom&> ret; - LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str()); - LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred); + const Atom* ret = nullptr; + LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str()); + LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred); lilv_node_free(lv2_pred); LILV_FOREACH (nodes, i, values) { const LilvNode* value = lilv_nodes_get(values, i); if (lilv_node_is_uri(value)) { - ret = set_property( + ret = &set_property( key, _uris.forge.make_urid(URI(lilv_node_as_uri(value)))); break; } if (lilv_node_is_string(value)) { - ret = set_property( + ret = &set_property( key, _uris.forge.alloc(lilv_node_as_string(value))); break; } if (lilv_node_is_float(value)) { - ret = set_property( + ret = &set_property( key, _uris.forge.make(lilv_node_as_float(value))); break; } if (lilv_node_is_int(value)) { - ret = set_property( + ret = &set_property( key, _uris.forge.make(lilv_node_as_int(value))); break; } diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 3acd510d..74542c87 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -61,7 +61,6 @@ #include "raul/Symbol.hpp" #include "sord/sordmm.hpp" -#include <boost/optional/optional.hpp> #include <gdk/gdk.h> #include <gdk/gdkkeysyms-compat.h> #include <gdkmm/window.h> @@ -94,6 +93,7 @@ #include <map> #include <memory> #include <mutex> +#include <optional> #include <set> #include <sstream> #include <string> @@ -727,7 +727,7 @@ GraphCanvas::paste() {{uris.rdf_type, Property(uris.ingen_Graph)}}); // Parse clipboard text into clipboard store - boost::optional<URI> base_uri = parser->parse_string( + std::optional<URI> base_uri = parser->parse_string( _app.world(), clipboard, str, main_uri()); // Figure out the copy graph base path diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp index b44a1fe7..61796de4 100644 --- a/src/gui/LoadGraphWindow.cpp +++ b/src/gui/LoadGraphWindow.cpp @@ -31,7 +31,6 @@ #include "ingen/runtime_paths.hpp" #include "raul/Path.hpp" -#include <boost/optional/optional.hpp> #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> #include <glibmm/propertyproxy.h> @@ -52,6 +51,7 @@ #include <list> #include <map> #include <memory> +#include <optional> #include <sstream> #include <string> #include <utility> @@ -187,8 +187,8 @@ LoadGraphWindow::ok_clicked() if (_import) { // If unset load_graph will load value - boost::optional<raul::Path> parent; - boost::optional<raul::Symbol> symbol; + std::optional<raul::Path> parent; + std::optional<raul::Symbol> symbol; if (!_graph->path().is_root()) { parent = _graph->path().parent(); symbol = _graph->symbol(); diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index d3672bda..0e5f1b01 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -26,7 +26,6 @@ #include "ingen/client/GraphModel.hpp" #include "raul/Path.hpp" -#include <boost/optional/optional.hpp> #include <glibmm/ustring.h> #include <sigc++/adaptors/bind.h> #include <sigc++/adaptors/retype_return.h> @@ -35,12 +34,11 @@ #include <cassert> #include <filesystem> #include <memory> +#include <optional> #include <string> #include <string_view> #include <utility> -using boost::optional; - namespace ingen { class Interface; @@ -85,20 +83,20 @@ ThreadedLoader::run() } void -ThreadedLoader::load_graph(bool merge, - const FilePath& file_path, - const optional<raul::Path>& engine_parent, - const optional<raul::Symbol>& engine_symbol, - const optional<Properties>& engine_data) +ThreadedLoader::load_graph(bool merge, + const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data) { std::lock_guard<std::mutex> lock(_mutex); Glib::ustring engine_base = ""; if (engine_parent) { if (merge) { - engine_base = engine_parent.get(); + engine_base = *engine_parent; } else { - engine_base = engine_parent.get().base(); + engine_base = engine_parent->base(); } } @@ -113,10 +111,11 @@ ThreadedLoader::load_graph(bool merge, } void -ThreadedLoader::load_graph_event(const FilePath& file_path, - const optional<raul::Path>& engine_parent, - const optional<raul::Symbol>& engine_symbol, - const optional<Properties>& engine_data) +ThreadedLoader::load_graph_event( + const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data) { std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp index d338b63f..83860461 100644 --- a/src/gui/ThreadedLoader.hpp +++ b/src/gui/ThreadedLoader.hpp @@ -25,12 +25,9 @@ #include <list> #include <memory> #include <mutex> +#include <optional> #include <thread> -namespace boost { -template <class T> class optional; -} // namespace boost - namespace raul { class Path; class Symbol; @@ -70,11 +67,11 @@ public: ~ThreadedLoader(); - void load_graph(bool merge, - const FilePath& file_path, - const boost::optional<raul::Path>& engine_parent, - const boost::optional<raul::Symbol>& engine_symbol, - const boost::optional<Properties>& engine_data); + void load_graph(bool merge, + const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data); void save_graph(const std::shared_ptr<const client::GraphModel>& model, const URI& uri); @@ -82,10 +79,10 @@ public: std::shared_ptr<Parser> parser(); private: - void load_graph_event(const FilePath& file_path, - const boost::optional<raul::Path>& engine_parent, - const boost::optional<raul::Symbol>& engine_symbol, - const boost::optional<Properties>& engine_data); + void load_graph_event(const FilePath& file_path, + const std::optional<raul::Path>& engine_parent, + const std::optional<raul::Symbol>& engine_symbol, + const std::optional<Properties>& engine_data); void save_graph_event(const std::shared_ptr<const client::GraphModel>& model, diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index 06d990f2..8f1233e1 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -35,8 +35,6 @@ #include "ingen/client/SocketClient.hpp" #endif -#include <boost/optional/optional.hpp> - #include <chrono> #include <csignal> #include <cstdint> @@ -45,6 +43,7 @@ #include <iostream> #include <memory> #include <mutex> +#include <optional> #include <string> #include <thread> @@ -180,8 +179,8 @@ run(int argc, char** argv) // Load a graph if (conf.option("load").is_valid()) { - boost::optional<raul::Path> parent; - boost::optional<raul::Symbol> symbol; + std::optional<raul::Path> parent; + std::optional<raul::Symbol> symbol; const Atom& path_option = conf.option("path"); if (path_option.is_valid()) { diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index 9d63f78e..b845c612 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -33,10 +33,10 @@ #include "raul/Maid.hpp" #include <boost/intrusive/slist_hook.hpp> -#include <boost/optional/optional.hpp> #include <cstdint> #include <memory> +#include <optional> #include <set> namespace raul { @@ -115,9 +115,11 @@ public: {} /** Save current state as preset. */ - virtual boost::optional<Resource> - save_preset(const URI& bundle, - const Properties& props) { return {}; } + virtual std::optional<Resource> + save_preset(const URI& bundle, const Properties& props) + { + return std::nullopt; + } /** Learn the next incoming MIDI event (for internals) */ virtual void learn() {} diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 4cdcecd7..23e58d43 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -705,7 +705,7 @@ get_port_value(const char* port_symbol, return nullptr; } -boost::optional<Resource> +std::optional<Resource> LV2Block::save_preset(const URI& uri, const Properties& props) { diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp index fa3979cd..253008c0 100644 --- a/src/server/LV2Block.hpp +++ b/src/server/LV2Block.hpp @@ -33,7 +33,6 @@ #include <boost/intrusive/slist.hpp> #include <boost/intrusive/slist_hook.hpp> -#include <boost/optional/optional.hpp> #include <cstdint> #include <cstdlib> @@ -41,6 +40,7 @@ #include <filesystem> #include <memory> #include <mutex> +#include <optional> namespace raul { class Symbol; @@ -113,8 +113,8 @@ public: void apply_state(const std::unique_ptr<Worker>& worker, const LilvState* state) override; - boost::optional<Resource> save_preset(const URI& uri, - const Properties& props) override; + std::optional<Resource> save_preset(const URI& uri, + const Properties& props) override; void set_port_buffer(uint32_t voice, uint32_t port_num, diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index 06a71fdc..c62417e0 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -34,11 +34,10 @@ #include "raul/Path.hpp" #include "raul/Symbol.hpp" -#include <boost/optional/optional.hpp> - #include <map> #include <memory> #include <mutex> +#include <optional> #include <string> #include <string_view> #include <utility> @@ -190,10 +189,10 @@ Copy::filesystem_to_engine(PreProcessContext&) std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex()); // Old URI is a filesystem path and new URI is a path within the engine - const std::string src_path(_msg.old_uri.path()); - const raul::Path dst_path = uri_to_path(_msg.new_uri); - boost::optional<raul::Path> dst_parent; - boost::optional<raul::Symbol> dst_symbol; + const std::string src_path(_msg.old_uri.path()); + const raul::Path dst_path = uri_to_path(_msg.new_uri); + std::optional<raul::Path> dst_parent; + std::optional<raul::Symbol> dst_symbol; if (!dst_path.is_root()) { dst_parent = dst_path.parent(); dst_symbol = raul::Symbol(dst_path.symbol()); diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp index 3351adc9..6d3e9ca2 100644 --- a/src/server/events/CreatePort.hpp +++ b/src/server/events/CreatePort.hpp @@ -27,10 +27,9 @@ #include "raul/Maid.hpp" #include "raul/Path.hpp" -#include <boost/optional/optional.hpp> - #include <cstdint> #include <memory> +#include <optional> namespace ingen { @@ -81,7 +80,7 @@ private: EnginePort* _engine_port{nullptr}; ///< Driver port if on the root Properties _properties; Properties _update; - boost::optional<Flow> _flow; + std::optional<Flow> _flow; }; } // namespace events diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index 7f79ae94..35357a26 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -29,10 +29,9 @@ #include "ingen/URI.hpp" #include "raul/Maid.hpp" -#include <boost/optional/optional.hpp> - #include <cstdint> #include <memory> +#include <optional> #include <vector> // IWYU pragma: no_include <algorithm> @@ -129,7 +128,7 @@ private: std::vector<ControlBindings::Binding*> _removed_bindings; - boost::optional<Resource> _preset; + std::optional<Resource> _preset; bool _block{false}; }; |