summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Szmigin <smidge@xsco.net>2020-08-20 18:34:23 +0100
committerGitHub <noreply@github.com>2020-08-20 18:34:23 +0100
commitf14366864b6d66fc69741141acbb4e66b88d9854 (patch)
tree07da14039f97e889082d909720309690fd704365
parent7880bfe9cbcfda05a38a74e6a53f1ce5e8cc8b6d (diff)
parent72fd8d7ac8a53616d6dcb899ee40a22b67704805 (diff)
Merge pull request #21 from xsco/enh/std-optional-support
Use `std::optional` or experimental as available
-rw-r--r--CMakeLists.txt13
-rw-r--r--example/engine_prime.cpp4
-rw-r--r--include/djinterop/config.hpp.in (renamed from include/djinterop/config.hpp)6
-rw-r--r--include/djinterop/crate.hpp8
-rw-r--r--include/djinterop/database.hpp19
-rw-r--r--include/djinterop/meson.build20
-rw-r--r--include/djinterop/optional.hpp63
-rw-r--r--include/djinterop/track.hpp97
-rw-r--r--include/meson.build5
-rw-r--r--meson.build2
-rw-r--r--src/djinterop/crate.cpp7
-rw-r--r--src/djinterop/database.cpp6
-rw-r--r--src/djinterop/enginelibrary/el_crate_impl.cpp34
-rw-r--r--src/djinterop/enginelibrary/el_crate_impl.hpp6
-rw-r--r--src/djinterop/enginelibrary/el_database_impl.cpp26
-rw-r--r--src/djinterop/enginelibrary/el_database_impl.hpp6
-rw-r--r--src/djinterop/enginelibrary/el_track_impl.cpp187
-rw-r--r--src/djinterop/enginelibrary/el_track_impl.hpp109
-rw-r--r--src/djinterop/enginelibrary/performance_data_format.cpp27
-rw-r--r--src/djinterop/enginelibrary/performance_data_format.hpp14
-rw-r--r--src/djinterop/impl/crate_impl.hpp8
-rw-r--r--src/djinterop/impl/database_impl.hpp9
-rw-r--r--src/djinterop/impl/track_impl.hpp97
-rw-r--r--src/djinterop/impl/util.cpp63
-rw-r--r--src/djinterop/impl/util.hpp5
-rw-r--r--src/djinterop/track.cpp136
-rw-r--r--test/enginelibrary/performance_data_test.cpp61
-rw-r--r--test/enginelibrary/track_test.cpp17
28 files changed, 565 insertions, 490 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea07846..73d9df2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@
# The meson/ninja build should be preferred in all other cases.
#
cmake_minimum_required(VERSION 3.10)
-project(libdjinterop VERSION 0.11.0)
+project(libdjinterop VERSION 0.12.0)
# Require C++17
set(CMAKE_CXX_STANDARD 17)
@@ -18,6 +18,14 @@ find_package(SQLite3 3.11.0 REQUIRED)
# Require zlib >= 1.2.8
find_package(ZLIB 1.2.8 REQUIRED)
+# Generate config.hpp based on build-time environment.
+include(CheckIncludeFileCXX)
+CHECK_INCLUDE_FILE_CXX(optional DJINTEROP_STD_OPTIONAL)
+CHECK_INCLUDE_FILE_CXX(experimental/optional DJINTEROP_STD_EXPERIMENTAL_OPTIONAL)
+configure_file(
+ include/djinterop/config.hpp.in
+ include/djinterop/config.hpp)
+
add_library(
djinterop
src/djinterop/enginelibrary/el_crate_impl.cpp
@@ -50,6 +58,7 @@ target_include_directories(
${SQLite3_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
ext/sqlite_modern_cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/include
include src)
target_link_libraries(
@@ -60,7 +69,7 @@ target_link_libraries(
install(TARGETS djinterop DESTINATION lib)
install(FILES
include/djinterop/album_art.hpp
- include/djinterop/config.hpp
+ ${CMAKE_CURRENT_BINARY_DIR}/include/djinterop/config.hpp
include/djinterop/crate.hpp
include/djinterop/database.hpp
include/djinterop/djinterop.hpp
diff --git a/example/engine_prime.cpp b/example/engine_prime.cpp
index d7b8520..ac81bef 100644
--- a/example/engine_prime.cpp
+++ b/example/engine_prime.cpp
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
tr.set_year(1970);
tr.set_title("Some Song"s);
tr.set_artist("Some Artist"s);
- tr.set_publisher(std::nullopt); // std::nullopt indicates missing metadata
+ tr.set_publisher(djinterop::stdx::nullopt); // indicates missing metadata
tr.set_key(djinterop::musical_key::a_minor);
tr.set_bitrate(320);
tr.set_average_loudness(0.5); // loudness range (0, 1]
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
tr.set_adjusted_main_cue(2732); // manually adjusted
// There are always 8 hot cues, whereby each can optionally be set
- std::array<std::optional<djinterop::hot_cue>, 8> cues;
+ std::array<djinterop::stdx::optional<djinterop::hot_cue>, 8> cues;
cues[0] = djinterop::hot_cue{
"Cue 1", 1377924.5, // position in number of samples
el::standard_pad_colors::pad_1};
diff --git a/include/djinterop/config.hpp b/include/djinterop/config.hpp.in
index 97260cc..b558501 100644
--- a/include/djinterop/config.hpp
+++ b/include/djinterop/config.hpp.in
@@ -46,4 +46,10 @@
#endif // DJINTEROP_SOURCE
#define DJINTEROP_LOCAL DJINTEROP_SYMBOL_LOCAL
+// Symbols defined after this point represent the environment at the time
+// that this library was built. The environment when this library is used must
+// be compatible in order to use the library successfully.
+#cmakedefine DJINTEROP_STD_OPTIONAL
+#cmakedefine DJINTEROP_STD_EXPERIMENTAL_OPTIONAL
+
#endif // DJINTEROP_CONFIG_HPP
diff --git a/include/djinterop/crate.hpp b/include/djinterop/crate.hpp
index 8a961ce..b0d7d85 100644
--- a/include/djinterop/crate.hpp
+++ b/include/djinterop/crate.hpp
@@ -23,11 +23,11 @@ Lesser General Public License for more details.
#include <cstdint>
#include <memory>
-#include <optional>
#include <string>
#include <vector>
#include <djinterop/config.hpp>
+#include <djinterop/optional.hpp>
namespace djinterop
{
@@ -111,7 +111,7 @@ public:
///
/// If the crate doesn't have a parent, then `djinterop::nullopt` is
/// returned.
- std::optional<crate> parent() const;
+ stdx::optional<crate> parent() const;
/// Removes a track from the crate
///
@@ -126,12 +126,12 @@ public:
///
/// If `djinterop::nullopt` is given, then this crate will have no parent.
/// That is, it becomes a root crate.
- void set_parent(std::optional<crate> parent) const;
+ void set_parent(stdx::optional<crate> parent) const;
/// Gets the sub-crate of this one with a given name.
///
/// If no such crate is found, then `djinterop::nullopt` is returned.
- std::optional<crate> sub_crate_by_name(const std::string& name) const;
+ stdx::optional<crate> sub_crate_by_name(const std::string& name) const;
/// Returns the crate's contained tracks
std::vector<track> tracks() const;
diff --git a/include/djinterop/database.hpp b/include/djinterop/database.hpp
index 9f68d61..b947733 100644
--- a/include/djinterop/database.hpp
+++ b/include/djinterop/database.hpp
@@ -25,17 +25,12 @@
#include <cstdint>
#include <memory>
-#include <optional>
#include <stdexcept>
#include <string>
#include <vector>
#include <djinterop/config.hpp>
-
-namespace sqlite
-{
-class database;
-}
+#include <djinterop/optional.hpp>
namespace djinterop
{
@@ -70,9 +65,9 @@ public:
/// Returns the crate with the given ID
///
- /// If no such crate exists in the database, then `djinterop::std::nullopt`
+ /// If no such crate exists in the database, then `djinterop::stdx::nullopt`
/// is returned.
- std::optional<crate> crate_by_id(int64_t id) const;
+ stdx::optional<crate> crate_by_id(int64_t id) const;
/// Returns all crates contained in the database
std::vector<crate> crates() const;
@@ -125,8 +120,8 @@ public:
/// Returns the root-level crate with the given name.
///
- /// If no such crate exists, then `djinterop::std::nullopt` is returned.
- std::optional<crate> root_crate_by_name(const std::string& name) const;
+ /// If no such crate exists, then `djinterop::stdx::nullopt` is returned.
+ stdx::optional<crate> root_crate_by_name(const std::string& name) const;
/// Returns all root crates contained in the database
///
@@ -135,9 +130,9 @@ public:
/// Returns the track with the given id
///
- /// If no such track exists in the database, then `djinterop::std::nullopt`
+ /// If no such track exists in the database, then `djinterop::stdx::nullopt`
/// is returned.
- std::optional<track> track_by_id(int64_t id) const;
+ stdx::optional<track> track_by_id(int64_t id) const;
/// Returns all tracks whose `relative_path` attribute in the database
/// matches the given string
diff --git a/include/djinterop/meson.build b/include/djinterop/meson.build
new file mode 100644
index 0000000..c43a0b2
--- /dev/null
+++ b/include/djinterop/meson.build
@@ -0,0 +1,20 @@
+# Generate config file based on build-time feature detection.
+# Note that most build configuration for public headers is handled in the
+# parent build file; this file exists solely because the `output` parameter
+# of configure_file() does not, at the time of writing (meson 0.55.0), support
+# writing the output file to a different directory.
+conf_data = configuration_data()
+if cpp_compiler.has_header('optional')
+ conf_data.set10('DJINTEROP_STD_OPTIONAL', true)
+endif
+if cpp_compiler.has_header('experimental/optional')
+ conf_data.set10('DJINTEROP_STD_EXPERIMENTAL_OPTIONAL', true)
+endif
+configure_file(
+ input: 'config.hpp.in',
+ output: 'config.hpp',
+ configuration: conf_data,
+ format: 'cmake',
+ install_dir: get_option('includedir') + '/djinterop'
+)
+
diff --git a/include/djinterop/optional.hpp b/include/djinterop/optional.hpp
new file mode 100644
index 0000000..6795913
--- /dev/null
+++ b/include/djinterop/optional.hpp
@@ -0,0 +1,63 @@
+/*
+ This file is part of libdjinterop.
+
+ libdjinterop is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ libdjinterop 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with libdjinterop. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#ifndef DJINTEROP_OPTIONAL_HPP
+#define DJINTEROP_OPTIONAL_HPP
+
+#include <djinterop/config.hpp>
+
+#ifdef DJINTEROP_STD_OPTIONAL
+
+#include <optional>
+
+namespace djinterop
+{
+namespace stdx
+{
+using std::bad_optional_access;
+using std::in_place;
+using std::in_place_t;
+using std::make_optional;
+using std::nullopt;
+using std::nullopt_t;
+using std::optional;
+} // namespace stdx
+} // namespace djinterop
+
+#elif DJINTEROP_STD_EXPERIMENTAL_OPTIONAL
+#include <experimental/optional>
+
+namespace djinterop
+{
+namespace stdx
+{
+using std::experimental::bad_optional_access;
+using std::experimental::in_place;
+using std::experimental::in_place_t;
+using std::experimental::make_optional;
+using std::experimental::nullopt;
+using std::experimental::nullopt_t;
+using std::experimental::optional;
+} // namespace stdx
+} // namespace djinterop
+
+#else
+#error This library requires support for optional<T>, but none was found
+#endif
+
+#endif // DJINTEROP_OPTIONAL_HPP
diff --git a/include/djinterop/track.hpp b/include/djinterop/track.hpp
index e058fd0..ff649cc 100644
--- a/include/djinterop/track.hpp
+++ b/include/djinterop/track.hpp
@@ -27,13 +27,13 @@
#include <chrono>
#include <cstdint>
#include <memory>
-#include <optional>
#include <stdexcept>
#include <string>
#include <vector>
#include <djinterop/config.hpp>
#include <djinterop/musical_key.hpp>
+#include <djinterop/optional.hpp>
#include <djinterop/performance_data.hpp>
#include <djinterop/semantic_version.hpp>
@@ -90,10 +90,10 @@ public:
void set_adjusted_main_cue(double sample_offset) const;
/// Returns the album name (metadata) of the track
- std::optional<std::string> album() const;
+ stdx::optional<std::string> album() const;
/// Sets the album name (metadata) of the track
- void set_album(std::optional<std::string> album) const;
+ void set_album(stdx::optional<std::string> album) const;
void set_album(std::string album) const;
/// Returns the ID of the `album_art` associated to the track
@@ -101,51 +101,51 @@ public:
/// If the track doesn't have an associated `album_art`, then `nullopt`
/// is returned.
/// TODO (haslersn): Return an `album_art` object instead.
- std::optional<int64_t> album_art_id() const;
+ stdx::optional<int64_t> album_art_id() const;
/// Sets the ID of the `album_art` associated to the track
/// TODO (haslersn): Pass an `album_art` object instead.
- void set_album_art_id(std::optional<int64_t> album_art_id) const;
+ void set_album_art_id(stdx::optional<int64_t> album_art_id) const;
void set_album_art_id(int64_t album_art_id) const;
/// Returns the artist (metadata) of the track
- std::optional<std::string> artist() const;
+ stdx::optional<std::string> artist() const;
/// Sets the artist (metadata) of the track
- void set_artist(std::optional<std::string> artist) const;
+ void set_artist(stdx::optional<std::string> artist) const;
void set_artist(std::string artist) const;
- std::optional<double> average_loudness() const;
+ stdx::optional<double> average_loudness() const;
- void set_average_loudness(std::optional<double> average_loudness) const;
+ void set_average_loudness(stdx::optional<double> average_loudness) const;
void set_average_loudness(double average_loudness) const;
/// Returns the bitrate (metadata) of the track
- std::optional<int64_t> bitrate() const;
+ stdx::optional<int64_t> bitrate() const;
/// Sets the bitrate (metadata) of the track
- void set_bitrate(std::optional<int64_t> bitrate) const;
+ void set_bitrate(stdx::optional<int64_t> bitrate) const;
void set_bitrate(int64_t bitrate) const;
/// Returns the BPM (metadata) of the track, rounded to the nearest integer
- std::optional<double> bpm() const;
+ stdx::optional<double> bpm() const;
/// Sets the BPM (metadata) of the track, rounded to the nearest integer
- void set_bpm(std::optional<double> bpm) const;
+ void set_bpm(stdx::optional<double> bpm) const;
void set_bpm(double bpm) const;
/// Returns the comment associated to the track (metadata)
- std::optional<std::string> comment() const;
+ stdx::optional<std::string> comment() const;
/// Sets the comment associated to the track (metadata)
- void set_comment(std::optional<std::string> comment) const;
+ void set_comment(stdx::optional<std::string> comment) const;
void set_comment(std::string comment) const;
/// Returns the composer (metadata) of the track
- std::optional<std::string> composer() const;
+ stdx::optional<std::string> composer() const;
/// Sets the composer (metadata) of the track
- void set_composer(std::optional<std::string> composer) const;
+ void set_composer(stdx::optional<std::string> composer) const;
void set_composer(std::string composer) const;
/// Returns the crates containing the track
@@ -163,7 +163,7 @@ public:
void set_default_main_cue(double sample_offset) const;
/// Returns the duration (metadata) of the track
- std::optional<std::chrono::milliseconds> duration() const;
+ stdx::optional<std::chrono::milliseconds> duration() const;
/// Returns the file extension part of `track::relative_path()`
///
@@ -175,20 +175,20 @@ public:
std::string filename() const;
/// Returns the genre (metadata) of the track
- std::optional<std::string> genre() const;
+ stdx::optional<std::string> genre() const;
/// Sets the genre (metadata) of the track
- void set_genre(std::optional<std::string> genre) const;
+ void set_genre(stdx::optional<std::string> genre) const;
void set_genre(std::string genre) const;
- std::optional<hot_cue> hot_cue_at(int32_t index) const;
+ stdx::optional<hot_cue> hot_cue_at(int32_t index) const;
- void set_hot_cue_at(int32_t index, std::optional<hot_cue> cue) const;
+ void set_hot_cue_at(int32_t index, stdx::optional<hot_cue> cue) const;
void set_hot_cue_at(int32_t index, hot_cue cue) const;
- std::array<std::optional<hot_cue>, 8> hot_cues() const;
+ std::array<stdx::optional<hot_cue>, 8> hot_cues() const;
- void set_hot_cues(std::array<std::optional<hot_cue>, 8> cues) const;
+ void set_hot_cues(std::array<stdx::optional<hot_cue>, 8> cues) const;
/// Returns the ID of this track
///
@@ -197,33 +197,33 @@ public:
int64_t id() const;
/// TODO (haslersn): Document this method.
- std::optional<track_import_info> import_info() const;
+ stdx::optional<track_import_info> import_info() const;
/// TODO (haslersn): Document these methods.
void set_import_info(
- const std::optional<track_import_info>& import_info) const;
+ const stdx::optional<track_import_info>& import_info) const;
void set_import_info(const track_import_info& import_info) const;
/// Returns `true` iff `*this` is valid as described in the class comment
bool is_valid() const;
/// Returns the key (metadata) of the track
- std::optional<musical_key> key() const;
+ stdx::optional<musical_key> key() const;
/// Sets the key (metadata) of the track
- void set_key(std::optional<musical_key> key) const;
+ void set_key(stdx::optional<musical_key> key) const;
void set_key(musical_key key) const;
/// Get the time at which this track was last accessed
///
/// Note that on VFAT filesystems, the access time is ceiled to just a date,
/// and loses any time precision.
- std::optional<std::chrono::system_clock::time_point> last_accessed_at()
+ stdx::optional<std::chrono::system_clock::time_point> last_accessed_at()
const;
/// TODO (haslersn): Document these methods.
void set_last_accessed_at(
- std::optional<std::chrono::system_clock::time_point> last_accessed_at)
+ stdx::optional<std::chrono::system_clock::time_point> last_accessed_at)
const;
void set_last_accessed_at(
std::chrono::system_clock::time_point last_accessed_at) const;
@@ -232,40 +232,41 @@ public:
///
/// Note that this is the attribute modification time, not the data
/// modification time, i.e. ctime not mtime.
- std::optional<std::chrono::system_clock::time_point> last_modified_at()
+ stdx::optional<std::chrono::system_clock::time_point> last_modified_at()
const;
/// TODO (haslersn): Document these methods.
void set_last_modified_at(
- std::optional<std::chrono::system_clock::time_point> last_modified_at)
+ stdx::optional<std::chrono::system_clock::time_point> last_modified_at)
const;
void set_last_modified_at(
std::chrono::system_clock::time_point last_modified_at) const;
/// Returns the time at which the track was last played
- std::optional<std::chrono::system_clock::time_point> last_played_at() const;
+ stdx::optional<std::chrono::system_clock::time_point> last_played_at()
+ const;
/// Sets the time at which the track was last played
void set_last_played_at(
- std::optional<std::chrono::system_clock::time_point> time) const;
+ stdx::optional<std::chrono::system_clock::time_point> time) const;
void set_last_played_at(std::chrono::system_clock::time_point time) const;
- std::optional<loop> loop_at(int32_t index) const;
+ stdx::optional<loop> loop_at(int32_t index) const;
- void set_loop_at(int32_t index, std::optional<loop> l) const;
+ void set_loop_at(int32_t index, stdx::optional<loop> l) const;
void set_loop_at(int32_t index, loop l) const;
- std::array<std::optional<loop>, 8> loops() const;
+ std::array<stdx::optional<loop>, 8> loops() const;
- void set_loops(std::array<std::optional<loop>, 8> loops) const;
+ void set_loops(std::array<stdx::optional<loop>, 8> loops) const;
std::vector<waveform_entry> overview_waveform() const;
/// Returns the publisher (metadata) of the track
- std::optional<std::string> publisher() const;
+ stdx::optional<std::string> publisher() const;
/// Sets the publisher (metadata) of the track
- void set_publisher(std::optional<std::string> publisher) const;
+ void set_publisher(stdx::optional<std::string> publisher) const;
void set_publisher(std::string publisher) const;
/// Get the required number of samples per waveform entry.
@@ -284,23 +285,23 @@ public:
/// TODO (haslersn): Document this method.
void set_relative_path(std::string relative_path) const;
- std::optional<sampling_info> sampling() const;
+ stdx::optional<sampling_info> sampling() const;
- void set_sampling(std::optional<sampling_info> sample_rate) const;
+ void set_sampling(stdx::optional<sampling_info> sample_rate) const;
void set_sampling(sampling_info sample_rate) const;
/// Returns the title (metadata) of the track
- std::optional<std::string> title() const;
+ stdx::optional<std::string> title() const;
/// Sets the title (metadata) of the track
- void set_title(std::optional<std::string> title) const;
+ void set_title(stdx::optional<std::string> title) const;
void set_title(std::string title) const;
/// Returns the track number (metadata) of the track
- std::optional<int32_t> track_number() const;
+ stdx::optional<int32_t> track_number() const;
/// Sets the track number (metadata) of the track
- void set_track_number(std::optional<int32_t> track_number) const;
+ void set_track_number(stdx::optional<int32_t> track_number) const;
void set_track_number(int32_t track_number) const;
std::vector<waveform_entry> waveform() const;
@@ -308,10 +309,10 @@ public:
void set_waveform(std::vector<waveform_entry> waveform) const;
/// Returns the recording year (metadata) of the track
- std::optional<int32_t> year() const;
+ stdx::optional<int32_t> year() const;
/// Sets the recording year (metadata) of the track
- void set_year(std::optional<int32_t> year) const;
+ void set_year(stdx::optional<int32_t> year) const;
void set_year(int32_t year) const;
// TODO (haslersn): non public?
diff --git a/include/meson.build b/include/meson.build
index ee89840..3d6595c 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -1,12 +1,15 @@
+# Used only to generate config.hpp in the nested include dir.
+subdir('djinterop')
+
djinterop_header_files = [
'djinterop/album_art.hpp',
- 'djinterop/config.hpp',
'djinterop/crate.hpp',
'djinterop/database.hpp',
'djinterop/djinterop.hpp',
'djinterop/exceptions.hpp',
'djinterop/enginelibrary.hpp',
'djinterop/musical_key.hpp',
+ 'djinterop/optional.hpp',
'djinterop/pad_color.hpp',
'djinterop/performance_data.hpp',
'djinterop/semantic_version.hpp',
diff --git a/meson.build b/meson.build
index e34ffcb..575e12f 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
project(
'djinterop',
'cpp', 'c',
- version: '0.11.0',
+ version: '0.12.0',
license: 'LGPL-3.0',
default_options: ['cpp_std=c++17', 'default_library=both'])
diff --git a/src/djinterop/crate.cpp b/src/djinterop/crate.cpp
index 5da4ad3..4f3fdaf 100644
--- a/src/djinterop/crate.cpp
+++ b/src/djinterop/crate.cpp
@@ -80,7 +80,7 @@ std::string crate::name() const
return pimpl_->name();
}
-std::optional<crate> crate::parent() const
+stdx::optional<crate> crate::parent() const
{
return pimpl_->parent();
}
@@ -95,13 +95,12 @@ void crate::set_name(std::string name) const
pimpl_->set_name(name);
}
-void crate::set_parent(std::optional<crate> parent) const
+void crate::set_parent(stdx::optional<crate> parent) const
{
pimpl_->set_parent(parent);
}
-std::optional<crate> crate::sub_crate_by_name(
- const std::string& name) const
+stdx::optional<crate> crate::sub_crate_by_name(const std::string& name) const
{
return pimpl_->sub_crate_by_name(name);
}
diff --git a/src/djinterop/database.cpp b/src/djinterop/database.cpp
index 1a224f8..fcff0d3 100644
--- a/src/djinterop/database.cpp
+++ b/src/djinterop/database.cpp
@@ -37,7 +37,7 @@ transaction_guard database::begin_transaction() const
return pimpl_->begin_transaction();
}
-std::optional<crate> database::crate_by_id(int64_t id) const
+stdx::optional<crate> database::crate_by_id(int64_t id) const
{
return pimpl_->crate_by_id(id);
}
@@ -92,13 +92,13 @@ std::vector<crate> database::root_crates() const
return pimpl_->root_crates();
}
-std::optional<crate> database::root_crate_by_name(
+stdx::optional<crate> database::root_crate_by_name(
const std::string& name) const
{
return pimpl_->root_crate_by_name(name);
}
-std::optional<track> database::track_by_id(int64_t id) const
+stdx::optional<track> database::track_by_id(int64_t id) const
{
return pimpl_->track_by_id(id);
}
diff --git a/src/djinterop/enginelibrary/el_crate_impl.cpp b/src/djinterop/enginelibrary/el_crate_impl.cpp
index f3a2360..0567b02 100644
--- a/src/djinterop/enginelibrary/el_crate_impl.cpp
+++ b/src/djinterop/enginelibrary/el_crate_impl.cpp
@@ -54,7 +54,6 @@ using djinterop::track;
// relationship is not written to this table.
namespace
{
-
void update_path(
sqlite::database& music_db, crate cr, const std::string& parent_path)
{
@@ -85,8 +84,8 @@ void ensure_valid_name(const std::string& name)
} // namespace
-el_crate_impl::el_crate_impl(std::shared_ptr<el_storage> storage, int64_t id)
- : crate_impl{id}, storage_{std::move(storage)}
+el_crate_impl::el_crate_impl(std::shared_ptr<el_storage> storage, int64_t id) :
+ crate_impl{id}, storage_{std::move(storage)}
{
}
@@ -133,9 +132,7 @@ crate el_crate_impl::create_sub_crate(std::string name)
el_transaction_guard_impl trans{storage_};
std::string path;
- storage_->db
- << "SELECT path FROM Crate WHERE id = ?"
- << id() >>
+ storage_->db << "SELECT path FROM Crate WHERE id = ?" << id() >>
[&](std::string path_val) {
if (path.empty())
{
@@ -157,13 +154,12 @@ crate el_crate_impl::create_sub_crate(std::string name)
"crateParentId) VALUES (?, ?)"
<< sub_id << id();
- storage_->db
- << "INSERT INTO CrateHierarchy (crateId, crateIdChild) "
- "SELECT crateId, ? FROM CrateHierarchy "
- "WHERE crateIdChild = ? "
- "UNION "
- "SELECT ? AS crateId, ? AS crateIdChild"
- << sub_id << id() << id() << sub_id;
+ storage_->db << "INSERT INTO CrateHierarchy (crateId, crateIdChild) "
+ "SELECT crateId, ? FROM CrateHierarchy "
+ "WHERE crateIdChild = ? "
+ "UNION "
+ "SELECT ? AS crateId, ? AS crateIdChild"
+ << sub_id << id() << id() << sub_id;
crate cr{std::make_shared<el_crate_impl>(storage_, sub_id)};
@@ -211,7 +207,7 @@ bool el_crate_impl::is_valid()
std::string el_crate_impl::name()
{
- std::optional<std::string> name;
+ stdx::optional<std::string> name;
storage_->db << "SELECT title FROM Crate WHERE id = ?" << id() >>
[&](std::string title) {
if (!name)
@@ -231,9 +227,9 @@ std::string el_crate_impl::name()
return *name;
}
-std::optional<crate> el_crate_impl::parent()
+stdx::optional<crate> el_crate_impl::parent()
{
- std::optional<crate> parent;
+ stdx::optional<crate> parent;
storage_->db
<< "SELECT crateParentId FROM CrateParentList WHERE crateOriginId "
"= ? AND crateParentId <> crateOriginId"
@@ -298,7 +294,7 @@ void el_crate_impl::set_name(std::string name)
trans.commit();
}
-void el_crate_impl::set_parent(std::optional<crate> parent)
+void el_crate_impl::set_parent(stdx::optional<crate> parent)
{
el_transaction_guard_impl trans{storage_};
@@ -323,9 +319,9 @@ void el_crate_impl::set_parent(std::optional<crate> parent)
trans.commit();
}
-std::optional<crate> el_crate_impl::sub_crate_by_name(const std::string& name)
+stdx::optional<crate> el_crate_impl::sub_crate_by_name(const std::string& name)
{
- std::optional<crate> cr;
+ stdx::optional<crate> cr;
storage_->db << "SELECT cr.id FROM Crate cr "
"JOIN CrateParentList cpl ON (cpl.crateOriginId = cr.id) "
"WHERE cr.title = ? "
diff --git a/src/djinterop/enginelibrary/el_crate_impl.hpp b/src/djinterop/enginelibrary/el_crate_impl.hpp
index 55a24df..7b67835 100644
--- a/src/djinterop/enginelibrary/el_crate_impl.hpp
+++ b/src/djinterop/enginelibrary/el_crate_impl.hpp
@@ -41,11 +41,11 @@ public:
std::vector<crate> descendants() override;
bool is_valid() override;
std::string name() override;
- std::optional<crate> parent() override;
+ stdx::optional<crate> parent() override;
void remove_track(track tr) override;
void set_name(std::string name) override;
- void set_parent(std::optional<crate> parent) override;
- std::optional<crate> sub_crate_by_name(const std::string& name) override;
+ void set_parent(stdx::optional<crate> parent) override;
+ stdx::optional<crate> sub_crate_by_name(const st