From 3ed2435ec2d590a9bb3e34b7cfa91706cbdc4c87 Mon Sep 17 00:00:00 2001 From: Adam Szmigin Date: Wed, 17 Apr 2024 00:35:04 +0100 Subject: [PATCH] Use std::optional and upgrade to C++20 --- .clang-format | 2 +- .github/workflows/cmake.yml | 19 +- .gitignore | 6 - CMakeLists.txt | 18 +- cmake/cplusplus_macro_print.cpp | 7 + example/engine_prime.cpp | 2 +- include/djinterop/album_art.hpp | 6 +- include/djinterop/config.hpp.in | 10 +- include/djinterop/crate.hpp | 32 +- include/djinterop/database.hpp | 18 +- include/djinterop/djinterop.hpp | 4 +- include/djinterop/engine/engine.hpp | 4 +- include/djinterop/engine/engine_version.hpp | 4 +- .../djinterop/engine/v2/beat_data_blob.hpp | 9 +- .../djinterop/engine/v2/change_log_table.hpp | 8 +- .../djinterop/engine/v2/engine_library.hpp | 4 +- .../djinterop/engine/v2/information_table.hpp | 4 +- include/djinterop/engine/v2/loops_blob.hpp | 6 +- .../engine/v2/overview_waveform_data_blob.hpp | 4 +- .../engine/v2/playlist_entity_table.hpp | 8 +- .../djinterop/engine/v2/playlist_table.hpp | 19 +- .../djinterop/engine/v2/quick_cues_blob.hpp | 8 +- .../djinterop/engine/v2/track_data_blob.hpp | 4 +- include/djinterop/engine/v2/track_table.hpp | 159 ++++----- include/djinterop/exceptions.hpp | 4 +- include/djinterop/musical_key.hpp | 4 +- include/djinterop/optional.hpp | 70 ---- include/djinterop/pad_color.hpp | 4 +- include/djinterop/performance_data.hpp | 4 +- include/djinterop/semantic_version.hpp | 4 +- include/djinterop/stream_helper.hpp | 13 +- include/djinterop/track.hpp | 98 ++--- include/djinterop/track_snapshot.hpp | 54 +-- src/djinterop/crate.cpp | 6 +- src/djinterop/database.cpp | 6 +- src/djinterop/engine/engine.cpp | 4 +- .../engine/schema/schema_validate_utils.hpp | 16 +- src/djinterop/engine/v1/engine_crate_impl.cpp | 12 +- src/djinterop/engine/v1/engine_crate_impl.hpp | 6 +- .../engine/v1/engine_database_impl.cpp | 12 +- .../engine/v1/engine_database_impl.hpp | 6 +- src/djinterop/engine/v1/engine_storage.cpp | 230 ++++++------ src/djinterop/engine/v1/engine_storage.hpp | 156 ++++---- src/djinterop/engine/v1/engine_track_impl.cpp | 278 ++++++++------- src/djinterop/engine/v1/engine_track_impl.hpp | 98 +++-- .../engine/v1/performance_data_format.cpp | 28 +- .../engine/v1/performance_data_format.hpp | 30 +- src/djinterop/engine/v2/change_log_table.cpp | 4 +- src/djinterop/engine/v2/convert_beatgrid.hpp | 1 - src/djinterop/engine/v2/convert_hot_cues.hpp | 23 +- src/djinterop/engine/v2/convert_loops.hpp | 18 +- src/djinterop/engine/v2/convert_track.hpp | 72 ++-- src/djinterop/engine/v2/convert_waveform.hpp | 6 +- src/djinterop/engine/v2/crate_impl.cpp | 14 +- src/djinterop/engine/v2/crate_impl.hpp | 6 +- src/djinterop/engine/v2/database_impl.cpp | 18 +- src/djinterop/engine/v2/database_impl.hpp | 6 +- src/djinterop/engine/v2/information_table.cpp | 5 +- src/djinterop/engine/v2/loops_blob.cpp | 3 +- .../engine/v2/playlist_entity_table.cpp | 6 +- src/djinterop/engine/v2/playlist_table.cpp | 12 +- src/djinterop/engine/v2/track_impl.cpp | 108 +++--- src/djinterop/engine/v2/track_impl.hpp | 97 +++-- src/djinterop/engine/v2/track_table.cpp | 336 +++++++++--------- src/djinterop/impl/crate_impl.hpp | 8 +- src/djinterop/impl/database_impl.hpp | 9 +- src/djinterop/impl/track_impl.hpp | 94 ++--- src/djinterop/track.cpp | 132 +++---- src/djinterop/util/chrono.hpp | 15 +- src/djinterop/util/convert.hpp | 10 +- src/djinterop/util/filesystem.cpp | 6 +- src/djinterop/util/filesystem.hpp | 5 +- subprojects/zlib.wrap | 10 - test/djinterop/engine/crate_test.cpp | 14 +- test/djinterop/engine/database_test.cpp | 2 +- test/djinterop/engine/example_track_data.hpp | 88 ++--- test/djinterop/engine/track_test.cpp | 2 +- .../engine/v2/example_track_row_data.hpp | 4 +- test/djinterop/engine/v2/track_table_test.cpp | 4 +- 79 files changed, 1266 insertions(+), 1380 deletions(-) create mode 100644 cmake/cplusplus_macro_print.cpp delete mode 100644 include/djinterop/optional.hpp delete mode 100644 subprojects/zlib.wrap diff --git a/.clang-format b/.clang-format index 1ef438d..1f602e5 100644 --- a/.clang-format +++ b/.clang-format @@ -111,7 +111,7 @@ SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: c++17 +Standard: c++20 TabWidth: 4 UseTab: Never ... diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c91b533..49d036c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -8,15 +8,24 @@ on: env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release + BUILD_TYPE: Debug jobs: build: strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04] - - runs-on: ${{ matrix.os }} + config: [ + { os: ubuntu-20.04, c_compiler: gcc-10, cpp_compiler: g++-10 }, + { os: ubuntu-20.04, c_compiler: clang-12, cpp_compiler: clang-12 }, + { os: ubuntu-22.04, c_compiler: gcc-11, cpp_compiler: g++-11 }, + { os: ubuntu-22.04, c_compiler: gcc-12, cpp_compiler: g++-12 }, + { os: ubuntu-22.04, c_compiler: gcc-13, cpp_compiler: g++-13 }, + { os: ubuntu-22.04, c_compiler: clang-13, cpp_compiler: clang-13 }, + { os: ubuntu-22.04, c_compiler: clang-14, cpp_compiler: clang-14 }, + { os: ubuntu-22.04, c_compiler: clang-15, cpp_compiler: clang-15 }, + ] + + runs-on: ${{ matrix.config.os }} steps: - uses: actions/checkout@v3 @@ -24,7 +33,7 @@ jobs: - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=${{matrix.config.c_compiler}} -DCMAKE_CXX_COMPILER=${{matrix.config.cpp_compiler}} - name: Build # Build your program with the given configuration diff --git a/.gitignore b/.gitignore index aa3d5c4..1e8863e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ -# The typical build output directory -/build/ - -# Sub-projects -/subprojects/ - # Compilation database compile_commands.json .clangd/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 72a1aac..bd809cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) project(libdjinterop - VERSION 0.21.0 + VERSION 0.22.0 DESCRIPTION "C++ library providing access to DJ record libraries") set(PROJECT_HOMEPAGE_URL "https://github.com/xsco/libdjinterop") @@ -15,8 +15,8 @@ if(POLICY CMP0076) cmake_policy(SET CMP0076 NEW) endif() -# Require C++17 -set(CMAKE_CXX_STANDARD 17) +# Require C++20 +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) if(MSVC) add_compile_options("/W4" "/wd4251" "/wd4275" "$<$:/O2>") @@ -27,6 +27,13 @@ else() add_compile_options("$<$:-Wall>") endif() +# Public headers rely on the __cplusplus macro being populated correctly. +# It can be useful to know exactly what it evaluates to. +try_run(CPP_MACRO_PRINT_COMPILE_RESULT CPP_MACRO_PRINT_RUN_RESULT + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_LIST_DIR}/cmake/cplusplus_macro_print.cpp" + RUN_OUTPUT_VARIABLE CPP_MACRO_PRINT_OUTPUT) +message(STATUS "${CPP_MACRO_PRINT_OUTPUT}") # Build shared a library by default. option(BUILD_SHARED_LIBS "Build shared library" ON) @@ -101,10 +108,6 @@ if(DJINTEROP_LIBRARY_TYPE STREQUAL "STATIC_LIBRARY") endif() # 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) @@ -170,7 +173,6 @@ install(FILES include/djinterop/djinterop.hpp include/djinterop/exceptions.hpp include/djinterop/musical_key.hpp - include/djinterop/optional.hpp include/djinterop/pad_color.hpp include/djinterop/performance_data.hpp include/djinterop/semantic_version.hpp diff --git a/cmake/cplusplus_macro_print.cpp b/cmake/cplusplus_macro_print.cpp new file mode 100644 index 0000000..07aed9e --- /dev/null +++ b/cmake/cplusplus_macro_print.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::cout << "Value of __cplusplus macro: " << __cplusplus; + return 0; +} diff --git a/example/engine_prime.cpp b/example/engine_prime.cpp index e2d02ab..4b280a6 100644 --- a/example/engine_prime.cpp +++ b/example/engine_prime.cpp @@ -54,7 +54,7 @@ int main() td.year = 1970; td.title = "Some Song"s; td.artist = "Some Artist"s; - td.publisher = djinterop::stdx::nullopt; // indicates missing metadata + td.publisher = std::nullopt; // indicates missing metadata td.key = djinterop::musical_key::a_minor; td.bitrate = 320; td.rating = 60; // note: rating is in the range 0-100 diff --git a/include/djinterop/album_art.hpp b/include/djinterop/album_art.hpp index 8da9fae..2099da4 100644 --- a/include/djinterop/album_art.hpp +++ b/include/djinterop/album_art.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_ALBUM_ART_HPP #define DJINTEROP_ALBUM_ART_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include @@ -33,7 +33,7 @@ namespace djinterop class album_art { public: - typedef uint_least8_t image_data_type; + using image_data_type = uint_least8_t; std::string hash_hex_str; std::vector image_data; diff --git a/include/djinterop/config.hpp.in b/include/djinterop/config.hpp.in index 489f46f..b574975 100644 --- a/include/djinterop/config.hpp.in +++ b/include/djinterop/config.hpp.in @@ -19,8 +19,8 @@ #ifndef DJINTEROP_CONFIG_HPP #define DJINTEROP_CONFIG_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif // Statement about whether the library was built/installed as static or shared. @@ -55,12 +55,6 @@ #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 - #include static_assert(sizeof(std::byte) == 1, "Only platforms where sizeof(std::byte) == 1 are supported"); diff --git a/include/djinterop/crate.hpp b/include/djinterop/crate.hpp index 8dc51a2..a07e255 100644 --- a/include/djinterop/crate.hpp +++ b/include/djinterop/crate.hpp @@ -1,13 +1,15 @@ /* - Tdd!his file is part of libdjinterop. -dd! - ldd!ibdjinterop is free software: you can redistribute it and/or modify - idd!t under the terms of the GNU Lesser General Public License as published -by tdd!he Free Software Foundation, either version 3 of the License, or (dd!at -your option) any later version. dd! ldd!ibdjinterop 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. + 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 . @@ -17,17 +19,17 @@ Lesser General Public License for more details. #ifndef DJINTEROP_CRATE_HPP #define DJINTEROP_CRATE_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include +#include #include #include #include -#include namespace djinterop { @@ -118,7 +120,7 @@ class DJINTEROP_PUBLIC crate /// /// If the crate doesn't have a parent, then `djinterop::nullopt` is /// returned. - stdx::optional parent() const; + std::optional parent() const; /// Removes a track from the crate /// @@ -133,7 +135,7 @@ class DJINTEROP_PUBLIC crate /// /// If `djinterop::nullopt` is given, then this crate will have no parent. /// That is, it becomes a root crate. - void set_parent(stdx::optional parent) const; + void set_parent(std::optional parent) const; /// Gets the sub-crate of this one with a given name. /// @@ -141,7 +143,7 @@ class DJINTEROP_PUBLIC crate /// the search does not recurse into the immediate sub-crates of this crate. /// /// If no such crate is found, then `djinterop::nullopt` is returned. - stdx::optional sub_crate_by_name(const std::string& name) const; + std::optional sub_crate_by_name(const std::string& name) const; /// Returns the crate's contained tracks. /// diff --git a/include/djinterop/database.hpp b/include/djinterop/database.hpp index 79773c7..d767cc6 100644 --- a/include/djinterop/database.hpp +++ b/include/djinterop/database.hpp @@ -19,18 +19,18 @@ #ifndef DJINTEROP_DATABASE_HPP #define DJINTEROP_DATABASE_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include +#include #include #include #include #include -#include namespace djinterop { @@ -55,9 +55,9 @@ class DJINTEROP_PUBLIC database /// Returns the crate with the given ID /// - /// If no such crate exists in the database, then `djinterop::stdx::nullopt` + /// If no such crate exists in the database, then `std::nullopt` /// is returned. - stdx::optional crate_by_id(int64_t id) const; + std::optional crate_by_id(int64_t id) const; /// Returns all crates contained in the database std::vector crates() const; @@ -104,8 +104,8 @@ class DJINTEROP_PUBLIC database /// Returns the root-level crate with the given name. /// - /// If no such crate exists, then `djinterop::stdx::nullopt` is returned. - stdx::optional root_crate_by_name(const std::string& name) const; + /// If no such crate exists, then `std::nullopt` is returned. + std::optional root_crate_by_name(const std::string& name) const; /// Returns all root crates contained in the database /// @@ -114,9 +114,9 @@ class DJINTEROP_PUBLIC database /// Returns the track with the given id /// - /// If no such track exists in the database, then `djinterop::stdx::nullopt` + /// If no such track exists in the database, then `std::nullopt` /// is returned. - stdx::optional track_by_id(int64_t id) const; + std::optional 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/djinterop.hpp b/include/djinterop/djinterop.hpp index 91b9223..a34379e 100644 --- a/include/djinterop/djinterop.hpp +++ b/include/djinterop/djinterop.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_DJINTEROP_HPP #define DJINTEROP_DJINTEROP_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/engine.hpp b/include/djinterop/engine/engine.hpp index 4807cc3..4aa8589 100644 --- a/include/djinterop/engine/engine.hpp +++ b/include/djinterop/engine/engine.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_ENGINE_ENGINE_HPP #define DJINTEROP_ENGINE_ENGINE_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/engine_version.hpp b/include/djinterop/engine/engine_version.hpp index e543428..db861c0 100644 --- a/include/djinterop/engine/engine_version.hpp +++ b/include/djinterop/engine/engine_version.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_ENGINE_ENGINE_VERSION_HPP #define DJINTEROP_ENGINE_ENGINE_VERSION_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/v2/beat_data_blob.hpp b/include/djinterop/engine/v2/beat_data_blob.hpp index 77f3bf9..e09ed3d 100644 --- a/include/djinterop/engine/v2/beat_data_blob.hpp +++ b/include/djinterop/engine/v2/beat_data_blob.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include @@ -28,9 +28,6 @@ #include #include -#include -#include -#include namespace djinterop::engine::v2 { @@ -90,7 +87,7 @@ struct DJINTEROP_PUBLIC beat_grid_marker_blob struct DJINTEROP_PUBLIC beat_data_blob { /// Type of collection of beat grid markers. - typedef std::vector beat_grid_marker_blobs_type; + using beat_grid_marker_blobs_type = std::vector; /// Sample rate, in hertz. double sample_rate; diff --git a/include/djinterop/engine/v2/change_log_table.hpp b/include/djinterop/engine/v2/change_log_table.hpp index 845e5be..7045656 100644 --- a/include/djinterop/engine/v2/change_log_table.hpp +++ b/include/djinterop/engine/v2/change_log_table.hpp @@ -17,16 +17,16 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include +#include #include #include -#include namespace djinterop::engine::v2 { @@ -86,7 +86,7 @@ class DJINTEROP_PUBLIC change_log_table /// Get the most recent entry in the changelog. /// /// \return Returns the last entry. - [[nodiscard]] djinterop::stdx::optional last() const; + [[nodiscard]] std::optional last() const; private: std::shared_ptr context_; diff --git a/include/djinterop/engine/v2/engine_library.hpp b/include/djinterop/engine/v2/engine_library.hpp index 38a7d5d..0527867 100644 --- a/include/djinterop/engine/v2/engine_library.hpp +++ b/include/djinterop/engine/v2/engine_library.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/v2/information_table.hpp b/include/djinterop/engine/v2/information_table.hpp index 5dd0a70..f1f8b34 100644 --- a/include/djinterop/engine/v2/information_table.hpp +++ b/include/djinterop/engine/v2/information_table.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/v2/loops_blob.hpp b/include/djinterop/engine/v2/loops_blob.hpp index c9fb046..aa7c0cf 100644 --- a/include/djinterop/engine/v2/loops_blob.hpp +++ b/include/djinterop/engine/v2/loops_blob.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include @@ -28,9 +28,7 @@ #include #include -#include #include -#include namespace djinterop::engine::v2 { diff --git a/include/djinterop/engine/v2/overview_waveform_data_blob.hpp b/include/djinterop/engine/v2/overview_waveform_data_blob.hpp index 7c4c445..0df06c0 100644 --- a/include/djinterop/engine/v2/overview_waveform_data_blob.hpp +++ b/include/djinterop/engine/v2/overview_waveform_data_blob.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/v2/playlist_entity_table.hpp b/include/djinterop/engine/v2/playlist_entity_table.hpp index aeed06e..48c085c 100644 --- a/include/djinterop/engine/v2/playlist_entity_table.hpp +++ b/include/djinterop/engine/v2/playlist_entity_table.hpp @@ -17,19 +17,19 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include #include +#include #include #include #include #include -#include namespace djinterop::engine::v2 { @@ -122,7 +122,7 @@ class DJINTEROP_PUBLIC playlist_entity_table /// \param list_id Id of playlist. /// \param track_id Id of track in playlist. /// \return Returns the optional playlist entity row. - [[nodiscard]] stdx::optional get( + [[nodiscard]] std::optional get( int64_t list_id, int64_t track_id) const; /// Get a list of entity rows for a given playlist, in playlist order. diff --git a/include/djinterop/engine/v2/playlist_table.hpp b/include/djinterop/engine/v2/playlist_table.hpp index 482b27b..74329f2 100644 --- a/include/djinterop/engine/v2/playlist_table.hpp +++ b/include/djinterop/engine/v2/playlist_table.hpp @@ -17,21 +17,21 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include #include #include +#include #include #include #include #include #include -#include #include namespace djinterop::engine::v2 @@ -42,7 +42,6 @@ struct engine_library_context; /// operation. struct DJINTEROP_PUBLIC playlist_row_id_error : public std::runtime_error { -public: explicit playlist_row_id_error(const std::string& what_arg) noexcept : runtime_error{what_arg} { @@ -51,14 +50,14 @@ struct DJINTEROP_PUBLIC playlist_row_id_error : public std::runtime_error /// Special value for id to indicate that a given row is not currently persisted /// in the database. -constexpr const int64_t PLAYLIST_ROW_ID_NONE = 0; +constexpr int64_t PLAYLIST_ROW_ID_NONE = 0; /// Special value for parent id to indicate that a given row is at the root /// level, and does not have any parent playlist. -constexpr const int64_t PARENT_LIST_ID_NONE = 0; +constexpr int64_t PARENT_LIST_ID_NONE = 0; /// Special value for next list id to indicate that there is no next list. -constexpr const int64_t PLAYLIST_NO_NEXT_LIST_ID = 0; +constexpr int64_t PLAYLIST_NO_NEXT_LIST_ID = 0; /// Represents a row in the `PlayList` table. struct DJINTEROP_PUBLIC playlist_row @@ -179,21 +178,21 @@ class DJINTEROP_PUBLIC playlist_table /// \param parent_id Id of parent playlist. /// \param title Title of playlist to find. /// \return Returns the id of the playlist, or none if not found. - [[nodiscard]] stdx::optional find_id( + [[nodiscard]] std::optional find_id( int64_t parent_id, const std::string& title) const; /// Find the id of a root playlist, given its title. /// /// \param title Title of playlist to find. /// \return Returns the id of the playlist, or none if not found. - [[nodiscard]] stdx::optional find_root_id( + [[nodiscard]] std::optional find_root_id( const std::string& title) const; /// Get a playlist by id. /// /// \param id Id of playlist. /// \return Returns an optional playlist row. - [[nodiscard]] djinterop::stdx::optional get(int64_t id) const; + [[nodiscard]] std::optional get(int64_t id) const; /// Remove an entry from the table. /// diff --git a/include/djinterop/engine/v2/quick_cues_blob.hpp b/include/djinterop/engine/v2/quick_cues_blob.hpp index e956c34..e0953b7 100644 --- a/include/djinterop/engine/v2/quick_cues_blob.hpp +++ b/include/djinterop/engine/v2/quick_cues_blob.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include @@ -27,9 +27,7 @@ #include #include -#include #include -#include namespace djinterop::engine::v2 { @@ -91,7 +89,7 @@ struct DJINTEROP_PUBLIC quick_cue_blob struct DJINTEROP_PUBLIC quick_cues_blob { /// Type of collection of quick cues. - typedef std::vector quick_cue_blobs_type; + using quick_cue_blobs_type = std::vector; /// List of quick cues. quick_cue_blobs_type quick_cues; diff --git a/include/djinterop/engine/v2/track_data_blob.hpp b/include/djinterop/engine/v2/track_data_blob.hpp index 2fb3581..375420d 100644 --- a/include/djinterop/engine/v2/track_data_blob.hpp +++ b/include/djinterop/engine/v2/track_data_blob.hpp @@ -17,8 +17,8 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/engine/v2/track_table.hpp b/include/djinterop/engine/v2/track_table.hpp index a2fa294..817c255 100644 --- a/include/djinterop/engine/v2/track_table.hpp +++ b/include/djinterop/engine/v2/track_table.hpp @@ -17,13 +17,14 @@ #pragma once -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include #include +#include #include #include #include @@ -34,8 +35,6 @@ #include #include #include -#include -#include #include namespace djinterop::engine::v2 @@ -55,19 +54,19 @@ struct DJINTEROP_PUBLIC track_row_id_error : public std::runtime_error /// Special value for id to indicate that a given row is not currently persisted /// in the database. -constexpr const int64_t TRACK_ROW_ID_NONE = 0; +constexpr int64_t TRACK_ROW_ID_NONE = 0; /// Special value for the `album_art_id` track table column that indicates that /// no album art is present for a given track. -constexpr const int64_t ALBUM_ART_ID_NONE = 1; +constexpr int64_t ALBUM_ART_ID_NONE = 1; /// Special value for the `rating` track table column that indicates that no /// rating is present for a given track. -constexpr const int64_t RATING_NONE = 0; +constexpr int64_t RATING_NONE = 0; /// Special value for the `lastEditTime` track table column that indicates there /// is no last edit time for a given track. -constexpr const std::chrono::system_clock::time_point LAST_EDIT_TIME_NONE = +constexpr std::chrono::system_clock::time_point LAST_EDIT_TIME_NONE = std::chrono::system_clock::time_point{std::chrono::seconds{0}}; /// Represents a row in the `Track` table. @@ -80,16 +79,16 @@ struct DJINTEROP_PUBLIC track_row int64_t id; /// `playOrder` column. - stdx::optional play_order; + std::optional play_order; /// `length` column, representing the approximate length, in seconds. int64_t length; /// `bpm` column, representing the approximate BPM. - stdx::optional bpm; + std::optional bpm; /// `year` column. - stdx::optional year; + std::optional year; /// `path` column. /// @@ -102,11 +101,11 @@ struct DJINTEROP_PUBLIC track_row std::string filename; /// `bitrate` column. - stdx::optional bitrate; + std::optional bitrate; /// `bpmAnalyzed` column, representing the BPM as determined from track /// analysis. - stdx::optional bpm_analyzed; + std::optional bpm_analyzed; /// `albumArtId` column. /// @@ -115,34 +114,34 @@ struct DJINTEROP_PUBLIC track_row /// `file_bytes` column, representing the size of the file underlying the /// track on disk, in bytes. - stdx::optional file_bytes; + std::optional file_bytes; /// `title` column. - stdx::optional title; + std::optional title; /// `artist` column. - stdx::optional artist; + std::optional artist; /// `album column. - stdx::optional album; + std::optional album; /// `genre` column. - stdx::optional genre; + std::optional genre; /// `comment` column. - stdx::optional comment; + std::optional comment; /// `label` column. - stdx::optional label; + std::optional label; /// `composer` column. - stdx::optional composer; + std::optional composer; /// `remixer` column. - stdx::optional remixer; + std::optional remixer; /// `key` column, as an integer between 0 and 23. - stdx::optional key; + std::optional key; /// `rating` column. /// @@ -150,10 +149,10 @@ struct DJINTEROP_PUBLIC track_row int64_t rating; /// `albumArt` column. - stdx::optional album_art; + std::optional album_art; /// `timeLastPlayed` column. - stdx::optional time_last_played; + std::optional time_last_played; /// `isPlayed` column, indicating whether the track has ever been played. bool is_played; @@ -189,7 +188,7 @@ struct DJINTEROP_PUBLIC track_row /// /// Random number matching the equivalent field in the `Information` table, /// if this track is the most recent to be played. - stdx::optional played_indicator; + std::optional played_indicator; /// `isMetadataImported` column. bool is_metadata_imported; @@ -198,10 +197,10 @@ struct DJINTEROP_PUBLIC track_row int64_t pdb_import_key; /// `streamingSource` column. - stdx::optional streaming_source; + std::optional streaming_source; /// `uri` column. - stdx::optional uri; + std::optional uri; /// `isBeatGridLocked` column. bool is_beat_grid_locked; @@ -236,7 +235,7 @@ struct DJINTEROP_PUBLIC track_row loops_blob loops; /// `thirdPartySourceId` column. - stdx::optional third_party_source_id; + std::optional third_party_source_id; /// `streamingFlags` column. int64_t streaming_flags; @@ -245,7 +244,7 @@ struct DJINTEROP_PUBLIC track_row bool explicit_lyrics; /// `activeOnLoadLoops` column. - stdx::optional active_on_load_loops; + std::optional active_on_load_loops; /// `lastEditTime` column. /// @@ -388,19 +387,19 @@ class DJINTEROP_PUBLIC track_table /// /// \param id Id of track. /// \return Returns a track row, or none if not found. - stdx::optional get(int64_t id) const; + std::optional get(int64_t id) const; /// Find whether a track exists, given its unique path. /// /// \param path Path of track. /// \return Returns a track id if found, or none if not found. - stdx::optional find_id_by_path(const std::string& path) const; + std::optional find_id_by_path(const std::string& path) const; /// Get the `playOrder` column for a given track. - stdx::optional get_play_order(int64_t id); + std::optional get_play_order(int64_t id); /// Set the `playOrder` column for a given track. - void set_play_order(int64_t id, stdx::optional play_order); + void set_play_order(int64_t id, std::optional play_order); /// Get the `length` column for a given track, representing the approximate /// length, in seconds. @@ -412,17 +411,17 @@ class DJINTEROP_PUBLIC track_table /// Get the `bpm` column for a given track, representing the approximate /// BPM. - stdx::optional get_bpm(int64_t id); + std::optional get_bpm(int64_t id); /// Set the `bpm` column for a given track, representing the approximate /// BPM. - void set_bpm(int64_t id, stdx::optional bpm); + void set_bpm(int64_t id, std::optional bpm); /// Get the `year` column for a given track. - stdx::optional get_year(int64_t id); + std::optional get_year(int64_t id); /// Set the `year` column for a given track. - void set_year(int64_t id, const stdx::optional& year); + void set_year(int64_t id, const std::optional& year); /// Get the `path` column for a given track. /// @@ -445,18 +444,18 @@ class DJINTEROP_PUBLIC track_table void set_filename(int64_t id, const std::string& filename); /// Get the `bitrate` column for a given track. - stdx::optional get_bitrate(int64_t id); + std::optional get_bitrate(int64_t id); /// Set the `bitrate` column for a given track. - void set_bitrate(int64_t id, stdx::optional bitrate); + void set_bitrate(int64_t id, std::optional bitrate); /// Get the `bpmAnalyzed` column for a given track, representing the BPM as /// determined from track analysis. - stdx::optional get_bpm_analyzed(int64_t id); + std::optional get_bpm_analyzed(int64_t id); /// Set the `bpmAnalyzed` column for a given track, representing the BPM as /// determined from track analysis. - void set_bpm_analyzed(int64_t id, stdx::optional bpm_analyzed); + void set_bpm_analyzed(int64_t id, std::optional bpm_analyzed); /// Get the `albumArtId` column for a given track. /// @@ -470,67 +469,67 @@ class DJINTEROP_PUBLIC track_table /// Get the `file_bytes` column for a given track, representing the size of /// the file underlying the track on disk, in bytes. - stdx::optional get_file_bytes(int64_t id); + std::optional get_file_bytes(int64_t id); /// Set the `file_bytes` column for a given track, representing the size of /// the file underlying the track on disk, in bytes. - void set_file_bytes(int64_t id, stdx::optional file_bytes); + void set_file_bytes(int64_t id, std::optional file_bytes); /// Get the `title` column for a given track. - stdx::optional get_title(int64_t id); + std::optional get_title(int64_t id); /// Set the `title` column for a given track. - void set_title(int64_t id, const stdx::optional& title); + void set_title(int64_t id, const std::optional& title); /// Get the `artist` column for a given track. - stdx::optional get_artist(int64_t id); + std::optional get_artist(int64_t id); /// Set the `artist` column for a given track. - void set_artist(int64_t id, const stdx::optional& artist); + void set_artist(int64_t id, const std::optional& artist); /// Get the `album` column for a given track. - stdx::optional get_album(int64_t id); + std::optional get_album(int64_t id); /// Set the `album` column for a given track. - void set_album(int64_t id, const stdx::optional& album); + void set_album(int64_t id, const std::optional& album); /// Get the `genre` column for a given track. - stdx::optional get_genre(int64_t id); + std::optional get_genre(int64_t id); /// Set the `genre` column for a given track. - void set_genre(int64_t id, const stdx::optional& genre); + void set_genre(int64_t id, const std::optional& genre); /// Get the `comment` column for a given track. - stdx::optional get_comment(int64_t id); + std::optional get_comment(int64_t id); /// Set the `comment` column for a given track. - void set_comment(int64_t id, const stdx::optional& comment); + void set_comment(int64_t id, const std::optional& comment); /// Get the `label` column for a given track. - stdx::optional get_label(int64_t id); + std::optional get_label(int64_t id); /// Set the `label` column for a given track. - void set_label(int64_t id, const stdx::optional& label); + void set_label(int64_t id, const std::optional& label); /// Get the `composer` column for a given track. - stdx::optional get_composer(int64_t id); + std::optional get_composer(int64_t id); /// Set the `composer` column for a given track. - void set_composer(int64_t id, const stdx::optional& composer); + void set_composer(int64_t id, const std::optional& composer); /// Get the `remixer` column for a given track. - stdx::optional get_remixer(int64_t id); + std::optional get_remixer(int64_t id); /// Set the `remixer` column for a given track. - void set_remixer(int64_t id, const stdx::optional& remixer); + void set_remixer(int64_t id, const std::optional& remixer); /// Get the `key` column for a given track, as an integer between 0 and 23. - stdx::optional get_key(int64_t id); + std::optional get_key(int64_t id); /// Set the `key` column for a given track, as an integer between 0 and 23. /// /// The values align with those in the `djinterop::musical_key` enum. - void set_key(int64_t id, stdx::optional key); + void set_key(int64_t id, std::optional key); /// Get the `rating` column for a given track. /// @@ -543,19 +542,19 @@ class DJINTEROP_PUBLIC track_table void set_rating(int64_t id, int64_t rating); /// Get the `albumArt` column for a given track. - stdx::optional get_album_art(int64_t id); + std::optional get_album_art(int64_t id); /// Set the `albumArt` column for a given track. void set_album_art( - int64_t id, const stdx::optional& album_art); + int64_t id, const std::optional& album_art); /// Get the `timeLastPlayed` column for a given track. - stdx::optional get_time_last_played( + std::optional get_time_last_played( int64_t id); /// Set the `timeLastPlayed` column for a given track. void set_time_last_played( - int64_t id, const stdx::optional& + int64_t id, const std::optional& time_last_played); /// Get the `isPlayed` column for a given track, indicating whether the @@ -583,23 +582,23 @@ class DJINTEROP_PUBLIC track_table void set_is_analyzed(int64_t id, bool is_analyzed); /// Get the `dateCreated` column for a given track. - stdx::optional get_date_created( + std::optional get_date_created( int64_t id); /// Set the `dateCreated` column for a given track. void set_date_created( - int64_t id, const stdx::optional& + int64_t id, const std::optional& date_created); /// Get the `dateAdded` column for a given track, representing the time at /// which the track was added to the database. - stdx::optional get_date_added( + std::optional get_date_added( int64_t id); /// Set the `dateAdded` column for a given track, representing the time at /// which the track was added to the database. void set_date_added( - int64_t id, const stdx::optional& + int64_t id, const std::optional& date_added); /// Get the `isAvailable` column for a given track, indicating if the file @@ -630,14 +629,14 @@ class DJINTEROP_PUBLIC track_table /// /// Random number matching the equivalent field in the `Information` table, /// if this track is the most recent to be played. - stdx::optional get_played_indicator(int64_t id); + std::optional get_played_indicator(int64_t id); /// Set the `playedIndicator` column for a given track. /// /// Random number matching the equivalent field in the `Information` table, /// if this track is the most recent to be played. void set_played_indicator( - int64_t id, const stdx::optional& played_indicator); + int64_t id, const std::optional& played_indicator); /// Get the `isMetadataImported` column for a given track. bool get_is_metadata_imported(int64_t id); @@ -652,17 +651,17 @@ class DJINTEROP_PUBLIC track_table void set_pdb_import_key(int64_t id, int64_t pdb_import_key); /// Get the `streamingSource` column for a given track. - stdx::optional get_streaming_source(int64_t id); + std::optional get_streaming_source(int64_t id); /// Set the `streamingSource` column for a given track. void set_streaming_source( - int64_t id, const stdx::optional& streaming_source); + int64_t id, const std::optional& streaming_source); /// Get the `uri` column for a given track. - stdx::optional get_uri(int64_t id); + std::optional get_uri(int64_t id); /// Set the `uri` column for a given track. - void set_uri(int64_t id, const stdx::optional& uri); + void set_uri(int64_t id, const std::optional& uri); /// Get the `isBeatGridLocked` column for a given track. bool get_is_beat_grid_locked(int64_t id); @@ -731,11 +730,11 @@ class DJINTEROP_PUBLIC track_table void set_loops(int64_t id, const loops_blob& loops); /// Get the `thirdPartySourceId` column for a given track. - stdx::optional get_third_party_source_id(int64_t id); + std::optional get_third_party_source_id(int64_t id); /// Set the `thirdPartySourceId` column for a given track. void set_third_party_source_id( - int64_t id, const stdx::optional& third_party_source_id); + int64_t id, const std::optional& third_party_source_id); /// Get the `streamingFlags` column for a given track. int64_t get_streaming_flags(int64_t id); @@ -750,11 +749,11 @@ class DJINTEROP_PUBLIC track_table void set_explicit_lyrics(int64_t id, bool explicit_lyrics); /// Get the `activeOnLoadLoops` column for a given track. - stdx::optional get_active_on_load_loops(int64_t id); + std::optional get_active_on_load_loops(int64_t id); /// Set the `activeOnLoadLoops` column for a given track. void set_active_on_load_loops( - int64_t id, stdx::optional active_on_load_loops); + int64_t id, std::optional active_on_load_loops); /// Get the `lastEditTime` column for a given track. std::chrono::system_clock::time_point get_last_edit_time(int64_t id); diff --git a/include/djinterop/exceptions.hpp b/include/djinterop/exceptions.hpp index 3bc0c8d..4accbb4 100644 --- a/include/djinterop/exceptions.hpp +++ b/include/djinterop/exceptions.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_EXCEPTIONS_HPP #define DJINTEROP_EXCEPTIONS_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/musical_key.hpp b/include/djinterop/musical_key.hpp index c536eb6..4c601ec 100644 --- a/include/djinterop/musical_key.hpp +++ b/include/djinterop/musical_key.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_MUSICAL_KEY_HPP #define DJINTEROP_MUSICAL_KEY_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/optional.hpp b/include/djinterop/optional.hpp deleted file mode 100644 index a7b5e0f..0000000 --- a/include/djinterop/optional.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - 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 . - */ - -#pragma once -#ifndef DJINTEROP_OPTIONAL_HPP -#define DJINTEROP_OPTIONAL_HPP - -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler -#endif - -#include - -#if defined DJINTEROP_STD_OPTIONAL - -#include - -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 defined DJINTEROP_STD_EXPERIMENTAL_OPTIONAL - -#include - -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, but none was found - -#endif - -#endif // DJINTEROP_OPTIONAL_HPP diff --git a/include/djinterop/pad_color.hpp b/include/djinterop/pad_color.hpp index e528369..b2a719a 100644 --- a/include/djinterop/pad_color.hpp +++ b/include/djinterop/pad_color.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_PAD_COLOR_HPP #define DJINTEROP_PAD_COLOR_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/performance_data.hpp b/include/djinterop/performance_data.hpp index ade72eb..f167ed6 100644 --- a/include/djinterop/performance_data.hpp +++ b/include/djinterop/performance_data.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_PERFORMANCE_DATA_HPP #define DJINTEROP_PERFORMANCE_DATA_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/semantic_version.hpp b/include/djinterop/semantic_version.hpp index 1dc25e4..3de7dfc 100644 --- a/include/djinterop/semantic_version.hpp +++ b/include/djinterop/semantic_version.hpp @@ -19,8 +19,8 @@ #ifndef DJINTEROP_SEMANTIC_VERSION_HPP #define DJINTEROP_SEMANTIC_VERSION_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include diff --git a/include/djinterop/stream_helper.hpp b/include/djinterop/stream_helper.hpp index 41ba38a..e153453 100644 --- a/include/djinterop/stream_helper.hpp +++ b/include/djinterop/stream_helper.hpp @@ -19,17 +19,16 @@ #ifndef DJINTEROP_STREAM_HELPER_HPP #define DJINTEROP_STREAM_HELPER_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include +#include #include #include -#include - namespace djinterop::stream_helper { template std::ostream& print(std::ostream& os, const T& obj) @@ -38,7 +37,7 @@ template std::ostream& print(std::ostream& os, const T& obj) } template -std::ostream& print(std::ostream& os, const stdx::optional& obj) +std::ostream& print(std::ostream& os, const std::optional& obj) { if (obj) return print(os, *obj); @@ -49,7 +48,7 @@ std::ostream& print(std::ostream& os, const stdx::optional& obj) template std::ostream& print( std::ostream& os, - const stdx::optional>& obj) + const std::optional>& obj) { if (obj) return os << obj->count(); @@ -67,7 +66,7 @@ std::ostream& print( template std::ostream& print( std::ostream& os, - const stdx::optional>& obj) + const std::optional>& obj) { if (obj) return os << obj->time_since_epoch().count(); diff --git a/include/djinterop/track.hpp b/include/djinterop/track.hpp index f97473d..92214d9 100644 --- a/include/djinterop/track.hpp +++ b/include/djinterop/track.hpp @@ -19,20 +19,20 @@ #ifndef DJINTEROP_TRACK_HPP #define DJINTEROP_TRACK_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -80,50 +80,50 @@ class DJINTEROP_PUBLIC track void set_beatgrid(std::vector beatgrid) const; /// Returns the album name (metadata) of the track - stdx::optional album() const; + std::optional album() const; /// Sets the album name (metadata) of the track - void set_album(stdx::optional album) const; + void set_album(std::optional album) const; void set_album(std::string album) const; /// Returns the artist (metadata) of the track - stdx::optional artist() const; + std::optional artist() const; /// Sets the artist (metadata) of the track - void set_artist(stdx::optional artist) const; + void set_artist(std::optional artist) const; void set_artist(std::string artist) const; - stdx::optional average_loudness() const; + std::optional average_loudness() const; - void set_average_loudness(stdx::optional average_loudness) const; + void set_average_loudness(std::optional average_loudness) const; void set_average_loudness(double average_loudness) const; /// Returns the bitrate (metadata) of the track - stdx::optional bitrate() const; + std::optional bitrate() const; /// Sets the bitrate (metadata) of the track - void set_bitrate(stdx::optional bitrate) const; + void set_bitrate(std::optional bitrate) const; void set_bitrate(int bitrate) const; /// Returns the BPM (metadata) of the track, rounded to the nearest integer - stdx::optional bpm() const; + std::optional bpm() const; /// Sets the BPM (metadata) of the track, rounded to the nearest integer - void set_bpm(stdx::optional bpm) const; + void set_bpm(std::optional bpm) const; void set_bpm(double bpm) const; /// Returns the comment associated to the track (metadata) - stdx::optional comment() const; + std::optional comment() const; /// Sets the comment associated to the track (metadata) - void set_comment(stdx::optional comment) const; + void set_comment(std::optional comment) const; void set_comment(std::string comment) const; /// Returns the composer (metadata) of the track - stdx::optional composer() const; + std::optional composer() const; /// Sets the composer (metadata) of the track - void set_composer(stdx::optional composer) const; + void set_composer(std::optional composer) const; void set_composer(std::string composer) const; /// Returns the crates containing the track @@ -133,10 +133,10 @@ class DJINTEROP_PUBLIC track database db() const; /// Returns the duration (metadata) of the track - stdx::optional duration() const; + std::optional duration() const; /// Sets the duration (metadata) of the track. - void set_duration(stdx::optional duration); + void set_duration(std::optional duration); void set_duration(std::chrono::milliseconds duration); // TODO (mr-smidge): Add `file_bytes()` and `set_file_bytes()` methods. @@ -151,20 +151,20 @@ class DJINTEROP_PUBLIC track std::string filename() const; /// Returns the genre (metadata) of the track - stdx::optional genre() const; + std::optional genre() const; /// Sets the genre (metadata) of the track - void set_genre(stdx::optional genre) const; + void set_genre(std::optional genre) const; void set_genre(std::string genre) const; - stdx::optional hot_cue_at(int index) const; + std::optional hot_cue_at(int index) const; - void set_hot_cue_at(int index, stdx::optional cue) const; + void set_hot_cue_at(int index, std::optional cue) const; void set_hot_cue_at(int index, hot_cue cue) const; - std::vector> hot_cues() const; + std::vector> hot_cues() const; - void set_hot_cues(std::vector> cues) const; + void set_hot_cues(std::vector> cues) const; /// Returns the ID of this track /// @@ -176,49 +176,49 @@ class DJINTEROP_PUBLIC track bool is_valid() const; /// Returns the key (metadata) of the track - stdx::optional key() const; + std::optional key() const; /// Sets the key (metadata) of the track - void set_key(stdx::optional key) const; + void set_key(std::optional key) const; void set_key(musical_key key) const; /// Returns the time at which the track was last played - stdx::optional last_played_at() + std::optional last_played_at() const; /// Sets the time at which the track was last played void set_last_played_at( - stdx::optional time) const; + std::optional time) const; void set_last_played_at(std::chrono::system_clock::time_point time) const; - stdx::optional loop_at(int index) const; + std::optional loop_at(int index) const; - void set_loop_at(int index, stdx::optional l) const; + void set_loop_at(int index, std::optional l) const; void set_loop_at(int index, loop l) const; - std::vector> loops() const; + std::vector> loops() const; - void set_loops(std::vector> loops) const; + void set_loops(std::vector> loops) const; /// Get the track's main cue point. - stdx::optional main_cue() const; + std::optional main_cue() const; /// Set the track's main cue point. - void set_main_cue(stdx::optional sample_offset) const; + void set_main_cue(std::optional sample_offset) const; /// Returns the publisher (metadata) of the track - stdx::optional publisher() const; + std::optional publisher() const; /// Sets the publisher (metadata) of the track - void set_publisher(stdx::optional publisher) const; + void set_publisher(std::optional publisher) const; void set_publisher(std::string publisher) const; /// Gets the track rating, from 0-100. - stdx::optional rating() const; + std::optional rating() const; /// Sets the track rating, from 0-100. Any rating provided outside this /// range will be clamped. - void set_rating(stdx::optional rating); + void set_rating(std::optional rating); void set_rating(int rating); /// Get the path to this track's file on disk, relative to the music @@ -230,31 +230,31 @@ class DJINTEROP_PUBLIC track void set_relative_path(std::string relative_path) const; /// Get the sample count of the track. - stdx::optional sample_count() const; + std::optional sample_count() const; /// Set the sample count of the track. - void set_sample_count(stdx::optional sample_count); + void set_sample_count(std::optional sample_count); void set_sample_count(unsigned long long sample_count); /// Get the sample rate of the track. - stdx::optional sample_rate() const; + std::optional sample_rate() const; /// Set the sample rate of the track. - void set_sample_rate(stdx::optional sample_rate); + void set_sample_rate(std::optional sample_rate); void set_sample_rate(double sample_rate); /// Returns the title (metadata) of the track - stdx::optional title() const; + std::optional title() const; /// Sets the title (metadata) of the track - void set_title(stdx::optional title) const; + void set_title(std::optional title) const; void set_title(std::string title) const; /// Returns the track number (metadata) of the track - stdx::optional track_number() const; + std::optional track_number() const; /// Sets the track number (metadata) of the track - void set_track_number(stdx::optional track_number) const; + void set_track_number(std::optional track_number) const; void set_track_number(int track_number) const; // TODO (mr-smidge): Add `uri()` and `set_uri()` methods. @@ -264,10 +264,10 @@ class DJINTEROP_PUBLIC track void set_waveform(std::vector waveform) const; /// Returns the recording year (metadata) of the track - stdx::optional year() const; + std::optional year() const; /// Sets the recording year (metadata) of the track - void set_year(stdx::optional year) const; + void set_year(std::optional year) const; void set_year(int year) const; // TODO (haslersn): non public? diff --git a/include/djinterop/track_snapshot.hpp b/include/djinterop/track_snapshot.hpp index f0a33fe..4a66d6a 100644 --- a/include/djinterop/track_snapshot.hpp +++ b/include/djinterop/track_snapshot.hpp @@ -19,18 +19,18 @@ #ifndef DJINTEROP_TRACK_SNAPSHOT_HPP #define DJINTEROP_TRACK_SNAPSHOT_HPP -#if __cplusplus < 201703L -#error This library needs at least a C++17 compliant compiler +#if __cplusplus < 202002L +#error This library needs at least a C++20 compliant compiler #endif #include #include +#include #include #include #include #include -#include #include #include @@ -53,83 +53,83 @@ class database; struct track_snapshot { /// The album name metadata. - stdx::optional album; + std::optional album; /// The artist name metadata. - stdx::optional artist; + std::optional artist; /// The average loudness metadata. - stdx::optional average_loudness; + std::optional average_loudness; /// The beatgrid. std::vector beatgrid; /// The bitrate metadata. - stdx::optional bitrate; + std::optional bitrate; /// The BPM metadata. - stdx::optional bpm; + std::optional bpm; /// The comment metadata. - stdx::optional comment; + std::optional comment; /// The composer metadata. - stdx::optional composer; + std::optional composer; /// The duration metadata. - stdx::optional duration; + std::optional duration; /// The size of the file, in bytes, metadata. - stdx::optional file_bytes; + std::optional file_bytes; /// The genre metadata. - stdx::optional genre; + std::optional genre; /// The hot cues. - std::vector> hot_cues; + std::vector> hot_cues; /// The key. - stdx::optional key; + std::optional key; /// The time at which the track was last played. - stdx::optional last_played_at; + std::optional last_played_at; /// The loops. - std::vector> loops; + std::vector> loops; /// The main cue sample offset. - stdx::optional main_cue; + std::optional main_cue; /// The publisher metadata. - stdx::optional publisher; + std::optional publisher; /// The track rating, from 0-100. /// Any rating provided outside this range will be clamped. - stdx::optional rating; + std::optional rating; /// The path to this track's file on disk, relative to the directory of /// the database. - stdx::optional relative_path; + std::optional relative_path; /// Number of audio samples within the track. - stdx::optional sample_count; + std::optional sample_count; /// Sample rate, i.e. number of samples per second. - stdx::optional sample_rate; + std::optional sample_rate; /// The title metadata. - stdx::optional title; + std::optional title; /// The track number metadata. - stdx::optional track_number; + std::optional track_number; - // TODO (mr-smidge): Add `stdx::optional uri` field. + // TODO (mr-smidge): Add `std::optional uri` field. /// The waveform. std::vector waveform; /// The recording year metadata. - stdx::optional year; + std::optional year; friend bool operator==( const track_snapshot& lhs, const track_snapshot& rhs) noexcept diff --git a/src/djinterop/crate.cpp b/src/djinterop/crate.cpp index a3ecd77..84699b0 100644 --- a/src/djinterop/crate.cpp +++ b/src/djinterop/crate.cpp @@ -86,7 +86,7 @@ std::string crate::name() const return pimpl_->name(); } -stdx::optional crate::parent() const +std::optional crate::parent() const { return pimpl_->parent(); } @@ -101,12 +101,12 @@ void crate::set_name(std::string name) const pimpl_->set_name(name); } -void crate::set_parent(stdx::optional parent) const +void crate::set_parent(std::optional parent) const { pimpl_->set_parent(parent); } -stdx::optional crate::sub_crate_by_name(const std::string& name) const +std::optional 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 bd7e0db..65a01e6 100644 --- a/src/djinterop/database.cpp +++ b/src/djinterop/database.cpp @@ -31,7 +31,7 @@ database::~database() = default; database& database::operator=(const database& db) = default; -stdx::optional database::crate_by_id(int64_t id) const +std::optional database::crate_by_id(int64_t id) const { return pimpl_->crate_by_id(id); } @@ -86,13 +86,13 @@ std::vector database::root_crates() const return pimpl_->root_crates(); } -stdx::optional database::root_crate_by_name( +std::optional database::root_crate_by_name( const std::string& name) const { return pimpl_->root_crate_by_name(name); } -stdx::optional database::track_by_id(int64_t id) const +std::optional database::track_by_id(int64_t id) const { return pimpl_->track_by_id(id); } diff --git a/src/djinterop/engine/engine.cpp b/src/djinterop/engine/engine.cpp index 770028d..1e0f384 100644 --- a/src/djinterop/engine/engine.cpp +++ b/src/djinterop/engine/engine.cpp @@ -33,11 +33,11 @@ namespace djinterop::engine { namespace { -inline djinterop::stdx::optional get_column_type( +inline std::optional get_column_type( sqlite::database& db, const std::string& table_name, const std::string& column_name) { - djinterop::stdx::optional column_type; + std::optional column_type; db << "PRAGMA table_info('" + table_name + "')" >> [&]([[maybe_unused]] int col_id, const std::string& col_name, diff --git a/src/djinterop/engine/schema/schema_validate_utils.hpp b/src/djinterop/engine/schema/schema_validate_utils.hpp index 919882e..5a0e38d 100644 --- a/src/djinterop/engine/schema/schema_validate_utils.hpp +++ b/src/djinterop/engine/schema/schema_validate_utils.hpp @@ -82,8 +82,8 @@ inline bool operator<(const index_info_entry& o1, const index_info_entry& o2) struct master_list { - typedef std::set::iterator iterator; - typedef std::set::const_iterator const_iterator; + using iterator = std::set::iterator; + using const_iterator = std::set::const_iterator; master_list( sqlite::database& db, const std::string& db_name, @@ -125,8 +125,8 @@ struct master_list struct table_info { - typedef std::set::iterator iterator; - typedef std::set::const_iterator const_iterator; + using iterator = std::set::iterator; + using const_iterator = std::set::const_iterator; table_info( sqlite::database& db, const std::string& db_name, @@ -172,8 +172,8 @@ struct table_info struct index_list { - typedef std::set::iterator iterator; - typedef std::set::const_iterator const_iterator; + using iterator = std::set::iterator; + using const_iterator = std::set::const_iterator; index_list( sqlite::database& db, const std::string& db_name, @@ -220,8 +220,8 @@ struct index_list struct index_info { - typedef std::set::iterator iterator; - typedef std::set::const_iterator const_iterator; + using iterator = std::set::iterator; + using const_iterator = std::set::const_iterator; index_info( sqlite::database& db, const std::string& db_name, diff --git a/src/djinterop/engine/v1/engine_crate_impl.cpp b/src/djinterop/engine/v1/engine_crate_impl.cpp index e5c325b..ae26cb3 100644 --- a/src/djinterop/engine/v1/engine_crate_impl.cpp +++ b/src/djinterop/engine/v1/engine_crate_impl.cpp @@ -228,7 +228,7 @@ bool engine_crate_impl::is_valid() std::string engine_crate_impl::name() { - stdx::optional name; + std::optional name; storage_->db << "SELECT title FROM Crate WHERE id = ?" << id() >> [&](std::string title) { if (!name) @@ -248,9 +248,9 @@ std::string engine_crate_impl::name() return *name; } -stdx::optional engine_crate_impl::parent() +std::optional engine_crate_impl::parent() { - stdx::optional parent; + std::optional parent; storage_->db << "SELECT crateParentId FROM CrateParentList WHERE crateOriginId " "= ? AND crateParentId <> crateOriginId" @@ -315,7 +315,7 @@ void engine_crate_impl::set_name(std::string name) trans.commit(); } -void engine_crate_impl::set_parent(stdx::optional parent) +void engine_crate_impl::set_parent(std::optional parent) { if (parent && parent->id() == id()) { @@ -345,9 +345,9 @@ void engine_crate_impl::set_parent(stdx::optional parent) trans.commit(); } -stdx::optional engine_crate_impl::sub_crate_by_name(const std::string& name) +std::optional engine_crate_impl::sub_crate_by_name(const std::string& name) { - stdx::optional cr; + std::optional 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/engine/v1/engine_crate_impl.hpp b/src/djinterop/engine/v1/engine_crate_impl.hpp index 4e9723a..ffc620b 100644 --- a/src/djinterop/engine/v1/engine_crate_impl.hpp +++ b/src/djinterop/engine/v1/engine_crate_impl.hpp @@ -43,11 +43,11 @@ class engine_crate_impl : public djinterop::crate_impl std::vector descendants() override; bool is_valid() override; std::string name() override; - stdx::optional parent() override; + std::optional parent() override; void remove_track(track tr) override; void set_name(std::string name) override; - void set_parent(stdx::optional parent) override; - stdx::optional sub_crate_by_name(const std::string& name) override; + void set_parent(std::optional parent) override; + std::optional sub_crate_by_name(const std::string& name) override; std::vector tracks() override; private: diff --git a/src/djinterop/engine/v1/engine_database_impl.cpp b/src/djinterop/engine/v1/engine_database_impl.cpp index fdcc5ba..0acad6d 100644 --- a/src/djinterop/engine/v1/engine_database_impl.cpp +++ b/src/djinterop/engine/v1/engine_database_impl.cpp @@ -50,9 +50,9 @@ engine_database_impl::engine_database_impl(std::shared_ptr stora { } -stdx::optional engine_database_impl::crate_by_id(int64_t id) +std::optional engine_database_impl::crate_by_id(int64_t id) { - stdx::optional cr; + std::optional cr; storage_->db << "SELECT COUNT(*) FROM Crate WHERE id = ?" << id >> [&](int64_t count) { if (count == 1) @@ -174,10 +174,10 @@ std::vector engine_database_impl::root_crates() return results; } -stdx::optional engine_database_impl::root_crate_by_name( +std::optional engine_database_impl::root_crate_by_name( const std::string& name) { - stdx::optional cr; + std::optional cr; storage_->db << "SELECT cr.id FROM Crate cr " "JOIN CrateParentList cpl ON (cpl.crateOriginId = cr.id) " "WHERE cr.title = ? " @@ -190,9 +190,9 @@ stdx::optional engine_database_impl::root_crate_by_name( return cr; } -stdx::optional engine_database_impl::track_by_id(int64_t id) +std::optional engine_database_impl::track_by_id(int64_t id) { - stdx::optional tr; + std::optional tr; storage_->db << "SELECT COUNT(*) FROM Track WHERE id = ?" << id >> [&](int64_t count) { if (count == 1) diff --git a/src/djinterop/engine/v1/engine_database_impl.hpp b/src/djinterop/engine/v1/engine_database_impl.hpp index 736c271..562cbab 100644 --- a/src/djinterop/engine/v1/engine_database_impl.hpp +++ b/src/djinterop/engine/v1/engine_database_impl.hpp @@ -29,7 +29,7 @@ class engine_database_impl : public database_impl public: engine_database_impl(std::shared_ptr storage); - stdx::optional crate_by_id(int64_t id) override; + std::optional crate_by_id(int64_t id) override; std::vector crates() override; std::vector crates_by_name( const std::string& name) override; @@ -42,9 +42,9 @@ class engine_database_impl : public database_impl void remove_crate(djinterop::crate cr) override; void remove_track(djinterop::track tr) override; std::vector root_crates() override; - stdx::optional root_crate_by_name( + std::optional root_crate_by_name( const std::string& name) override; - stdx::optional track_by_id(int64_t id) override; + std::optional track_by_id(int64_t id) override; std::vector tracks() override; std::vector tracks_by_relative_path( const std::string& relative_path) override; diff --git a/src/djinterop/engine/v1/engine_storage.cpp b/src/djinterop/engine/v1/engine_storage.cpp index aed7047..afdba3c 100644 --- a/src/djinterop/engine/v1/engine_storage.cpp +++ b/src/djinterop/engine/v1/engine_storage.cpp @@ -103,20 +103,20 @@ std::shared_ptr engine_storage::create_temporary( } int64_t engine_storage::create_track( - stdx::optional play_order, stdx::optional length, - stdx::optional length_calculated, stdx::optional bpm, - stdx::optional year, - const stdx::optional& relative_path, - const stdx::optional& filename, - stdx::optional bitrate, stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - const stdx::optional& uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, stdx::optional file_bytes, - stdx::optional pdb_import_key, - const stdx::optional& uri, - stdx::optional is_beatgrid_locked) + std::optional play_order, std::optional length, + std::optional length_calculated, std::optional bpm, + std::optional year, + const std::optional& relative_path, + const std::optional& filename, + std::optional bitrate, std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + const std::optional& uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, std::optional file_bytes, + std::optional pdb_import_key, + const std::optional& uri, + std::optional is_beatgrid_locked) { if (version.schema_version >= os_1_6_0.schema_version) { @@ -202,7 +202,7 @@ int64_t engine_storage::create_track( track_row engine_storage::get_track(int64_t id) { - stdx::optional result; + std::optional result; if (version.schema_version >= os_1_6_0.schema_version) { db << ("SELECT playOrder, length, lengthCalculated, bpm, year, path, " @@ -211,23 +211,23 @@ track_row engine_storage::get_track(int64_t id) "fileBytes, pdbImportKey, uri, isBeatGridLocked " "FROM Track WHERE id = ?") << id >> - [&](stdx::optional play_order, - stdx::optional length, - stdx::optional length_calculated, - stdx::optional bpm, stdx::optional year, - stdx::optional relative_path, - stdx::optional filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - stdx::optional uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, - stdx::optional file_bytes, - stdx::optional pdb_import_key, - stdx::optional uri, - stdx::optional is_beatgrid_locked) { + [&](std::optional play_order, + std::optional length, + std::optional length_calculated, + std::optional bpm, std::optional year, + std::optional relative_path, + std::optional filename, + std::optional bitrate, + std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + std::optional uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, + std::optional file_bytes, + std::optional pdb_import_key, + std::optional uri, + std::optional is_beatgrid_locked) { if (result) { throw track_database_inconsistency{ @@ -262,22 +262,22 @@ track_row engine_storage::get_track(int64_t id) "fileBytes, pdbImportKey, uri " "FROM Track WHERE id = ?") << id >> - [&](stdx::optional play_order, - stdx::optional length, - stdx::optional length_calculated, - stdx::optional bpm, stdx::optional year, - stdx::optional relative_path, - stdx::optional filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - stdx::optional uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, - stdx::optional file_bytes, - stdx::optional pdb_import_key, - stdx::optional uri) { + [&](std::optional play_order, + std::optional length, + std::optional length_calculated, + std::optional bpm, std::optional year, + std::optional relative_path, + std::optional filename, + std::optional bitrate, + std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + std::optional uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, + std::optional file_bytes, + std::optional pdb_import_key, + std::optional uri) { if (result) { throw track_database_inconsistency{ @@ -311,20 +311,20 @@ track_row engine_storage::get_track(int64_t id) "pdbImportKey " "FROM Track WHERE id = ?") << id >> - [&](stdx::optional play_order, - stdx::optional length, - stdx::optional length_calculated, - stdx::optional bpm, stdx::optional year, - stdx::optional relative_path, - stdx::optional filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - stdx::optional uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, - stdx::optional pdb_import_key) { + [&](std::optional play_order, + std::optional length, + std::optional length_calculated, + std::optional bpm, std::optional year, + std::optional relative_path, + std::optional filename, + std::optional bitrate, + std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + std::optional uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, + std::optional pdb_import_key) { if (result) { throw track_database_inconsistency{ @@ -345,7 +345,7 @@ track_row engine_storage::get_track(int64_t id) std::move(uuid_of_external_database), id_track_in_external_database, album_art_id, - stdx::nullopt, // file_bytes + std::nullopt, // file_bytes pdb_import_key}; }; } @@ -356,19 +356,19 @@ track_row engine_storage::get_track(int64_t id) "uuidOfExternalDatabase, idTrackInExternalDatabase, idAlbumArt " "FROM Track WHERE id = ?") << id >> - [&](stdx::optional play_order, - stdx::optional length, - stdx::optional length_calculated, - stdx::optional bpm, stdx::optional year, - stdx::optional relative_path, - stdx::optional filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - stdx::optional uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id) { + [&](std::optional play_order, + std::optional length, + std::optional length_calculated, + std::optional bpm, std::optional year, + std::optional relative_path, + std::optional filename, + std::optional bitrate, + std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + std::optional uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id) { if (result) { throw track_database_inconsistency{ @@ -401,20 +401,20 @@ track_row engine_storage::get_track(int64_t id) /// Update a row in the `Track` table. void engine_storage::update_track( - int64_t id, stdx::optional play_order, - stdx::optional length, stdx::optional length_calculated, - stdx::optional bpm, stdx::optional year, - const stdx::optional& relative_path, - const stdx::optional& filename, - stdx::optional bitrate, stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - const stdx::optional& uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, stdx::optional file_bytes, - stdx::optional pdb_import_key, - const stdx::optional& uri, - stdx::optional is_beatgrid_locked) + int64_t id, std::optional play_order, + std::optional length, std::optional length_calculated, + std::optional bpm, std::optional year, + const std::optional& relative_path, + const std::optional& filename, + std::optional bitrate, std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + const std::optional& uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, std::optional file_bytes, + std::optional pdb_import_key, + const std::optional& uri, + std::optional is_beatgrid_locked) { if (version.schema_version >= os_1_6_0.schema_version) { @@ -498,10 +498,10 @@ std::vector engine_storage::get_all_meta_data(int64_t id) return results; } -stdx::optional engine_storage::get_meta_data( +std::optional engine_storage::get_meta_data( int64_t id, metadata_str_type type) { - stdx::optional result; + std::optional result; db << "SELECT text FROM MetaData WHERE id = ? AND " "type = ? AND text IS NOT NULL" << id << static_cast(type) >> @@ -522,7 +522,7 @@ stdx::optional engine_storage::get_meta_data( } void engine_storage::set_meta_data( - int64_t id, metadata_str_type type, stdx::optional content) + int64_t id, metadata_str_type type, std::optional content) { if (content) { @@ -543,19 +543,19 @@ void engine_storage::set_meta_data( } void engine_storage::set_meta_data( - int64_t id, const stdx::optional& title, - const stdx::optional& artist, - const stdx::optional& album, - const stdx::optional& genre, - const stdx::optional& comment, - const stdx::optional& publisher, - const stdx::optional& composer, - const stdx::optional& duration_mm_ss, - const stdx::optional& ever_played, - const stdx::optional& file_extension) + int64_t id, const std::optional& title, + const std::optional& artist, + const std::optional& album, + const std::optional& genre, + const std::optional& comment, + const std::optional& publisher, + const std::optional& composer, + const std::optional& duration_mm_ss, + const std::optional& ever_played, + const std::optional& file_extension) { // Note that rows are created even for null values. - stdx::optional no_value; + std::optional no_value; if (version.schema_version >= os_1_4_0.schema_version) { // A new unknown entry of type 17 may appear from 1.15.0 onwards. @@ -650,10 +650,10 @@ std::vector engine_storage::get_all_meta_data_integer( return results; } -stdx::optional engine_storage::get_meta_data_integer( +std::optional engine_storage::get_meta_data_integer( int64_t id, metadata_int_type type) { - stdx::optional result; + std::optional result; db << "SELECT value FROM MetaDataInteger WHERE id = " "? AND type = ? AND value IS NOT NULL" << id << static_cast(type) >> @@ -674,26 +674,26 @@ stdx::optional engine_storage::get_meta_data_integer( } void engine_storage::set_meta_data_integer( - int64_t id, metadata_int_type type, stdx::optional content) + int64_t id, metadata_int_type type, std::optional content) { db << "REPLACE INTO MetaDataInteger (id, type, value) VALUES (?, ?, ?)" << id << static_cast(type) << content; } void engine_storage::set_meta_data_integer( - int64_t id, stdx::optional musical_key, - stdx::optional rating, - stdx::optional last_played_timestamp, - stdx::optional last_modified_timestamp, - stdx::optional last_accessed_timestamp, - stdx::optional last_play_hash) + int64_t id, std::optional musical_key, + std::optional rating, + std::optional last_played_timestamp, + std::optional last_modified_timestamp, + std::optional last_accessed_timestamp, + std::optional last_play_hash) { // Note that rows are created even for null values. // // Hardware players have been observed to record integer metadata in the // order 4, 5, 1, 2, 3, 6, 8, 7, 9, 10, 11, for reasons unknown. The code // below replicates this order for maximum compatibility. - stdx::optional no_value; + std::optional no_value; if (version.schema_version >= os_1_2_0.schema_version) { // A new unknown entry of type 12 may appear from 1.11.1 onwards. @@ -773,7 +773,7 @@ void engine_storage::clear_performance_data(int64_t id) performance_data_row engine_storage::get_performance_data(int64_t id) { - stdx::optional result; + std::optional result; if (version.schema_version >= os_1_2_0.schema_version) { db << "SELECT id, isAnalyzed, isRendered, " diff --git a/src/djinterop/engine/v1/engine_storage.hpp b/src/djinterop/engine/v1/engine_storage.hpp index a2fc073..444a71f 100644 --- a/src/djinterop/engine/v1/engine_storage.hpp +++ b/src/djinterop/engine/v1/engine_storage.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include #include "djinterop/engine/metadata_types.hpp" #include "performance_data_format.hpp" @@ -38,24 +38,24 @@ namespace djinterop::engine::v1 /// The `track_row` struct represents a row from the `Track` table. struct track_row { - stdx::optional play_order; - stdx::optional length; - stdx::optional length_calculated; - stdx::optional bpm; - stdx::optional year; - stdx::optional relative_path; - stdx::optional filename; - stdx::optional bitrate; - stdx::optional bpm_analyzed; - stdx::optional track_type; - stdx::optional is_external_track; - stdx::optional uuid_of_external_database; - stdx::optional id_track_in_external_database; - stdx::optional album_art_id; - stdx::optional file_bytes; - stdx::optional pdb_import_key; - stdx::optional uri; - stdx::optional is_beatgrid_locked; + std::optional play_order; + std::optional length; + std::optional length_calculated; + std::optional bpm; + std::optional year; + std::optional relative_path; + std::optional filename; + std::optional bitrate; + std::optional bpm_analyzed; + std::optional track_type; + std::optional is_external_track; + std::optional uuid_of_external_database; + std::optional id_track_in_external_database; + std::optional album_art_id; + std::optional file_bytes; + std::optional pdb_import_key; + std::optional uri; + std::optional is_beatgrid_locked; }; /// The `meta_data_row` struct represents a row from the `MetaData` table. @@ -82,12 +82,12 @@ struct performance_data_row int64_t id; int64_t is_analyzed; int64_t is_rendered; - stdx::optional track_performance_data; - stdx::optional high_res_waveform; - stdx::optional overview_waveform; - stdx::optional beats; - stdx::optional quick_cues; - stdx::optional loops; + std::optional track_performance_data; + std::optional high_res_waveform; + std::optional overview_waveform; + std::optional beats; + std::optional quick_cues; + std::optional loops; int64_t has_serato_values; int64_t has_rekordbox_values; int64_t has_traktor_values; @@ -114,21 +114,21 @@ class engine_storage /// Create an entry in the `Track` table. int64_t create_track( - stdx::optional play_order, stdx::optional length, - stdx::optional length_calculated, stdx::optional bpm, - stdx::optional year, - const stdx::optional& relative_path, - const stdx::optional& filename, - stdx::optional bitrate, stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - const stdx::optional& uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, - stdx::optional file_bytes, - stdx::optional pdb_import_key, - const stdx::optional& uri, - stdx::optional is_beatgrid_locked); + std::optional play_order, std::optional length, + std::optional length_calculated, std::optional bpm, + std::optional year, + const std::optional& relative_path, + const std::optional& filename, + std::optional bitrate, std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + const std::optional& uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, + std::optional file_bytes, + std::optional pdb_import_key, + const std::optional& uri, + std::optional is_beatgrid_locked); /// Get a row from the `Track` table. track_row get_track(int64_t id); @@ -137,7 +137,7 @@ class engine_storage template T get_track_column(int64_t id, const char* column_name) { - stdx::optional result; + std::optional result; db << (std::string{"SELECT "} + column_name + " FROM Track WHERE id = ?") << id >> @@ -161,22 +161,22 @@ class engine_storage /// Update a row in the `Track` table. void update_track( - int64_t id, stdx::optional play_order, - stdx::optional length, - stdx::optional length_calculated, stdx::optional bpm, - stdx::optional year, - const stdx::optional& relative_path, - const stdx::optional& filename, - stdx::optional bitrate, stdx::optional bpm_analyzed, - stdx::optional track_type, - stdx::optional is_external_track, - const stdx::optional& uuid_of_external_database, - stdx::optional id_track_in_external_database, - stdx::optional album_art_id, - stdx::optional file_bytes, - stdx::optional pdb_import_key, - const stdx::optional& uri, - stdx::optional is_beatgrid_locked); + int64_t id, std::optional play_order, + std::optional length, + std::optional length_calculated, std::optional bpm, + std::optional year, + const std::optional& relative_path, + const std::optional& filename, + std::optional bitrate, std::optional bpm_analyzed, + std::optional track_type, + std::optional is_external_track, + const std::optional& uuid_of_external_database, + std::optional id_track_in_external_database, + std::optional album_art_id, + std::optional file_bytes, + std::optional pdb_import_key, + const std::optional& uri, + std::optional is_beatgrid_locked); /// Set the value of a given column in the `Track` table. template @@ -191,13 +191,13 @@ class engine_storage std::vector get_all_meta_data(int64_t id); /// Get string meta-data from the `MetaData` table. - stdx::optional get_meta_data( + std::optional get_meta_data( int64_t id, metadata_str_type type); /// Set string meta-data in the `MetaData` table. void set_meta_data( int64_t id, metadata_str_type type, - stdx::optional content); + std::optional content); /// Set string meta-data in the `MetaData` table. void set_meta_data( @@ -205,36 +205,36 @@ class engine_storage /// Bulk-set entries in the `MetaData` table. void set_meta_data( - int64_t id, const stdx::optional& title, - const stdx::optional& artist, - const stdx::optional& album, - const stdx::optional& genre, - const stdx::optional& comment, - const stdx::optional& publisher, - const stdx::optional& composer, - const stdx::optional& duration_mm_ss, - const stdx::optional& ever_played, - const stdx::optional& file_extension); + int64_t id, const std::optional& title, + const std::optional& artist, + const std::optional& album, + const std::optional& genre, + const std::optional& comment, + const std::optional& publisher, + const std::optional& composer, + const std::optional& duration_mm_ss, + const std::optional& ever_played, + const std::optional& file_extension); /// Get all integer meta-data for a track from the `MetaDataInteger` table. std::vector get_all_meta_data_integer(int64_t id); /// Get integer meta-data from the `MetaDataInteger` table. - stdx::optional get_meta_data_integer( + std::optional get_meta_data_integer( int64_t id, metadata_int_type type); /// Set integer meta-data in the `MetaDataInteger` table. void set_meta_data_integer( - int64_t id, metadata_int_type type, stdx::optional content); + int64_t id, metadata_int_type type, std::optional content); /// Bulk-set entries in the `MetaDataInteger` table. void set_meta_data_integer( - int64_t id, stdx::optional musical_key, - stdx::optional rating, - stdx::optional last_played_timestamp, - stdx::optional last_modified_timestamp, - stdx::optional last_accessed_timestamp, - stdx::optional last_play_hash); + int64_t id, std::optional musical_key, + std::optional rating, + std::optional last_played_timestamp, + std::optional last_modified_timestamp, + std::optional last_accessed_timestamp, + std::optional last_play_hash); /// Remove an existing entry in the `PerformanceData` table, if it exists. void clear_performance_data(int64_t id); @@ -246,7 +246,7 @@ class engine_storage template T get_performance_data_column(int64_t id, const char* column_name) { - stdx::optional result; + std::optional result; db << (std::string{"SELECT "} + column_name + " FROM PerformanceData WHERE id = ?") << id >> diff --git a/src/djinterop/engine/v1/engine_track_impl.cpp b/src/djinterop/engine/v1/engine_track_impl.cpp index 34959b5..e664493 100644 --- a/src/djinterop/engine/v1/engine_track_impl.cpp +++ b/src/djinterop/engine/v1/engine_track_impl.cpp @@ -16,8 +16,10 @@ */ #include +#include #include #include +#include #include #include @@ -44,15 +46,15 @@ const int64_t default_track_type = 1; const int64_t default_is_external_track = 0; -const stdx::optional default_uuid_of_external_database; +const std::optional default_uuid_of_external_database; -const stdx::optional default_id_track_in_external_database; +const std::optional default_id_track_in_external_database; const int64_t no_album_art_id = 1; const int64_t default_pdb_import_key = 0; -const stdx::optional default_uri; +const std::optional default_uri; const int64_t default_is_beatgrid_locked = 0; @@ -66,18 +68,18 @@ const int64_t default_has_traktor_values = 0; struct length_field_data { - stdx::optional length; - stdx::optional length_calculated; - stdx::optional length_mm_ss; + std::optional length; + std::optional length_calculated; + std::optional length_mm_ss; }; length_field_data to_length_fields( - stdx::optional duration, - stdx::optional sample_count, - stdx::optional sample_rate) + std::optional duration, + std::optional sample_count, + std::optional sample_rate) { - stdx::optional length; - stdx::optional length_mm_ss; + std::optional length; + std::optional length_mm_ss; if (duration) { length = static_cast(duration->count() / 1000); @@ -93,7 +95,7 @@ length_field_data to_length_fields( } // A zero sample rate is interpreted as no sample rate. - stdx::optional length_calculated; + std::optional length_calculated; if (sample_count && sample_rate && *sample_rate != 0) { length_calculated = static_cast(*sample_count) / @@ -105,21 +107,21 @@ length_field_data to_length_fields( struct bpm_field_data { - stdx::optional bpm; - stdx::optional bpm_analyzed; + std::optional bpm; + std::optional bpm_analyzed; }; bpm_field_data to_bpm_fields( - stdx::optional bpm, stdx::optional sample_rate, + std::optional bpm, std::optional sample_rate, const std::vector& beatgrid) { - stdx::optional rounded_bpm; + std::optional rounded_bpm; if (bpm) { rounded_bpm = static_cast(*bpm); } - stdx::optional bpm_analyzed; + std::optional bpm_analyzed; if (sample_rate && beatgrid.size() >= 2) { auto marker_1 = beatgrid[0]; @@ -137,27 +139,27 @@ bpm_field_data to_bpm_fields( struct timestamp_field_data { - stdx::optional last_played_at_ts; - stdx::optional last_modified_at_ts; - stdx::optional last_accessed_at_ts; - stdx::optional ever_played; + std::optional last_played_at_ts; + std::optional last_modified_at_ts; + std::optional last_accessed_at_ts; + std::optional ever_played; }; timestamp_field_data to_timestamp_fields( - stdx::optional last_played_at) + std::optional last_played_at) { auto last_played_at_ts = djinterop::util::to_timestamp(last_played_at); - stdx::optional ever_played = - last_played_at ? stdx::optional{"1"} : stdx::nullopt; + std::optional ever_played = + last_played_at ? std::optional{"1"} : std::nullopt; return timestamp_field_data{ - last_played_at_ts, stdx::nullopt, stdx::nullopt, ever_played}; + last_played_at_ts, std::nullopt, std::nullopt, ever_played}; } -stdx::optional to_key_num(stdx::optional key) +std::optional to_key_num(std::optional key) { - stdx::optional key_num; + std::optional key_num; if (key) { key_num = static_cast(*key); @@ -167,9 +169,9 @@ stdx::optional to_key_num(stdx::optional key) } track_data to_track_data( - stdx::optional sample_count, - stdx::optional sample_rate, stdx::optional average_loudness, - stdx::optional key) + std::optional sample_count, + std::optional sample_rate, std::optional average_loudness, + std::optional key) { return track_data{ sample_rate, @@ -178,11 +180,11 @@ track_data to_track_data( } quick_cues_data to_cues_data( - const std::vector >& hot_cues, - stdx::optional main_cue) + const std::vector >& hot_cues, + std::optional main_cue) { - auto data = quick_cues_data{ - hot_cues, main_cue.value_or(0), main_cue.value_or(0)}; + const auto main_cue_or_zero = main_cue.value_or(0); + auto data = quick_cues_data{hot_cues, main_cue_or_zero, main_cue_or_zero}; if (data.hot_cues.size() < 8) data.hot_cues.resize(8); @@ -190,8 +192,8 @@ quick_cues_data to_cues_data( } beat_data to_beat_data( - stdx::optional sample_count, - stdx::optional sample_rate, + std::optional sample_count, + std::optional sample_rate, const std::vector& beatgrid) { return beat_data{ @@ -200,7 +202,7 @@ beat_data to_beat_data( beatgrid}; } -loops_data to_loops_data(const std::vector >& loops) +loops_data to_loops_data(const std::vector >& loops) { auto data = loops_data{loops}; if (data.loops.size() < 8) @@ -210,8 +212,8 @@ loops_data to_loops_data(const std::vector >& loops) } overview_waveform_data to_overview_waveform_data( - stdx::optional sample_count, - stdx::optional sample_rate, + std::optional sample_count, + std::optional sample_rate, const std::vector& waveform) { if (!sample_count || !sample_rate) @@ -238,8 +240,8 @@ overview_waveform_data to_overview_waveform_data( } high_res_waveform_data to_high_res_waveform_data( - stdx::optional sample_count, - stdx::optional sample_rate, + std::optional sample_count, + std::optional sample_rate, const std::vector& waveform) { // Make the assumption that the client has respected the required number @@ -348,23 +350,23 @@ track_snapshot engine_track_impl::snapshot() const } snapshot.main_cue = (perf_data.quick_cues && perf_data.quick_cues->adjusted_main_cue != 0) - ? stdx::make_optional(perf_data.quick_cues->adjusted_main_cue) - : stdx::nullopt; + ? std::make_optional(perf_data.quick_cues->adjusted_main_cue) + : std::nullopt; snapshot.average_loudness = perf_data.track_performance_data ? perf_data.track_performance_data->average_loudness - : stdx::nullopt; + : std::nullopt; snapshot.bitrate = djinterop::util::optional_static_cast(track_data.bitrate); snapshot.bpm = track_data.bpm_analyzed ? track_data.bpm_analyzed : track_data.bpm - ? stdx::make_optional(static_cast(*track_data.bpm)) - : stdx::nullopt; + ? std::make_optional(static_cast(*track_data.bpm)) + : std::nullopt; if (track_data.length) { auto ms = 1000 * *track_data.length; - snapshot.duration = stdx::make_optional(milliseconds{ms}); + snapshot.duration = std::make_optional(milliseconds{ms}); } snapshot.file_bytes = djinterop::util::optional_static_cast( @@ -375,7 +377,7 @@ track_snapshot engine_track_impl::snapshot() const } snapshot.key = perf_data.track_performance_data ? perf_data.track_performance_data->key - : stdx::nullopt; + : std::nullopt; if (perf_data.loops) { snapshot.loops = std::move(perf_data.loops->loops); @@ -393,16 +395,16 @@ track_snapshot engine_track_impl::snapshot() const } snapshot.track_number = track_data.play_order - ? stdx::make_optional(static_cast(*track_data.play_order)) - : stdx::nullopt; + ? std::make_optional(static_cast(*track_data.play_order)) + : std::nullopt; if (perf_data.high_res_waveform) { snapshot.waveform = std::move(perf_data.high_res_waveform->waveform); } snapshot.year = track_data.year - ? stdx::make_optional(static_cast(*track_data.year)) - : stdx::nullopt; + ? std::make_optional(static_cast(*track_data.year)) + : std::nullopt; for (auto&& row : meta_data) { @@ -436,7 +438,7 @@ track_snapshot engine_track_impl::snapshot() const case metadata_int_type::musical_key: if (!snapshot.key) { - snapshot.key = stdx::make_optional( + snapshot.key = std::make_optional( static_cast(row.value)); } @@ -465,18 +467,18 @@ void engine_track_impl::update(const track_snapshot& snapshot) auto extension = djinterop::util::get_file_extension(filename); auto track_number = snapshot.track_number - ? stdx::make_optional(static_cast(*snapshot.track_number)) - : stdx::nullopt; + ? std::make_optional(static_cast(*snapshot.track_number)) + : std::nullopt; auto year = snapshot.year - ? stdx::make_optional(static_cast(*snapshot.year)) - : stdx::nullopt; + ? std::make_optional(static_cast(*snapshot.year)) + : std::nullopt; auto timestamp_fields = to_timestamp_fields(snapshot.last_played_at); auto key_num = to_key_num(snapshot.key); auto clamped_rating = snapshot.rating - ? stdx::make_optional(static_cast( + ? std::make_optional(static_cast( std::clamp(*snapshot.rating, 0, 100))) - : stdx::nullopt; - stdx::optional last_play_hash; + : std::nullopt; + std::optional last_play_hash; auto track_data = to_track_data( snapshot.sample_count, snapshot.sample_rate, snapshot.average_loudness, snapshot.key); @@ -537,40 +539,40 @@ void engine_track_impl::update(const track_snapshot& snapshot) trans.commit(); } -stdx::optional engine_track_impl::album() +std::optional engine_track_impl::album() { return storage_->get_meta_data(id(), metadata_str_type::album); } -void engine_track_impl::set_album(stdx::optional album) +void engine_track_impl::set_album(std::optional album) { storage_->set_meta_data(id(), metadata_str_type::album, album); } -stdx::optional engine_track_impl::artist() +std::optional engine_track_impl::artist() { return storage_->get_meta_data(id(), metadata_str_type::artist); } -void engine_track_impl::set_artist(stdx::optional artist) +void engine_track_impl::set_artist(std::optional artist) { return storage_->set_meta_data(id(), metadata_str_type::artist, artist); } -stdx::optional engine_track_impl::average_loudness() +std::optional engine_track_impl::average_loudness() { return get_track_data().average_loudness; } void engine_track_impl::set_average_loudness( - stdx::optional average_loudness) + std::optional average_loudness) { djinterop::util::sqlite_transaction trans{storage_->db}; auto track_d = get_track_data(); // Zero average loudness is interpreted as no average loudness. track_d.average_loudness = - average_loudness.value_or(0) == 0 ? stdx::nullopt : average_loudness; + average_loudness.value_or(0) == 0 ? std::nullopt : average_loudness; set_track_data(track_d); trans.commit(); @@ -592,27 +594,27 @@ void engine_track_impl::set_beatgrid(std::vector beatgrid) trans.commit(); } -stdx::optional engine_track_impl::bitrate() +std::optional engine_track_impl::bitrate() { return djinterop::util::optional_static_cast( - storage_->get_track_column >(id(), "bitrate")); + storage_->get_track_column >(id(), "bitrate")); } -void engine_track_impl::set_bitrate(stdx::optional bitrate) +void engine_track_impl::set_bitrate(std::optional bitrate) { storage_->set_track_column(id(), "bitrate", bitrate); } -stdx::optional engine_track_impl::bpm() +std::optional engine_track_impl::bpm() { - return storage_->get_track_column >( + return storage_->get_track_column >( id(), "bpmAnalyzed"); } -void engine_track_impl::set_bpm(stdx::optional bpm) +void engine_track_impl::set_bpm(std::optional bpm) { storage_->set_track_column(id(), "bpmAnalyzed", bpm); - stdx::optional ceiled_bpm; + std::optional ceiled_bpm; if (bpm) { ceiled_bpm = static_cast(std::ceil(*bpm)); @@ -620,22 +622,22 @@ void engine_track_impl::set_bpm(stdx::optional bpm) storage_->set_track_column(id(), "bpm", ceiled_bpm); } -stdx::optional engine_track_impl::comment() +std::optional engine_track_impl::comment() { return storage_->get_meta_data(id(), metadata_str_type::comment); } -void engine_track_impl::set_comment(stdx::optional comment) +void engine_track_impl::set_comment(std::optional comment) { storage_->set_meta_data(id(), metadata_str_type::comment, comment); } -stdx::optional engine_track_impl::composer() +std::optional engine_track_impl::composer() { return storage_->get_meta_data(id(), metadata_str_type::composer); } -void engine_track_impl::set_composer(stdx::optional composer) +void engine_track_impl::set_composer(std::optional composer) { storage_->set_meta_data(id(), metadata_str_type::composer, composer); } @@ -658,25 +660,25 @@ std::vector engine_track_impl::containing_crates() return results; } -stdx::optional engine_track_impl::duration() +std::optional engine_track_impl::duration() { auto secs = - storage_->get_track_column >(id(), "length"); + storage_->get_track_column >(id(), "length"); if (secs) { return milliseconds{*secs * 1000}; } - return stdx::nullopt; + return std::nullopt; } void engine_track_impl::set_duration( - stdx::optional duration) + std::optional duration) { djinterop::util::sqlite_transaction trans{storage_->db}; - stdx::optional secs = - duration ? stdx::make_optional(duration->count() / 1000) - : stdx::nullopt; - storage_->set_track_column >(id(), "length", secs); + std::optional secs = + duration ? std::make_optional(duration->count() / 1000) + : std::nullopt; + storage_->set_track_column >(id(), "length", secs); if (secs) { @@ -693,7 +695,7 @@ void engine_track_impl::set_duration( else { storage_->set_meta_data( - id(), metadata_str_type::duration_mm_ss, stdx::nullopt); + id(), metadata_str_type::duration_mm_ss, std::nullopt); } trans.commit(); @@ -712,23 +714,23 @@ std::string engine_track_impl::filename() return djinterop::util::get_filename(rel_path); } -stdx::optional engine_track_impl::genre() +std::optional engine_track_impl::genre() { return storage_->get_meta_data(id(), metadata_str_type::genre); } -void engine_track_impl::set_genre(stdx::optional genre) +void engine_track_impl::set_genre(std::optional genre) { storage_->set_meta_data(id(), metadata_str_type::genre, genre); } -stdx::optional engine_track_impl::hot_cue_at(int index) +std::optional engine_track_impl::hot_cue_at(int index) { auto quick_cues_d = get_quick_cues_data(); return std::move(quick_cues_d.hot_cues[index]); } -void engine_track_impl::set_hot_cue_at(int index, stdx::optional cue) +void engine_track_impl::set_hot_cue_at(int index, std::optional cue) { djinterop::util::sqlite_transaction trans{storage_->db}; auto quick_cues_d = get_quick_cues_data(); @@ -737,13 +739,13 @@ void engine_track_impl::set_hot_cue_at(int index, stdx::optional cue) trans.commit(); } -std::vector > engine_track_impl::hot_cues() +std::vector > engine_track_impl::hot_cues() { auto quick_cues_d = get_quick_cues_data(); return std::move(quick_cues_d.hot_cues); } -void engine_track_impl::set_hot_cues(std::vector > cues) +void engine_track_impl::set_hot_cues(std::vector > cues) { djinterop::util::sqlite_transaction trans{storage_->db}; // TODO (haslersn): The following can be optimized because in this case we @@ -776,9 +778,9 @@ bool engine_track_impl::is_valid() return valid; } -stdx::optional engine_track_impl::key() +std::optional engine_track_impl::key() { - stdx::optional result; + std::optional result; auto key_num = storage_->get_meta_data_integer(id(), metadata_int_type::musical_key); if (key_num) @@ -788,9 +790,9 @@ stdx::optional engine_track_impl::key() return result; } -void engine_track_impl::set_key(stdx::optional key) +void engine_track_impl::set_key(std::optional key) { - stdx::optional key_num; + std::optional key_num; if (key) { key_num = static_cast(*key); @@ -805,17 +807,17 @@ void engine_track_impl::set_key(stdx::optional key) trans.commit(); } -stdx::optional engine_track_impl::last_played_at() +std::optional engine_track_impl::last_played_at() { return djinterop::util::to_time_point(storage_->get_meta_data_integer( id(), metadata_int_type::last_played_ts)); } void engine_track_impl::set_last_played_at( - stdx::optional played_at) + std::optional played_at) { - static stdx::optional zero{"0"}; - static stdx::optional one{"1"}; + static std::optional zero{"0"}; + static std::optional one{"1"}; storage_->set_meta_data( id(), metadata_str_type::ever_played, played_at ? one : zero); storage_->set_meta_data_integer( @@ -832,13 +834,13 @@ void engine_track_impl::set_last_played_at( } } -stdx::optional engine_track_impl::loop_at(int index) +std::optional engine_track_impl::loop_at(int index) { auto loops_d = get_loops_data(); return std::move(loops_d.loops[index]); } -void engine_track_impl::set_loop_at(int index, stdx::optional l) +void engine_track_impl::set_loop_at(int index, std::optional l) { djinterop::util::sqlite_transaction trans{storage_->db}; auto loops_d = get_loops_data(); @@ -847,13 +849,13 @@ void engine_track_impl::set_loop_at(int index, stdx::optional l) trans.commit(); } -std::vector > engine_track_impl::loops() +std::vector > engine_track_impl::loops() { auto loops_d = get_loops_data(); return std::move(loops_d.loops); } -void engine_track_impl::set_loops(std::vector > loops) +void engine_track_impl::set_loops(std::vector > loops) { djinterop::util::sqlite_transaction trans{storage_->db}; loops_data loops_d; @@ -865,16 +867,16 @@ void engine_track_impl::set_loops(std::vector > loops) trans.commit(); } -stdx::optional engine_track_impl::main_cue() +std::optional engine_track_impl::main_cue() { auto cue = get_quick_cues_data().adjusted_main_cue; if (cue == 0) - return stdx::nullopt; + return std::nullopt; - return stdx::make_optional(cue); + return std::make_optional(cue); } -void engine_track_impl::set_main_cue(stdx::optional sample_offset) +void engine_track_impl::set_main_cue(std::optional sample_offset) { djinterop::util::sqlite_transaction trans{storage_->db}; auto quick_cues_d = get_quick_cues_data(); @@ -884,29 +886,29 @@ void engine_track_impl::set_main_cue(stdx::optional sample_offset) trans.commit(); } -stdx::optional engine_track_impl::publisher() +std::optional engine_track_impl::publisher() { return storage_->get_meta_data(id(), metadata_str_type::publisher); } -void engine_track_impl::set_publisher(stdx::optional publisher) +void engine_track_impl::set_publisher(std::optional publisher) { storage_->set_meta_data(id(), metadata_str_type::publisher, publisher); } -stdx::optional engine_track_impl::rating() +std::optional engine_track_impl::rating() { auto result = storage_->get_meta_data_integer(id(), metadata_int_type::rating); - return result ? stdx::make_optional(static_cast(*result)) - : stdx::nullopt; + return result ? std::make_optional(static_cast(*result)) + : std::nullopt; } -void engine_track_impl::set_rating(stdx::optional rating) +void engine_track_impl::set_rating(std::optional rating) { - auto clamped_rating = rating ? stdx::make_optional(static_cast( + auto clamped_rating = rating ? std::make_optional(static_cast( std::clamp(*rating, 0, 100))) - : stdx::nullopt; + : std::nullopt; storage_->set_meta_data_integer( id(), metadata_int_type::rating, clamped_rating); } @@ -926,14 +928,14 @@ void engine_track_impl::set_relative_path(std::string relative_path) storage_->set_meta_data(id(), metadata_str_type::file_extension, extension); } -stdx::optional engine_track_impl::sample_count() +std::optional engine_track_impl::sample_count() { return djinterop::util::optional_static_cast( get_track_data().sample_count); } void engine_track_impl::set_sample_count( - stdx::optional sample_count) + std::optional sample_count) { djinterop::util::sqlite_transaction trans{storage_->db}; @@ -943,7 +945,7 @@ void engine_track_impl::set_sample_count( auto high_res_waveform_d = get_high_res_waveform_data(); auto overview_waveform_d = get_overview_waveform_data(); - stdx::optional secs; + std::optional secs; if (sample_count && track_d.sample_rate && *track_d.sample_rate != 0) { secs = *sample_count / static_cast(*track_d.sample_rate); @@ -974,12 +976,12 @@ void engine_track_impl::set_sample_count( trans.commit(); } -stdx::optional engine_track_impl::sample_rate() +std::optional engine_track_impl::sample_rate() { return get_track_data().sample_rate; } -void engine_track_impl::set_sample_rate(stdx::optional sample_rate) +void engine_track_impl::set_sample_rate(std::optional sample_rate) { djinterop::util::sqlite_transaction trans{storage_->db}; @@ -989,7 +991,7 @@ void engine_track_impl::set_sample_rate(stdx::optional sample_rate) auto high_res_waveform_d = get_high_res_waveform_data(); auto overview_waveform_d = get_overview_waveform_data(); - stdx::optional secs; + std::optional secs; if (track_d.sample_count && sample_rate && *sample_rate != 0) { secs = *track_d.sample_count / static_cast(*sample_rate); @@ -1030,23 +1032,23 @@ void engine_track_impl::set_sample_rate(stdx::optional sample_rate) trans.commit(); } -stdx::optional engine_track_impl::title() +std::optional engine_track_impl::title() { return storage_->get_meta_data(id(), metadata_str_type::title); } -void engine_track_impl::set_title(stdx::optional title) +void engine_track_impl::set_title(std::optional title) { storage_->set_meta_data(id(), metadata_str_type::title, title); } -stdx::optional engine_track_impl::track_number() +std::optional engine_track_impl::track_number() { - return storage_->get_track_column >( + return storage_->get_track_column >( id(), "playOrder"); } -void engine_track_impl::set_track_number(stdx::optional track_number) +void engine_track_impl::set_track_number(std::optional track_number) { storage_->set_track_column(id(), "playOrder", track_number); } @@ -1100,12 +1102,12 @@ void engine_track_impl::set_waveform(std::vector waveform) trans.commit(); } -stdx::optional engine_track_impl::year() +std::optional engine_track_impl::year() { - return storage_->get_track_column >(id(), "year"); + return storage_->get_track_column >(id(), "year"); } -void engine_track_impl::set_year(stdx::optional year) +void engine_track_impl::set_year(std::optional year) { storage_->set_track_column(id(), "year", year); } @@ -1128,18 +1130,18 @@ track create_track( auto extension = djinterop::util::get_file_extension(filename); auto track_number = snapshot.track_number - ? stdx::make_optional(static_cast(*snapshot.track_number)) - : stdx::nullopt; + ? std::make_optional(static_cast(*snapshot.track_number)) + : std::nullopt; auto year = snapshot.year - ? stdx::make_optional(static_cast(*snapshot.year)) - : stdx::nullopt; + ? std::make_optional(static_cast(*snapshot.year)) + : std::nullopt; auto timestamp_fields = to_timestamp_fields(snapshot.last_played_at); auto key_num = to_key_num(snapshot.key); auto clamped_rating = snapshot.rating - ? stdx::make_optional(static_cast( + ? std::make_optional(static_cast( std::clamp(*snapshot.rating, 0, 100))) - : stdx::nullopt; - stdx::optional last_play_hash; + : std::nullopt; + std::optional last_play_hash; auto track_data = to_track_data( snapshot.sample_count, snapshot.sample_rate, snapshot.average_loudness, snapshot.key); diff --git a/src/djinterop/engine/v1/engine_track_impl.hpp b/src/djinterop/engine/v1/engine_track_impl.hpp index 33ba66d..192bde5 100644 --- a/src/djinterop/engine/v1/engine_track_impl.hpp +++ b/src/djinterop/engine/v1/engine_track_impl.hpp @@ -19,14 +19,10 @@ #include #include -#include +#include #include #include -#include -#include -#include - #include "../../impl/track_impl.hpp" #include "engine_storage.hpp" #include "performance_data_format.hpp" @@ -62,66 +58,66 @@ class engine_track_impl : public djinterop::track_impl void update(const track_snapshot& snapshot) override; - stdx::optional album() override; - void set_album(stdx::optional album) override; - stdx::optional artist() override; - void set_artist(stdx::optional artist) override; - stdx::optional average_loudness() override; - void set_average_loudness(stdx::optional average_loudness) override; + std::optional album() override; + void set_album(std::optional album) override; + std::optional artist() override; + void set_artist(std::optional artist) override; + std::optional average_loudness() override; + void set_average_loudness(std::optional average_loudness) override; std::vector beatgrid() override; void set_beatgrid(std::vector beatgrid) override; - stdx::optional bitrate() override; - void set_bitrate(stdx::optional bitrate) override; - stdx::optional bpm() override; - void set_bpm(stdx::optional bpm) override; - stdx::optional comment() override; - void set_comment(stdx::optional comment) override; - stdx::optional composer() override; - void set_composer(stdx::optional composer) override; + std::optional bitrate() override; + void set_bitrate(std::optional bitrate) override; + std::optional bpm() override; + void set_bpm(std::optional bpm) override; + std::optional comment() override; + void set_comment(std::optional comment) override; + std::optional composer() override; + void set_composer(std::optional composer) override; std::vector containing_crates() override; database db() override; - stdx::optional duration() override; - void set_duration(stdx::optional duration) override; + std::optional duration() override; + void set_duration(std::optional duration) override; std::string file_extension() override; std::string filename() override; - stdx::optional genre() override; - void set_genre(stdx::optional genre) override; - stdx::optional hot_cue_at(int index) override; - void set_hot_cue_at(int index, stdx::optional cue) override; - std::vector > hot_cues() override; - void set_hot_cues(std::vector > cues) override; + std::optional genre() override; + void set_genre(std::optional genre) override; + std::optional hot_cue_at(int index) override; + void set_hot_cue_at(int index, std::optional cue) override; + std::vector > hot_cues() override; + void set_hot_cues(std::vector > cues) override; bool is_valid() override; - stdx::optional key() override; - void set_key(stdx::optional key) override; - stdx::optional last_played_at() + std::optional key() override; + void set_key(std::optional key) override; + std::optional last_played_at() override; void set_last_played_at( - stdx::optional played_at) + std::optional played_at) override; - stdx::optional loop_at(int index) override; - void set_loop_at(int index, stdx::optional l) override; - std::vector > loops() override; - void set_loops(std::vector > loops) override; - stdx::optional main_cue() override; - void set_main_cue(stdx::optional sample_offset) override; - stdx::optional publisher() override; - void set_publisher(stdx::optional publisher) override; - stdx::optional rating() override; - void set_rating(stdx::optional rating) override; + std::optional loop_at(int index) override; + void set_loop_at(int index, std::optional l) override; + std::vector > loops() override; + void set_loops(std::vector > loops) override; + std::optional main_cue() override; + void set_main_cue(std::optional sample_offset) override; + std::optional publisher() override; + void set_publisher(std::optional publisher) override; + std::optional rating() override; + void set_rating(std::optional rating) override; std::string relative_path() override; void set_relative_path(std::string relative_path) override; - stdx::optional sample_count() override; - void set_sample_count(stdx::optional sample_count) override; - stdx::optional sample_rate() override; - void set_sample_rate(stdx::optional sample_rate) override; - stdx::optional title() override; - void set_title(stdx::optional title) override; - stdx::optional track_number() override; - void set_track_number(stdx::optional track_number) override; + std::optional sample_count() override; + void set_sample_count(std::optional sample_count) override; + std::optional sample_rate() override; + void set_sample_rate(std::optional sample_rate) override; + std::optional title() override; + void set_title(std::optional title) override; + std::optional track_number() override; + void set_track_number(std::optional track_number) override; std::vector waveform() override; void set_waveform(std::vector waveform) override; - stdx::optional year() override; - void set_year(stdx::optional year) override; + std::optional year() override; + void set_year(std::optional year) override; private: std::shared_ptr storage_; diff --git a/src/djinterop/engine/v1/performance_data_format.cpp b/src/djinterop/engine/v1/performance_data_format.cpp index fdfe973..3cace7b 100644 --- a/src/djinterop/engine/v1/performance_data_format.cpp +++ b/src/djinterop/engine/v1/performance_data_format.cpp @@ -17,10 +17,10 @@ #include #include +#include #include #include -#include #include "../../util/convert.hpp" #include "djinterop/engine/encode_decode_utils.hpp" @@ -31,18 +31,18 @@ namespace djinterop::engine::v1 namespace { template -stdx::optional > prohibit(const U& sentinel, T&& data) +std::optional > prohibit(const U& sentinel, T&& data) { if (data == sentinel) { - return stdx::nullopt; + return std::nullopt; } - return stdx::make_optional(std::forward(data)); + return std::make_optional(std::forward(data)); } std::byte* encode_beatgrid(const std::vector& beatgrid, std::byte* ptr) { - typedef std::vector::size_type vec_size_t; + using vec_size_t = std::vector::size_type; ptr = encode_int64_be(beatgrid.size(), ptr); for (vec_size_t i = 0; i < beatgrid.size(); ++i) { @@ -84,7 +84,7 @@ std::pair, const std::byte*> decode_beatgrid( } std::vector result(count); int32_t beats_until_next_marker = 0; - typedef std::vector::size_type vec_size_t; + using vec_size_t = std::vector::size_type; for (vec_size_t i = 0; i < result.size(); ++i) { std::tie(result[i].sample_offset, ptr) = decode_double_le(ptr); @@ -166,9 +166,9 @@ beat_data beat_data::decode(const std::vector& compressed_data) std::tie(sample_rate, ptr) = decode_double_be(ptr); std::tie(sample_count, ptr) = decode_double_be(ptr); result.sample_rate = - sample_rate != 0 ? stdx::make_optional(sample_rate) : stdx::nullopt; + sample_rate != 0 ? std::make_optional(sample_rate) : std::nullopt; result.sample_count = - sample_count != 0 ? stdx::make_optional(sample_count) : stdx::nullopt; + sample_count != 0 ? std::make_optional(sample_count) : std::nullopt; uint8_t is_beat_data_set; std::tie(is_beat_data_set, ptr) = decode_uint8(ptr); @@ -325,7 +325,7 @@ std::vector loops_data::encode() const { auto total_label_length = std::accumulate( loops.begin(), loops.end(), int64_t{0}, - [](int64_t x, const stdx::optional& loop) { + [](int64_t x, const std::optional& loop) { return x + (loop ? loop->label.length() : 0); }); @@ -429,7 +429,7 @@ loops_data loops_data::decode(const std::vector& raw_data) if (loop.start_sample_offset != -1) result.loops.emplace_back(loop); else - result.loops.emplace_back(stdx::nullopt); + result.loops.emplace_back(std::nullopt); } if (ptr != end) @@ -541,7 +541,7 @@ std::vector quick_cues_data::encode() const { auto total_label_length = std::accumulate( hot_cues.begin(), hot_cues.end(), int64_t{0}, - [](int64_t x, const stdx::optional& hot_cue) { + [](int64_t x, const std::optional& hot_cue) { return x + (hot_cue ? hot_cue->label.length() : 0); }); @@ -642,7 +642,7 @@ quick_cues_data quick_cues_data::decode( if (quick_cue.sample_offset != -1) result.hot_cues.emplace_back(quick_cue); else - result.hot_cues.emplace_back(stdx::nullopt); + result.hot_cues.emplace_back(std::nullopt); } std::tie(result.adjusted_main_cue, ptr) = decode_double_be(ptr); @@ -708,9 +708,9 @@ track_data track_data::decode(const std::vector& compressed_track_dat std::tie(sample_rate, ptr) = decode_double_be(ptr); std::tie(sample_count, ptr) = decode_int64_be(ptr); result.sample_rate = - sample_rate != 0 ? stdx::make_optional(sample_rate) : stdx::nullopt; + sample_rate != 0 ? std::make_optional(sample_rate) : std::nullopt; result.sample_count = - sample_count != 0 ? stdx::make_optional(sample_count) : stdx::nullopt; + sample_count != 0 ? std::make_optional(sample_count) : std::nullopt; double raw_average_loudness; std::tie(raw_average_loudness, ptr) = decode_double_be(ptr); diff --git a/src/djinterop/engine/v1/performance_data_format.hpp b/src/djinterop/engine/v1/performance_data_format.hpp index 3328b51..888e4f9 100644 --- a/src/djinterop/engine/v1/performance_data_format.hpp +++ b/src/djinterop/engine/v1/performance_data_format.hpp @@ -19,9 +19,9 @@ #include #include +#include #include -#include #include namespace djinterop @@ -32,13 +32,11 @@ namespace engine::v1 { struct beat_data { - stdx::optional sample_rate; - stdx::optional sample_count; + std::optional sample_rate; + std::optional sample_count; std::vector default_beatgrid; std::vector adjusted_beatgrid; - beat_data() noexcept = default; - friend bool operator==( const beat_data& first, const beat_data& second) noexcept { @@ -57,8 +55,6 @@ struct high_res_waveform_data double samples_per_entry; std::vector waveform; - high_res_waveform_data() noexcept = default; - friend bool operator==( const high_res_waveform_data& first, const high_res_waveform_data& second) noexcept @@ -74,9 +70,7 @@ struct high_res_waveform_data struct loops_data { - std::vector > loops; - - loops_data() noexcept = default; + std::vector > loops; friend bool operator==( const loops_data& first, const loops_data& second) noexcept @@ -94,8 +88,6 @@ struct overview_waveform_data double samples_per_entry; std::vector waveform; - overview_waveform_data() noexcept = default; - friend bool operator==( const overview_waveform_data& first, const overview_waveform_data& second) noexcept @@ -111,12 +103,10 @@ struct overview_waveform_data struct quick_cues_data { - std::vector > hot_cues; + std::vector > hot_cues; double adjusted_main_cue = 0; double default_main_cue = 0; - quick_cues_data() noexcept = default; - friend bool operator==( const quick_cues_data& first, const quick_cues_data& second) noexcept { @@ -131,12 +121,10 @@ struct quick_cues_data struct track_data { - stdx::optional sample_rate; - stdx::optional sample_count; - stdx::optional average_loudness; // range (0, 1] - stdx::optional key; - - track_data() noexcept = default; + std::optional sample_rate; + std::optional sample_count; + std::optional average_loudness; // range (0, 1] + std::optional key; friend bool operator==( const track_data& first, const track_data& second) noexcept diff --git a/src/djinterop/engine/v2/change_log_table.cpp b/src/djinterop/engine/v2/change_log_table.cpp index 36e2893..e6a66c1 100644 --- a/src/djinterop/engine/v2/change_log_table.cpp +++ b/src/djinterop/engine/v2/change_log_table.cpp @@ -65,9 +65,9 @@ std::vector change_log_table::after(int64_t id) const return results; } -djinterop::stdx::optional change_log_table::last() const +std::optional change_log_table::last() const { - djinterop::stdx::optional result; + std::optional result; context_->db << "SELECT id, trackId FROM ChangeLog ORDER BY id DESC LIMIT 1" >> [&](int64_t id, int64_t track_id) diff --git a/src/djinterop/engine/v2/convert_beatgrid.hpp b/src/djinterop/engine/v2/convert_beatgrid.hpp index 9f458f8..41c906e 100644 --- a/src/djinterop/engine/v2/convert_beatgrid.hpp +++ b/src/djinterop/engine/v2/convert_beatgrid.hpp @@ -21,7 +21,6 @@ #include #include -#include #include namespace djinterop::engine::v2::convert diff --git a/src/djinterop/engine/v2/convert_hot_cues.hpp b/src/djinterop/engine/v2/convert_hot_cues.hpp index f0c1024..b72b66a 100644 --- a/src/djinterop/engine/v2/convert_hot_cues.hpp +++ b/src/djinterop/engine/v2/convert_hot_cues.hpp @@ -17,32 +17,29 @@ #pragma once -#include -#include #include #include -#include #include namespace djinterop::engine::v2::convert { namespace read { -inline stdx::optional hot_cue( +inline std::optional hot_cue( const quick_cue_blob& quick_cue) { return quick_cue.sample_offset == QUICK_CUE_SAMPLE_OFFSET_EMPTY - ? stdx::nullopt - : stdx::make_optional(djinterop::hot_cue{ + ? std::nullopt + : std::make_optional(djinterop::hot_cue{ quick_cue.label, quick_cue.sample_offset, quick_cue.color}); } -inline std::vector> hot_cues( +inline std::vector> hot_cues( const quick_cues_blob& quick_cues) { - std::vector> converted; + std::vector> converted; converted.reserve(quick_cues.quick_cues.size()); for (auto&& c : quick_cues.quick_cues) converted.push_back(hot_cue(c)); @@ -50,15 +47,15 @@ inline std::vector> hot_cues( return converted; } -inline stdx::optional main_cue(double main_cue) +inline std::optional main_cue(double main_cue) { - return main_cue != 0 ? stdx::make_optional(main_cue) : stdx::nullopt; + return main_cue != 0 ? std::make_optional(main_cue) : std::nullopt; } } // namespace read namespace write { -inline quick_cue_blob hot_cue(const stdx::optional& hot_cue) +inline quick_cue_blob hot_cue(const std::optional& hot_cue) { if (!hot_cue) return quick_cue_blob::empty(); @@ -68,7 +65,7 @@ inline quick_cue_blob hot_cue(const stdx::optional& hot_cue) } inline std::vector hot_cues( - const std::vector>& cues) + const std::vector>& cues) { if (cues.size() > MAX_QUICK_CUES) throw djinterop::hot_cues_overflow{ @@ -88,7 +85,7 @@ inline std::vector hot_cues( return converted; } -inline double main_cue(stdx::optional main_cue) +inline double main_cue(std::optional main_cue) { return main_cue.value_or(0); } diff --git a/src/djinterop/engine/v2/convert_loops.hpp b/src/djinterop/engine/v2/convert_loops.hpp index 3022e65..da0fe97 100644 --- a/src/djinterop/engine/v2/convert_loops.hpp +++ b/src/djinterop/engine/v2/convert_loops.hpp @@ -17,30 +17,28 @@ #pragma once -#include -#include +#include #include -#include #include namespace djinterop::engine::v2::convert { namespace read { -inline stdx::optional loop(const loop_blob& l) +inline std::optional loop(const loop_blob& l) { return (l.is_start_set || l.is_end_set) - ? stdx::make_optional(djinterop::loop{ + ? std::make_optional(djinterop::loop{ l.label, l.start_sample_offset, l.end_sample_offset, l.color}) - : stdx::nullopt; + : std::nullopt; } -inline std::vector> loops( +inline std::vector> loops( const loops_blob& loops) { - std::vector> converted; + std::vector> converted; converted.reserve(loops.loops.size()); for (auto&& l : loops.loops) converted.push_back(loop(l)); @@ -51,7 +49,7 @@ inline std::vector> loops( namespace write { -inline loop_blob loop(stdx::optional loop) +inline loop_blob loop(std::optional loop) { if (!loop) return loop_blob::empty(); @@ -65,7 +63,7 @@ inline loop_blob loop(stdx::optional loop) } inline loops_blob loops( - const std::vector>& loops) + const std::vector>& loops) { if (loops.size() > MAX_LOOPS) throw djinterop::loops_overflow{ diff --git a/src/djinterop/engine/v2/convert_track.hpp b/src/djinterop/engine/v2/convert_track.hpp index daebef7..cb87d4c 100644 --- a/src/djinterop/engine/v2/convert_track.hpp +++ b/src/djinterop/engine/v2/convert_track.hpp @@ -19,10 +19,9 @@ #include #include +#include #include -#include -#include #include "../../util/convert.hpp" @@ -30,26 +29,26 @@ namespace djinterop::engine::v2::convert { namespace read { -inline stdx::optional album_art_id(int64_t album_art_id) +inline std::optional album_art_id(int64_t album_art_id) { if (album_art_id == ALBUM_ART_ID_NONE) { - return stdx::nullopt; + return std::nullopt; } - return stdx::make_optional(album_art_id); + return std::make_optional(album_art_id); } -inline stdx::optional average_loudness( +inline std::optional average_loudness( const track_data_blob& track_data) { return track_data.average_loudness_low != 0 - ? stdx::make_optional(track_data.average_loudness_low) - : stdx::nullopt; + ? std::make_optional(track_data.average_loudness_low) + : std::nullopt; } -inline stdx::optional bpm( - stdx::optional bpm_analyzed, stdx::optional bpm) +inline std::optional bpm( + std::optional bpm_analyzed, std::optional bpm) { // Prefer the analysed BPM on account of typically being more accurate, if // it is available. @@ -61,68 +60,68 @@ inline stdx::optional bpm( return djinterop::util::optional_static_cast(bpm); } -inline stdx::optional duration(int64_t length) +inline std::optional duration(int64_t length) { if (length == 0) - return stdx::nullopt; + return std::nullopt; return std::chrono::milliseconds{length * 1000}; } -inline stdx::optional key(stdx::optional key) +inline std::optional key(std::optional key) { return djinterop::util::optional_static_cast(key); } -inline stdx::optional rating(int64_t rating) +inline std::optional rating(int64_t rating) { if (rating == RATING_NONE) { - return stdx::nullopt; + return std::nullopt; } - return stdx::make_optional(static_cast(rating)); + return std::make_optional(static_cast(rating)); } -inline stdx::optional sample_count( +inline std::optional sample_count( const track_data_blob& track_data) { if (track_data.samples == 0) { - return stdx::nullopt; + return std::nullopt; } - return stdx::make_optional( + return std::make_optional( static_cast(track_data.samples)); } -inline stdx::optional sample_rate(const track_data_blob& track_data) +inline std::optional sample_rate(const track_data_blob& track_data) { return track_data.sample_rate != 0 - ? stdx::make_optional(track_data.sample_rate) - : stdx::nullopt; + ? std::make_optional(track_data.sample_rate) + : std::nullopt; } } // namespace read namespace write { -inline int64_t album_art_id(stdx::optional album_art_id) +inline int64_t album_art_id(std::optional album_art_id) { return album_art_id.value_or(ALBUM_ART_ID_NONE); } -inline double average_loudness(stdx::optional average_loudness) +inline double average_loudness(std::optional average_loudness) { return average_loudness.value_or(0); } struct converted_bpm_fields { - stdx::optional bpm_analyzed; - stdx::optional bpm; + std::optional bpm_analyzed; + std::optional bpm; }; -inline converted_bpm_fields bpm(stdx::optional bpm) +inline converted_bpm_fields bpm(std::optional bpm) { // Deliberate choice to override the BPM as determined by analysis. This // results in the 'least astonishment' for a caller if they set then get the @@ -130,32 +129,31 @@ inline converted_bpm_fields bpm(stdx::optional bpm) return {bpm, djinterop::util::optional_static_cast(bpm)}; } -inline int64_t duration(stdx::optional duration) +inline int64_t duration(std::optional duration) { return duration.value_or(std::chrono::milliseconds{}).count() / 1000; } struct converted_key_fields { - stdx::optional key; + std::optional key; int32_t track_data_key; }; -inline converted_key_fields key(stdx::optional key) +inline converted_key_fields key(std::optional key) { if (key) { auto converted = static_cast(*key); - return {stdx::make_optional(converted), converted}; + return {std::make_optional(converted), converted}; } - return {stdx::nullopt, 0}; + return {std::nullopt, 0}; } -inline int64_t rating(stdx::optional rating) +inline int64_t rating(std::optional rating) { - return static_cast( - std::clamp(rating.value_or(RATING_NONE), 0, 100)); + return std::clamp(rating.value_or(RATING_NONE), 0, 100); } struct converted_sample_count_fields @@ -165,13 +163,13 @@ struct converted_sample_count_fields }; inline converted_sample_count_fields sample_count( - const stdx::optional& sample_count) + const std::optional& sample_count) { auto s = sample_count.value_or(0); return {static_cast(s), (double)s}; } -inline double sample_rate(const stdx::optional& sample_rate) +inline double sample_rate(const std::optional& sample_rate) { return sample_rate.value_or(0); } diff --git a/src/djinterop/engine/v2/convert_waveform.hpp b/src/djinterop/engine/v2/convert_waveform.hpp index 536b97d..2bccbe4 100644 --- a/src/djinterop/engine/v2/convert_waveform.hpp +++ b/src/djinterop/engine/v2/convert_waveform.hpp @@ -18,10 +18,10 @@ #pragma once #include +#include #include #include -#include #include #include "../track_utils.hpp" @@ -62,8 +62,8 @@ inline overview_waveform_point waveform_entry( inline overview_waveform_data_blob waveform( const std::vector& w, - stdx::optional sample_count, - stdx::optional sample_rate) + std::optional sample_count, + std::optional sample_rate) { overview_waveform_data_blob result; if (w.empty()) diff --git a/src/djinterop/engine/v2/crate_impl.cpp b/src/djinterop/engine/v2/crate_impl.cpp index c95d443..2ad1e91 100644 --- a/src/djinterop/engine/v2/crate_impl.cpp +++ b/src/djinterop/engine/v2/crate_impl.cpp @@ -160,16 +160,16 @@ std::string crate_impl::name() return row->title; } -stdx::optional crate_impl::parent() +std::optional crate_impl::parent() { auto row = playlist_.get(id()); if (row->parent_list_id == PARENT_LIST_ID_NONE) { - return stdx::nullopt; + return std::nullopt; } auto impl = std::make_shared(library_, row->parent_list_id); - return stdx::make_optional(crate{impl}); + return std::make_optional(crate{impl}); } void crate_impl::remove_track(track tr) @@ -189,7 +189,7 @@ void crate_impl::set_name(std::string name) playlist_.update(*row); } -void crate_impl::set_parent(stdx::optional parent) +void crate_impl::set_parent(std::optional parent) { if (parent && parent->id() == id()) { @@ -206,16 +206,16 @@ void crate_impl::set_parent(stdx::optional parent) playlist_.update(*row); } -stdx::optional crate_impl::sub_crate_by_name(const std::string& name) +std::optional crate_impl::sub_crate_by_name(const std::string& name) { auto id_maybe = library_->playlist().find_id(id(), name); if (!id_maybe) { - return stdx::nullopt; + return std::nullopt; } auto impl = std::make_shared(library_, *id_maybe); - return stdx::make_optional(crate{impl}); + return std::make_optional(crate{impl}); } std::vector crate_impl::tracks() diff --git a/src/djinterop/engine/v2/crate_impl.hpp b/src/djinterop/engine/v2/crate_impl.hpp index 03e90db..92c72e0 100644 --- a/src/djinterop/engine/v2/crate_impl.hpp +++ b/src/djinterop/engine/v2/crate_impl.hpp @@ -48,11 +48,11 @@ class crate_impl : public djinterop::crate_impl std::vector descendants() override; bool is_valid() override; std::string name() override; - stdx::optional parent() override; + std::optional parent() override; void remove_track(track tr) override; void set_name(std::string name) override; - void set_parent(stdx::optional parent) override; - stdx::optional sub_crate_by_name(const std::string& name) override; + void set_parent(std::optional parent) override; + std::optional sub_crate_by_name(const std::string& name) override; std::vector tracks() override; private: diff --git a/src/djinterop/engine/v2/database_impl.cpp b/src/djinterop/engine/v2/database_impl.cpp index c2dca51..6a3a8b1 100644 --- a/src/djinterop/engine/v2/database_impl.cpp +++ b/src/djinterop/engine/v2/database_impl.cpp @@ -31,16 +31,16 @@ database_impl::database_impl(std::shared_ptr library) : { } -stdx::optional database_impl::crate_by_id(int64_t id) +std::optional database_impl::crate_by_id(int64_t id) { auto exists = library_->playlist().exists(id); if (!exists) { - return stdx::nullopt; + return std::nullopt; } auto impl = std::make_shared(library_, id); - return stdx::make_optional(crate{impl}); + return std::make_optional(crate{impl}); } std::vector database_impl::crates() @@ -162,28 +162,28 @@ std::vector database_impl::root_crates() return results; } -stdx::optional database_impl::root_crate_by_name(const std::string& name) +std::optional database_impl::root_crate_by_name(const std::string& name) { auto id_maybe = library_->playlist().find_root_id(name); if (!id_maybe) { - return stdx::nullopt; + return std::nullopt; } auto impl = std::make_shared(library_, *id_maybe); - return stdx::make_optional(crate{impl}); + return std::make_optional(crate{impl}); } -stdx::optional database_impl::track_by_id(int64_t id) +std::optional database_impl::track_by_id(int64_t id) { auto track_table = library_->track(); if (track_table.exists(id)) { auto impl = std::make_shared(library_, id); - return stdx::make_optional(track{impl}); + return std::make_optional(track{impl}); } - return stdx::nullopt; + return std::nullopt; } std::vector database_impl::tracks() diff --git a/src/djinterop/engine/v2/database_impl.hpp b/src/djinterop/engine/v2/database_impl.hpp index e02a656..50278aa 100644 --- a/src/djinterop/engine/v2/database_impl.hpp +++ b/src/djinterop/engine/v2/database_impl.hpp @@ -32,7 +32,7 @@ class database_impl : public djinterop::database_impl public: explicit database_impl(std::shared_ptr library); - stdx::optional crate_by_id(int64_t id) override; + std::optional crate_by_id(int64_t id) override; std::vector crates() override; std::vector crates_by_name( const std::string& name) override; @@ -45,9 +45,9 @@ class database_impl : public djinterop::database_impl void remove_crate(djinterop::crate cr) override; void remove_track(djinterop::track tr) override; std::vector root_crates() override; - stdx::optional root_crate_by_name( + std::optional root_crate_by_name( const std::string& name) override; - stdx::optional track_by_id(int64_t id) override; + std::optional track_by_id(int64_t id) override; std::vector tracks() override; std::vector tracks_by_relative_path( const std::string& relative_path) override; diff --git a/src/djinterop/engine/v2/information_table.cpp b/src/djinterop/engine/v2/information_table.cpp index be2439e..c2c21a9 100644 --- a/src/djinterop/engine/v2/information_table.cpp +++ b/src/djinterop/engine/v2/information_table.cpp @@ -18,11 +18,10 @@ #include #include +#include #include #include -#include - #include "engine_library_context.hpp" namespace djinterop::engine::v2 @@ -36,7 +35,7 @@ information_table::information_table( information_row information_table::get() const { - djinterop::stdx::optional result; + std::optional result; context_->db << "SELECT id, uuid, schemaVersionMajor, schemaVersionMinor, " "schemaVersionPatch, currentPlayedIndiciator, " "lastRekordBoxLibraryImportReadCounter FROM Information" >> diff --git a/src/djinterop/engine/v2/loops_blob.cpp b/src/djinterop/engine/v2/loops_blob.cpp index 93aa05d..d872acd 100644 --- a/src/djinterop/engine/v2/loops_blob.cpp +++ b/src/djinterop/engine/v2/loops_blob.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include "../encode_decode_utils.hpp" @@ -29,7 +30,7 @@ std::vector loops_blob::to_blob() const { auto total_label_length = std::accumulate( loops.begin(), loops.end(), int64_t{0}, - [](int64_t x, const stdx::optional& loop) + [](int64_t x, const std::optional& loop) { return x + (loop ? loop->label.length() : 0); }); std::vector uncompressed( diff --git a/src/djinterop/engine/v2/playlist_entity_table.cpp b/src/djinterop/engine/v2/playlist_entity_table.cpp index abe56bc..ad5c974 100644 --- a/src/djinterop/engine/v2/playlist_entity_table.cpp +++ b/src/djinterop/engine/v2/playlist_entity_table.cpp @@ -43,7 +43,7 @@ int64_t playlist_entity_table::add_back( "playlist entity, and so it cannot be created again"}; } - djinterop::stdx::optional existing_id; + std::optional existing_id; context_->db << "SELECT id FROM PlaylistEntity WHERE listId = ? AND " "trackId = ? AND databaseUuid = ?" << row.list_id << row.track_id << row.database_uuid >> @@ -89,10 +89,10 @@ void playlist_entity_table::clear(int64_t list_id) context_->db << "DELETE FROM PlaylistEntity WHERE listId = ?" << list_id; } -djinterop::stdx::optional playlist_entity_table::get( +std::optional playlist_entity_table::get( int64_t list_id, int64_t track_id) const { - djinterop::stdx::optional result; + std::optional result; context_->db << "SELECT id, listId, trackId, databaseUuid, nextEntityId, " "membershipReference FROM PlaylistEntity WHERE listId = ? " "AND trackId = ?" diff --git a/src/djinterop/engine/v2/playlist_table.cpp b/src/djinterop/engine/v2/playlist_table.cpp index c9fda15..8540177 100644 --- a/src/djinterop/engine/v2/playlist_table.cpp +++ b/src/djinterop/engine/v2/playlist_table.cpp @@ -142,10 +142,10 @@ std::vector playlist_table::find_ids(const std::string& title) const return results; } -stdx::optional playlist_table::find_id( +std::optional playlist_table::find_id( int64_t parent_id, const std::string& title) const { - stdx::optional result; + std::optional result; context_->db << "SELECT id FROM Playlist WHERE title = ? AND parentListId = ?" << title << parent_id >> @@ -158,10 +158,10 @@ stdx::optional playlist_table::find_id( return result; } -stdx::optional playlist_table::find_root_id( +std::optional playlist_table::find_root_id( const std::string& title) const { - stdx::optional result; + std::optional result; context_->db << "SELECT id FROM Playlist WHERE title = ? AND parentListId = 0" << title >> @@ -174,9 +174,9 @@ stdx::optional playlist_table::find_root_id( return result; } -djinterop::stdx::optional playlist_table::get(int64_t id) const +std::optional playlist_table::get(int64_t id) const { - djinterop::stdx::optional result; + std::optional result; context_->db << "SELECT id, title, parentListId, isPersisted, nextListId, " "lastEditTime, isExplicitlyExported " "FROM Playlist WHERE id = ?" diff --git a/src/djinterop/engine/v2/track_impl.cpp b/src/djinterop/engine/v2/track_impl.cpp index cfebf7d..3cc5e3a 100644 --- a/src/djinterop/engine/v2/track_impl.cpp +++ b/src/djinterop/engine/v2/track_impl.cpp @@ -52,9 +52,9 @@ track_row snapshot_to_row( } auto filename = djinterop::util::get_filename(*snapshot.relative_path); - stdx::optional remixer; + std::optional remixer; auto rating = convert::write::rating(snapshot.rating); - stdx::optional album_art; + std::optional album_art; bool is_played = false; bool is_analyzed = true; @@ -73,11 +73,11 @@ track_row snapshot_to_row( bool is_available = true; bool is_metadata_of_packed_track_changed = false; bool is_performance_data_of_packed_track_changed = false; - stdx::optional played_indicator; + std::optional played_indicator; bool is_metadata_imported = true; int64_t pdb_import_key = 0; - stdx::optional streaming_source; - stdx::optional uri; + std::optional streaming_source; + std::optional uri; bool is_beat_grid_locked = false; std::string origin_database_uuid = information.uuid; int64_t origin_track_id = 0; @@ -121,7 +121,7 @@ track_row snapshot_to_row( loops_blob loops = convert::write::loops(snapshot.loops); - stdx::optional third_party_source_id; + std::optional third_party_source_id; int64_t streaming_flags = 0; bool explicit_lyrics = false; int64_t active_on_load_loops = 0; @@ -244,33 +244,33 @@ void track_impl::update(const track_snapshot& snapshot) track_.update(row); } -stdx::optional track_impl::album() +std::optional track_impl::album() { return track_.get_album(id()); } -void track_impl::set_album(stdx::optional album) +void track_impl::set_album(std::optional album) { track_.set_album(id(), album); } -stdx::optional track_impl::artist() +std::optional track_impl::artist() { return track_.get_artist(id()); } -void track_impl::set_artist(stdx::optional artist) +void track_impl::set_artist(std::optional artist) { track_.set_artist(id(), artist); } -stdx::optional track_impl::average_loudness() +std::optional track_impl::average_loudness() { auto track_data = track_.get_track_data(id()); return convert::read::average_loudness(track_data); } -void track_impl::set_average_loudness(stdx::optional average_loudness) +void track_impl::set_average_loudness(std::optional average_loudness) { auto track_data = track_.get_track_data(id()); auto converted = convert::write::average_loudness(average_loudness); @@ -298,46 +298,46 @@ void track_impl::set_beatgrid(std::vector beatgrid) track_.set_beat_data(id(), beat_data); } -stdx::optional track_impl::bitrate() +std::optional track_impl::bitrate() { return djinterop::util::optional_static_cast(track_.get_bitrate(id())); } -void track_impl::set_bitrate(stdx::optional bitrate) +void track_impl::set_bitrate(std::optional bitrate) { track_.set_bitrate( id(), djinterop::util::optional_static_cast(bitrate)); } -stdx::optional track_impl::bpm() +std::optional track_impl::bpm() { return convert::read::bpm( track_.get_bpm_analyzed(id()), track_.get_bpm(id())); } -void track_impl::set_bpm(stdx::optional bpm) +void track_impl::set_bpm(std::optional bpm) { auto fields = convert::write::bpm(bpm); track_.set_bpm_analyzed(id(), fields.bpm_analyzed); track_.set_bpm(id(), fields.bpm); } -stdx::optional track_impl::comment() +std::optional track_impl::comment() { return track_.get_comment(id()); } -void track_impl::set_comment(stdx::optional comment) +void track_impl::set_comment(std::optional comment) { track_.set_comment(id(), comment); } -stdx::optional track_impl::composer() +std::optional track_impl::composer() { return track_.get_composer(id()); } -void track_impl::set_composer(stdx::optional composer) +void track_impl::set_composer(std::optional composer) { track_.set_composer(id(), composer); } @@ -353,14 +353,14 @@ std::vector track_impl::containing_crates() throw std::runtime_error{"containing_crates() - Not yet implemented"}; } -stdx::optional track_impl::duration() +std::optional track_impl::duration() { auto length = track_.get_length(id()); return convert::read::duration(length); } void track_impl::set_duration( - stdx::optional duration) + std::optional duration) { track_.set_length(id(), convert::write::duration(duration)); } @@ -378,17 +378,17 @@ std::string track_impl::filename() return djinterop::util::get_filename(rel_path); } -stdx::optional track_impl::genre() +std::optional track_impl::genre() { return track_.get_genre(id()); } -void track_impl::set_genre(stdx::optional genre) +void track_impl::set_genre(std::optional genre) { track_.set_genre(id(), genre); } -stdx::optional track_impl::hot_cue_at(int index) +std::optional track_impl::hot_cue_at(int index) { auto quick_cues = track_.get_quick_cues(id()); if (index < 0 || (unsigned)index > quick_cues.quick_cues.size()) @@ -401,7 +401,7 @@ stdx::optional track_impl::hot_cue_at(int index) return convert::read::hot_cue(quick_cues.quick_cues[index]); } -void track_impl::set_hot_cue_at(int index, stdx::optional cue) +void track_impl::set_hot_cue_at(int index, std::optional cue) { auto quick_cues = track_.get_quick_cues(id()); if (index < 0 || (unsigned)index > quick_cues.quick_cues.size()) @@ -415,13 +415,13 @@ void track_impl::set_hot_cue_at(int index, stdx::optional cue) track_.set_quick_cues(id(), quick_cues); } -std::vector> track_impl::hot_cues() +std::vector> track_impl::hot_cues() { auto quick_cues = track_.get_quick_cues(id()); return convert::read::hot_cues(quick_cues); } -void track_impl::set_hot_cues(std::vector> cues) +void track_impl::set_hot_cues(std::vector> cues) { auto quick_cues = track_.get_quick_cues(id()); quick_cues.quick_cues = convert::write::hot_cues(cues); @@ -433,12 +433,12 @@ bool track_impl::is_valid() return track_.exists(id()); } -stdx::optional track_impl::key() +std::optional track_impl::key() { return convert::read::key(track_.get_key(id())); } -void track_impl::set_key(stdx::optional key) +void track_impl::set_key(std::optional key) { auto converted = convert::write::key(key); track_.set_key(id(), converted.key); @@ -448,18 +448,18 @@ void track_impl::set_key(stdx::optional key) track_.set_track_data(id(), track_data); } -stdx::optional track_impl::last_played_at() +std::optional track_impl::last_played_at() { return track_.get_time_last_played(id()); } void track_impl::set_last_played_at( - stdx::optional played_at) + std::optional played_at) { track_.set_time_last_played(id(), played_at); } -stdx::optional track_impl::loop_at(int index) +std::optional track_impl::loop_at(int index) { auto loops = track_.get_loops(id()); if (index < 0 || (unsigned)index > loops.loops.size()) @@ -472,7 +472,7 @@ stdx::optional track_impl::loop_at(int index) return convert::read::loop(loops.loops[index]); } -void track_impl::set_loop_at(int index, stdx::optional l) +void track_impl::set_loop_at(int index, std::optional l) { auto loops = track_.get_loops(id()); if (index < 0 || (unsigned)index > loops.loops.size()) @@ -486,28 +486,28 @@ void track_impl::set_loop_at(int index, stdx::optional l) track_.set_loops(id(), loops); } -std::vector> track_impl::loops() +std::vector> track_impl::loops() { return convert::read::loops(track_.get_loops(id())); } -void track_impl::set_loops(std::vector> loops) +void track_impl::set_loops(std::vector> loops) { auto converted = convert::write::loops(loops); track_.set_loops(id(), converted); } -stdx::optional track_impl::main_cue() +std::optional track_impl::main_cue() { auto quick_cues = track_.get_quick_cues(id()); auto cue = quick_cues.adjusted_main_cue; if (cue == 0) - return stdx::nullopt; + return std::nullopt; - return stdx::make_optional(cue); + return std::make_optional(cue); } -void track_impl::set_main_cue(stdx::optional sample_offset) +void track_impl::set_main_cue(std::optional sample_offset) { auto quick_cues = track_.get_quick_cues(id()); quick_cues.adjusted_main_cue = sample_offset.value_or(0); @@ -516,23 +516,23 @@ void track_impl::set_main_cue(stdx::optional sample_offset) track_.set_quick_cues(id(), quick_cues); } -stdx::optional track_impl::publisher() +std::optional track_impl::publisher() { return track_.get_label(id()); } -void track_impl::set_publisher(stdx::optional publisher) +void track_impl::set_publisher(std::optional publisher) { track_.set_label(id(), publisher); } -stdx::optional track_impl::rating() +std::optional track_impl::rating() { auto rating = track_.get_rating(id()); return convert::read::rating(rating); } -void track_impl::set_rating(stdx::optional rating) +void track_impl::set_rating(std::optional rating) { track_.set_rating(id(), convert::write::rating(rating)); } @@ -547,14 +547,14 @@ void track_impl::set_relative_path(std::string relative_path) track_.set_path(id(), relative_path); } -stdx::optional track_impl::sample_count() +std::optional track_impl::sample_count() { auto track_data = track_.get_track_data(id()); return convert::read::sample_count(track_data); } void track_impl::set_sample_count( - stdx::optional sample_count) + std::optional sample_count) { auto converted = convert::write::sample_count(sample_count); @@ -568,13 +568,13 @@ void track_impl::set_sample_count( track_.set_beat_data(id(), beat_data); } -stdx::optional track_impl::sample_rate() +std::optional track_impl::sample_rate() { auto track_data = track_.get_track_data(id()); return convert::read::sample_rate(track_data); } -void track_impl::set_sample_rate(stdx::optional sample_rate) +void track_impl::set_sample_rate(std::optional sample_rate) { auto converted = convert::write::sample_rate(sample_rate); @@ -588,23 +588,23 @@ void track_impl::set_sample_rate(stdx::optional sample_rate) track_.set_beat_data(id(), beat_data); } -stdx::optional track_impl::title() +std::optional track_impl::title() { return track_.get_title(id()); } -void track_impl::set_title(stdx::optional title) +void track_impl::set_title(std::optional title) { track_.set_title(id(), title); } -stdx::optional track_impl::track_number() +std::optional track_impl::track_number() { return djinterop::util::optional_static_cast( track_.get_play_order(id())); } -void track_impl::set_track_number(stdx::optional track_number) +void track_impl::set_track_number(std::optional track_number) { track_.set_play_order( id(), djinterop::util::optional_static_cast(track_number)); @@ -625,12 +625,12 @@ void track_impl::set_waveform(std::vector waveform) track_.set_overview_waveform_data(id(), overview_waveform_data); } -stdx::optional track_impl::year() +std::optional track_impl::year() { return djinterop::util::optional_static_cast(track_.get_year(id())); } -void track_impl::set_year(stdx::optional year) +void track_impl::set_year(std::optional year) { track_.set_year(id(), djinterop::util::optional_static_cast(year)); } diff --git a/src/djinterop/engine/v2/track_impl.hpp b/src/djinterop/engine/v2/track_impl.hpp index 1177fec..48f28c0 100644 --- a/src/djinterop/engine/v2/track_impl.hpp +++ b/src/djinterop/engine/v2/track_impl.hpp @@ -19,17 +19,14 @@ #include #include -#include +#include #include #include #include -#include -#include #include #include "../../impl/track_impl.hpp" -#include "engine_library_context.hpp" namespace djinterop { @@ -48,68 +45,68 @@ class track_impl : public djinterop::track_impl void update(const track_snapshot& snapshot) override; - stdx::optional album() override; - void set_album(stdx::optional album) override; - stdx::optional artist() override; - void set_artist(stdx::optional artist) override; - stdx::optional average_loudness() override; - void set_average_loudness(stdx::optional average_loudness) override; + std::optional album() override; + void set_album(std::optional album) override; + std::optional artist() override; + void set_artist(std::optional artist) override; + std::optional average_loudness() override; + void set_average_loudness(std::optional average_loudness) override; std::vector beatgrid() override; void set_beatgrid(std::vector beatgrid) override; - stdx::optional bitrate() override; - void set_bitrate(stdx::optional bitrate) override; - stdx::optional bpm() override; - void set_bpm(stdx::optional bpm) override; - stdx::optional comment() override; - void set_comment(stdx::optional comment) override; - stdx::optional composer() override; - void set_composer(stdx::optional composer) override; + std::optional bitrate() override; + void set_bitrate(std::optional bitrate) override; + std::optional bpm() override; + void set_bpm(std::optional bpm) override; + std::optional comment() override; + void set_comment(std::optional comment) override; + std::optional composer() override; + void set_composer(std::optional composer) override; std::vector containing_crates() override; database db() override; - stdx::optional duration() override; + std::optional duration() override; void set_duration( - stdx::optional duration) override; + std::optional duration) override; std::string file_extension() override; std::string filename() override; - stdx::optional genre() override; - void set_genre(stdx::optional genre) override; - stdx::optional hot_cue_at(int index) override; - void set_hot_cue_at(int index, stdx::optional cue) override; - std::vector> hot_cues() override; - void set_hot_cues(std::vector> cues) override; + std::optional genre() override; + void set_genre(std::optional genre) override; + std::optional hot_cue_at(int index) override; + void set_hot_cue_at(int index, std::optional cue) override; + std::vector> hot_cues() override; + void set_hot_cues(std::vector> cues) override; bool is_valid() override; - stdx::optional key() override; - void set_key(stdx::optional key) override; - stdx::optional last_played_at() + std::optional key() override; + void set_key(std::optional key) override; + std::optional last_played_at() override; void set_last_played_at( - stdx::optional played_at) + std::optional played_at) override; - stdx::optional loop_at(int index) override; - void set_loop_at(int index, stdx::optional l) override; - std::vector> loops() override; - void set_loops(std::vector> loops) override; - stdx::optional main_cue() override; - void set_main_cue(stdx::optional sample_offset) override; - stdx::optional publisher() override; - void set_publisher(stdx::optional publisher) override; - stdx::optional rating() override; - void set_rating(stdx::optional rating) override; + std::optional loop_at(int index) override; + void set_loop_at(int index, std::optional l) override; + std::vector> loops() override; + void set_loops(std::vector> loops) override; + std::optional main_cue() override; + void set_main_cue(std::optional sample_offset) override; + std::optional publisher() override; + void set_publisher(std::optional publisher) override; + std::optional rating() override; + void set_rating(std::optional rating) override; std::string relative_path() override; void set_relative_path(std::string relative_path) override; - stdx::optional sample_count() override; + std::optional sample_count() override; void set_sample_count( - stdx::optional sample_count) override; - stdx::optional sample_rate() override; - void set_sample_rate(stdx::optional sample_rate) override; - stdx::optional title() override; - void set_title(stdx::optional title) override; - stdx::optional track_number() override; - void set_track_number(stdx::optional track_number) override; + std::optional sample_count) override; + std::optional sample_rate() override; + void set_sample_rate(std::optional sample_rate) override; + std::optional title() override; + void set_title(std::optional title) override; + std::optional track_number() override; + void set_track_number(std::optional track_number) override; std::vector waveform() override; void set_waveform(std::vector waveform) override; - stdx::optional year() override; - void set_year(stdx::optional year) override; + std::optional year() override; + void set_year(std::optional year) override; private: std::shared_ptr library_; diff --git a/src/djinterop/engine/v2/track_table.cpp b/src/djinterop/engine/v2/track_table.cpp index f6e381a..5487d89 100644 --- a/src/djinterop/engine/v2/track_table.cpp +++ b/src/djinterop/engine/v2/track_table.cpp @@ -35,7 +35,7 @@ template ColumnType get_column( sqlite::database& db, int64_t id, const std::string& column_name) { - stdx::optional result; + std::optional result; auto sql = "SELECT " + column_name + " FROM Track WHERE id = ?"; db << sql << id >> [&](ColumnType value) { result = value; }; @@ -54,11 +54,11 @@ std::chrono::system_clock::time_point get_column( } template <> -stdx::optional get_column( +std::optional get_column( sqlite::database& db, int64_t id, const std::string& column_name) { - auto timestamp = get_column>(db, id, column_name); + auto timestamp = get_column>(db, id, column_name); return djinterop::util::to_time_point(timestamp); } @@ -88,10 +88,10 @@ void set_column( template <> void set_column( sqlite::database& db, int64_t id, const std::string& column_name, - const stdx::optional& value) + const std::optional& value) { auto timestamp = djinterop::util::to_timestamp(value); - set_column>(db, id, column_name, timestamp); + set_column>(db, id, column_name, timestamp); } } // anonymous namespace @@ -350,9 +350,9 @@ bool track_table::exists(int64_t id) const return result; } -stdx::optional track_table::get(int64_t id) const +std::optional track_table::get(int64_t id) const { - stdx::optional result; + std::optional result; if (context_->version.schema_version >= semantic_version{2, 20, 3}) { @@ -372,40 +372,40 @@ stdx::optional track_table::get(int64_t id) const "activeOnLoadLoops, lastEditTime " "FROM Track WHERE id = ?" << id >> - [&](int64_t id, stdx::optional play_order, int64_t length, - stdx::optional bpm, stdx::optional year, + [&](int64_t id, std::optional play_order, int64_t length, + std::optional bpm, std::optional year, std::string path, std::string filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, int64_t album_art_id, - stdx::optional file_bytes, - stdx::optional title, - stdx::optional artist, - stdx::optional album, - stdx::optional genre, - stdx::optional comment, - stdx::optional label, - stdx::optional composer, - stdx::optional remixer, - stdx::optional key, int64_t rating, - stdx::optional album_art, - stdx::optional time_last_played, bool is_played, + std::optional bitrate, + std::optional bpm_analyzed, int64_t album_art_id, + std::optional file_bytes, + std::optional title, + std::optional artist, + std::optional album, + std::optional genre, + std::optional comment, + std::optional label, + std::optional composer, + std::optional remixer, + std::optional key, int64_t rating, + std::optional album_art, + std::optional time_last_played, bool is_played, std::string file_type, bool is_analyzed, int64_t date_created, int64_t date_added, bool is_available, bool is_metadata_of_packed_track_changed, bool is_performance_data_of_packed_track_changed, - stdx::optional played_indicator, + std::optional played_indicator, bool is_metadata_imported, int64_t pdb_import_key, - stdx::optional streaming_source, - stdx::optional uri, bool is_beat_grid_locked, + std::optional streaming_source, + std::optional uri, bool is_beat_grid_locked, std::string origin_database_uuid, int64_t origin_track_id, const std::vector& track_data, const std::vector& overview_waveform_data, const std::vector& beat_data, const std::vector& quick_cues, const std::vector& loops, - stdx::optional third_party_source_id, + std::optional third_party_source_id, int64_t streaming_flags, bool explicit_lyrics, - stdx::optional active_on_load_loops, + std::optional active_on_load_loops, int64_t last_edit_time) { assert(!result); @@ -480,40 +480,40 @@ stdx::optional track_table::get(int64_t id) const "activeOnLoadLoops " "FROM Track WHERE id = ?" << id >> - [&](int64_t id, stdx::optional play_order, int64_t length, - stdx::optional bpm, stdx::optional year, + [&](int64_t id, std::optional play_order, int64_t length, + std::optional bpm, std::optional year, std::string path, std::string filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, int64_t album_art_id, - stdx::optional file_bytes, - stdx::optional title, - stdx::optional artist, - stdx::optional album, - stdx::optional genre, - stdx::optional comment, - stdx::optional label, - stdx::optional composer, - stdx::optional remixer, - stdx::optional key, int64_t rating, - stdx::optional album_art, - stdx::optional time_last_played, bool is_played, + std::optional bitrate, + std::optional bpm_analyzed, int64_t album_art_id, + std::optional file_bytes, + std::optional title, + std::optional artist, + std::optional album, + std::optional genre, + std::optional comment, + std::optional label, + std::optional composer, + std::optional remixer, + std::optional key, int64_t rating, + std::optional album_art, + std::optional time_last_played, bool is_played, std::string file_type, bool is_analyzed, int64_t date_created, int64_t date_added, bool is_available, bool is_metadata_of_packed_track_changed, bool is_performance_data_of_packed_track_changed, - stdx::optional played_indicator, + std::optional played_indicator, bool is_metadata_imported, int64_t pdb_import_key, - stdx::optional streaming_source, - stdx::optional uri, bool is_beat_grid_locked, + std::optional streaming_source, + std::optional uri, bool is_beat_grid_locked, std::string origin_database_uuid, int64_t origin_track_id, const std::vector& track_data, const std::vector& overview_waveform_data, const std::vector& beat_data, const std::vector& quick_cues, const std::vector& loops, - stdx::optional third_party_source_id, + std::optional third_party_source_id, int64_t streaming_flags, bool explicit_lyrics, - stdx::optional active_on_load_loops) + std::optional active_on_load_loops) { assert(!result); @@ -586,38 +586,38 @@ stdx::optional track_table::get(int64_t id) const "thirdPartySourceId, streamingFlags, explicitLyrics " "FROM Track WHERE id = ?" << id >> - [&](int64_t id, stdx::optional play_order, int64_t length, - stdx::optional bpm, stdx::optional year, + [&](int64_t id, std::optional play_order, int64_t length, + std::optional bpm, std::optional year, std::string path, std::string filename, - stdx::optional bitrate, - stdx::optional bpm_analyzed, int64_t album_art_id, - stdx::optional file_bytes, - stdx::optional title, - stdx::optional artist, - stdx::optional album, - stdx::optional genre, - stdx::optional comment, - stdx::optional label, - stdx::optional composer, - stdx::optional remixer, - stdx::optional key, int64_t rating, - stdx::optional album_art, - stdx::optional time_last_played, bool is_played, + std::optional bitrate, + std::optional bpm_analyzed, int64_t album_art_id, + std::optional file_bytes, + std::optional title, + std::optional artist, + std::optional album, + std::optional genre, + std::optional comment, + std::optional label, + std::optional composer, + std::optional remixer, + std::optional key, int64_t rating, + std::optional album_art, + std::optional time_last_played, bool is_played, std::string file_type, bool is_analyzed, int64_t date_created, int64_t date_added, bool is_available, bool is_metadata_of_packed_track_changed, bool is_performance_data_of_packed_track_changed, - stdx::optional played_indicator, + std::optional played_indicator, bool is_metadata_imported, int64_t pdb_import_key, - stdx::optional streaming_source, - stdx::optional uri, bool is_beat_grid_locked, + std::optional streaming_source, + std::optional uri, bool is_beat_grid_locked, std::string origin_database_uuid, int64_t origin_track_id, const std::vector& track_data, const std::vector& overview_waveform_data, const std::vector& beat_data, const std::vector& quick_cues, const std::vector& loops, - stdx::optional third_party_source_id, + std::optional third_party_source_id, int64_t streaming_flags, bool explicit_lyrics) { assert(!result); @@ -670,7 +670,7 @@ stdx::optional track_table::get(int64_t id) const third_party_source_id, streaming_flags, explicit_lyrics, - stdx::nullopt, + std::nullopt, LAST_EDIT_TIME_NONE}; }; } @@ -678,10 +678,10 @@ stdx::optional track_table::get(int64_t id) const return result; } -stdx::optional track_table::find_id_by_path( +std::optional track_table::find_id_by_path( const std::string& path) const { - stdx::optional result; + std::optional result; context_->db << "SELECT id FROM Track WHERE path = ?" << path >> [&](int64_t id) @@ -859,14 +859,14 @@ void track_table::update(const track_row& row) } } -stdx::optional track_table::get_play_order(int64_t id) +std::optional track_table::get_play_order(int64_t id) { - return get_column>(context_->db, id, "playOrder"); + return get_column>(context_->db, id, "playOrder"); } -void track_table::set_play_order(int64_t id, stdx::optional play_order) +void track_table::set_play_order(int64_t id, std::optional play_order) { - set_column>( + set_column>( context_->db, id, "playOrder", play_order); } @@ -880,24 +880,24 @@ void track_table::set_length(int64_t id, int64_t length) set_column(context_->db, id, "length", length); } -stdx::optional track_table::get_bpm(int64_t id) +std::optional track_table::get_bpm(int64_t id) { - return get_column>(context_->db, id, "bpm"); + return get_column>(context_->db, id, "bpm"); } -void track_table::set_bpm(int64_t id, stdx::optional bpm) +void track_table::set_bpm(int64_t id, std::optional bpm) { - set_column>(context_->db, id, "bpm", bpm); + set_column>(context_->db, id, "bpm", bpm); } -stdx::optional track_table::get_year(int64_t id) +std::optional track_table::get_year(int64_t id) { - return get_column>(context_->db, id, "year"); + return get_column>(context_->db, id, "year"); } -void track_table::set_year(int64_t id, const stdx::optional& year) +void track_table::set_year(int64_t id, const std::optional& year) { - set_column>(context_->db, id, "year", year); + set_column>(context_->db, id, "year", year); } std::string track_table::get_path(int64_t id) @@ -920,25 +920,25 @@ void track_table::set_filename(int64_t id, const std::string& filename) set_column(context_->db, id, "filename", filename); } -stdx::optional track_table::get_bitrate(int64_t id) +std::optional track_table::get_bitrate(int64_t id) { - return get_column>(context_->db, id, "bitrate"); + return get_column>(context_->db, id, "bitrate"); } -void track_table::set_bitrate(int64_t id, stdx::optional bitrate) +void track_table::set_bitrate(int64_t id, std::optional bitrate) { - set_column>(context_->db, id, "bitrate", bitrate); + set_column>(context_->db, id, "bitrate", bitrate); } -stdx::optional track_table::get_bpm_analyzed(int64_t id) +std::optional track_table::get_bpm_analyzed(int64_t id) { - return get_column>(context_->db, id, "bpmAnalyzed"); + return get_column>(context_->db, id, "bpmAnalyzed"); } void track_table::set_bpm_analyzed( - int64_t id, stdx::optional bpm_analyzed) + int64_t id, std::optional bpm_analyzed) { - set_column>( + set_column>( context_->db, id, "bpmAnalyzed", bpm_analyzed); } @@ -952,117 +952,117 @@ void track_table::set_album_art_id(int64_t id, int64_t album_art_id) set_column(context_->db, id, "albumArtId", album_art_id); } -stdx::optional track_table::get_file_bytes(int64_t id) +std::optional track_table::get_file_bytes(int64_t id) { - return get_column>(context_->db, id, "fileBytes"); + return get_column>(context_->db, id, "fileBytes"); } -void track_table::set_file_bytes(int64_t id, stdx::optional file_bytes) +void track_table::set_file_bytes(int64_t id, std::optional file_bytes) { - set_column>( + set_column>( context_->db, id, "fileBytes", file_bytes); } -stdx::optional track_table::get_title(int64_t id) +std::optional track_table::get_title(int64_t id) { - return get_column>(context_->db, id, "title"); + return get_column>(context_->db, id, "title"); } void track_table::set_title( - int64_t id, const stdx::optional& title) + int64_t id, const std::optional& title) { - set_column>(context_->db, id, "title", title); + set_column>(context_->db, id, "title", title); } -stdx::optional track_table::get_artist(int64_t id) +std::optional track_table::get_artist(int64_t id) { - return get_column>(context_->db, id, "artist"); + return get_column>(context_->db, id, "artist"); } void track_table::set_artist( - int64_t id, const stdx::optional& artist) + int64_t id, const std::optional& artist) { - set_column>(context_->db, id, "artist", artist); + set_column>(context_->db, id, "artist", artist); } -stdx::optional track_table::get_album(int64_t id) +std::optional track_table::get_album(int64_t id) { - return get_column>(context_->db, id, "album"); + return get_column>(context_->db, id, "album"); } void track_table::set_album( - int64_t id, const stdx::optional& album) + int64_t id, const std::optional& album) { - set_column>(context_->db, id, "album", album); + set_column>(context_->db, id, "album", album); } -stdx::optional track_table::get_genre(int64_t id) +std::optional track_table::get_genre(int64_t id) { - return get_column>(context_->db, id, "genre"); + return get_column>(context_->db, id, "genre"); } void track_table::set_genre( - int64_t id, const stdx::optional& genre) + int64_t id, const std::optional& genre) { - set_column>(context_->db, id, "genre", genre); + set_column>(context_->db, id, "genre", genre); } -stdx::optional track_table::get_comment(int64_t id) +std::optional track_table::get_comment(int64_t id) { - return get_column>(context_->db, id, "comment"); + return get_column>(context_->db, id, "comment"); } void track_table::set_comment( - int64_t id, const stdx::optional& comment) + int64_t id, const std::optional& comment) { - set_column>( + set_column>( context_->db, id, "comment", comment); } -stdx::optional track_table::get_label(int64_t id) +std::optional track_table::get_label(int64_t id) { - return get_column>(context_->db, id, "label"); + return get_column>(context_->db, id, "label"); } void track_table::set_label( - int64_t id, const stdx::optional& label) + int64_t id, const std::optional& label) { - set_column>(context_->db, id, "label", label); + set_column>(context_->db, id, "label", label); } -stdx::optional track_table::get_composer(int64_t id) +std::optional track_table::get_composer(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "composer"); } void track_table::set_composer( - int64_t id, const stdx::optional& composer) + int64_t id, const std::optional& composer) { - set_column>( + set_column>( context_->db, id, "composer", composer); } -stdx::optional track_table::get_remixer(int64_t id) +std::optional track_table::get_remixer(int64_t id) { - return get_column>(context_->db, id, "remixer"); + return get_column>(context_->db, id, "remixer"); } void track_table::set_remixer( - int64_t id, const stdx::optional& remixer) + int64_t id, const std::optional& remixer) { - set_column>( + set_column>( context_->db, id, "remixer", remixer); } -stdx::optional track_table::get_key(int64_t id) +std::optional track_table::get_key(int64_t id) { - return get_column>(context_->db, id, "key"); + return get_column>(context_->db, id, "key"); } -void track_table::set_key(int64_t id, stdx::optional key) +void track_table::set_key(int64_t id, std::optional key) { - set_column>(context_->db, id, "key", key); + set_column>(context_->db, id, "key", key); } int64_t track_table::get_rating(int64_t id) @@ -1075,31 +1075,31 @@ void track_table::set_rating(int64_t id, int64_t rating) set_column(context_->db, id, "rating", rating); } -stdx::optional track_table::get_album_art(int64_t id) +std::optional track_table::get_album_art(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "albumArt"); } void track_table::set_album_art( - int64_t id, const stdx::optional& album_art) + int64_t id, const std::optional& album_art) { - set_column>( + set_column>( context_->db, id, "albumArt", album_art); } -stdx::optional +std::optional track_table::get_time_last_played(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "timeLastPlayed"); } void track_table::set_time_last_played( - int64_t id, const stdx::optional& + int64_t id, const std::optional& time_last_played) { - set_column>( + set_column>( context_->db, id, "timeLastPlayed", time_last_played); } @@ -1133,33 +1133,33 @@ void track_table::set_is_analyzed(int64_t id, bool is_analyzed) set_column(context_->db, id, "isAnalyzed", is_analyzed); } -stdx::optional +std::optional track_table::get_date_created(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "dateCreated"); } void track_table::set_date_created( int64_t id, - const stdx::optional& date_created) + const std::optional& date_created) { - set_column>( + set_column>( context_->db, id, "dateCreated", date_created); } -stdx::optional +std::optional track_table::get_date_added(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "dateAdded"); } void track_table::set_date_added( int64_t id, - const stdx::optional& date_added) + const std::optional& date_added) { - set_column>( + set_column>( context_->db, id, "dateAdded", date_added); } @@ -1200,16 +1200,16 @@ void track_table::set_is_performance_data_of_packed_track_changed( is_performance_data_of_packed_track_changed); } -stdx::optional track_table::get_played_indicator(int64_t id) +std::optional track_table::get_played_indicator(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "playedIndicator"); } void track_table::set_played_indicator( - int64_t id, const stdx::optional& played_indicator) + int64_t id, const std::optional& played_indicator) { - set_column>( + set_column>( context_->db, id, "playedIndicator", played_indicator); } @@ -1235,27 +1235,27 @@ void track_table::set_pdb_import_key(int64_t id, int64_t pdb_import_key) set_column(context_->db, id, "pdbImportKey", pdb_import_key); } -stdx::optional track_table::get_streaming_source(int64_t id) +std::optional track_table::get_streaming_source(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "streamingSource"); } void track_table::set_streaming_source( - int64_t id, const stdx::optional& streaming_source) + int64_t id, const std::optional& streaming_source) { - set_column>( + set_column>( context_->db, id, "streamingSource", streaming_source); } -stdx::optional track_table::get_uri(int64_t id) +std::optional track_table::get_uri(int64_t id) { - return get_column>(context_->db, id, "uri"); + return get_column>(context_->db, id, "uri"); } -void track_table::set_uri(int64_t id, const stdx::optional& uri) +void track_table::set_uri(int64_t id, const std::optional& uri) { - set_column>(context_->db, id, "uri", uri); + set_column>(context_->db, id, "uri", uri); } bool track_table::get_is_beat_grid_locked(int64_t id) @@ -1353,16 +1353,16 @@ void track_table::set_loops(int64_t id, const loops_blob& loops) context_->db, id, "loops", loops.to_blob()); } -stdx::optional track_table::get_third_party_source_id(int64_t id) +std::optional track_table::get_third_party_source_id(int64_t id) { - return get_column>( + return get_column>( context_->db, id, "thirdPartySourceId"); } void track_table::set_third_party_source_id( - int64_t id, const stdx::optional& third_party_source_id) + int64_t id, const std::optional& third_party_source_id) { - set_column>( + set_column>( context_->db, id, "thirdPartySourceId", third_party_source_id); } @@ -1386,26 +1386,26 @@ void track_table::set_explicit_lyrics(int64_t id, bool explicit_lyrics) set_column(context_->db, id, "explicitLyrics", explicit_lyrics); } -stdx::optional track_table::get_active_on_load_loops(int64_t id) +std::optional track_table::get_active_on_load_loops(int64_t id) { if (context_->version.schema_version < semantic_version{2, 20, 1}) throw djinterop::unsupported_operation{ "The `activeOnLoadLoops` column is not available for this " "database version"}; - return get_column>( + return get_column>( context_->db, id, "activeOnLoadLoops"); } void track_table::set_active_on_load_loops( - int64_t id, stdx::optional active_on_load_loops) + int64_t id, std::optional active_on_load_loops) { if (context_->version.schema_version < semantic_version{2, 20, 1}) throw djinterop::unsupported_operation{ "The `activeOnLoadLoops` column is not available for this " "database version"}; - set_column>( + set_column>( context_->db, id, "activeOnLoadLoops", active_on_load_loops); } diff --git a/src/djinterop/impl/crate_impl.hpp b/src/djinterop/impl/crate_impl.hpp index fb62123..2a17d98 100644 --- a/src/djinterop/impl/crate_impl.hpp +++ b/src/djinterop/impl/crate_impl.hpp @@ -17,11 +17,11 @@ #pragma once +#include #include #include #include -#include #include #include "database_impl.hpp" @@ -50,12 +50,12 @@ class crate_impl virtual std::vector descendants() = 0; virtual bool is_valid() = 0; virtual std::string name() = 0; - virtual stdx::optional parent() = 0; + virtual std::optional parent() = 0; virtual void remove_track(track tr) = 0; - virtual stdx::optional sub_crate_by_name( + virtual std::optional sub_crate_by_name( const std::string& name) = 0; virtual void set_name(std::string name) = 0; - virtual void set_parent(stdx::optional parent) = 0; + virtual void set_parent(std::optional parent) = 0; virtual std::vector tracks() = 0; private: diff --git a/src/djinterop/impl/database_impl.hpp b/src/djinterop/impl/database_impl.hpp index 019b681..dd6f7a1 100644 --- a/src/djinterop/impl/database_impl.hpp +++ b/src/djinterop/impl/database_impl.hpp @@ -17,11 +17,10 @@ #pragma once +#include #include #include -#include - namespace djinterop { class crate; @@ -33,7 +32,7 @@ class database_impl public: virtual ~database_impl(); - virtual stdx::optional crate_by_id(int64_t id) = 0; + virtual std::optional crate_by_id(int64_t id) = 0; virtual std::vector crates() = 0; virtual std::vector crates_by_name(const std::string& name) = 0; virtual crate create_root_crate(const std::string& name) = 0; @@ -45,9 +44,9 @@ class database_impl virtual void remove_crate(crate cr) = 0; virtual void remove_track(track tr) = 0; virtual std::vector root_crates() = 0; - virtual stdx::optional root_crate_by_name( + virtual std::optional root_crate_by_name( const std::string& name) = 0; - virtual stdx::optional track_by_id(int64_t id) = 0; + virtual std::optional track_by_id(int64_t id) = 0; virtual std::vector tracks() = 0; virtual std::vector tracks_by_relative_path( const std::string& relative_path) = 0; diff --git a/src/djinterop/impl/track_impl.hpp b/src/djinterop/impl/track_impl.hpp index e1d2bc6..393f05c 100644 --- a/src/djinterop/impl/track_impl.hpp +++ b/src/djinterop/impl/track_impl.hpp @@ -19,10 +19,10 @@ #include #include +#include #include #include -#include #include namespace djinterop @@ -45,67 +45,67 @@ class track_impl virtual void update(const track_snapshot& snapshot) = 0; - virtual stdx::optional album() = 0; - virtual void set_album(stdx::optional album) = 0; - virtual stdx::optional artist() = 0; - virtual void set_artist(stdx::optional artist) = 0; - virtual stdx::optional average_loudness() = 0; + virtual std::optional album() = 0; + virtual void set_album(std::optional album) = 0; + virtual std::optional artist() = 0; + virtual void set_artist(std::optional artist) = 0; + virtual std::optional average_loudness() = 0; virtual void set_average_loudness( - stdx::optional average_loudness) = 0; + std::optional average_loudness) = 0; virtual std::vector beatgrid() = 0; virtual void set_beatgrid(std::vector beatgrid) = 0; - virtual stdx::optional bitrate() = 0; - virtual void set_bitrate(stdx::optional bitrate) = 0; - virtual stdx::optional bpm() = 0; - virtual void set_bpm(stdx::optional bpm) = 0; - virtual stdx::optional comment() = 0; - virtual void set_comment(stdx::optional comment) = 0; - virtual stdx::optional composer() = 0; - virtual void set_composer(stdx::optional composer) = 0; + virtual std::optional bitrate() = 0; + virtual void set_bitrate(std::optional bitrate) = 0; + virtual std::optional bpm() = 0; + virtual void set_bpm(std::optional bpm) = 0; + virtual std::optional comment() = 0; + virtual void set_comment(std::optional comment) = 0; + virtual std::optional composer() = 0; + virtual void set_composer(std::optional composer) = 0; virtual std::vector containing_crates() = 0; virtual database db() = 0; - virtual stdx::optional duration() = 0; + virtual std::optional duration() = 0; virtual void set_duration( - stdx::optional duration) = 0; + std::optional duration) = 0; virtual std::string file_extension() = 0; virtual std::string filename() = 0; - virtual stdx::optional genre() = 0; - virtual void set_genre(stdx::optional genre) = 0; - virtual stdx::optional hot_cue_at(int index) = 0; - virtual void set_hot_cue_at(int index, stdx::optional cue) = 0; - virtual std::vector > hot_cues() = 0; - virtual void set_hot_cues(std::vector > cues) = 0; + virtual std::optional genre() = 0; + virtual void set_genre(std::optional genre) = 0; + virtual std::optional hot_cue_at(int index) = 0; + virtual void set_hot_cue_at(int index, std::optional cue) = 0; + virtual std::vector > hot_cues() = 0; + virtual void set_hot_cues(std::vector > cues) = 0; virtual bool is_valid() = 0; - virtual stdx::optional key() = 0; - virtual void set_key(stdx::optional key) = 0; - virtual stdx::optional + virtual std::optional key() = 0; + virtual void set_key(std::optional key) = 0; + virtual std::optional last_played_at() = 0; virtual void set_last_played_at( - stdx::optional time) = 0; - virtual stdx::optional loop_at(int index) = 0; - virtual void set_loop_at(int index, stdx::optional l) = 0; - virtual std::vector > loops() = 0; - virtual void set_loops(std::vector > loops) = 0; - virtual stdx::optional main_cue() = 0; - virtual void set_main_cue(stdx::optional sample_offset) = 0; - virtual stdx::optional publisher() = 0; - virtual void set_publisher(stdx::optional publisher) = 0; - virtual stdx::optional rating() = 0; - virtual void set_rating(stdx::optional rating) = 0; + std::optional time) = 0; + virtual std::optional loop_at(int index) = 0; + virtual void set_loop_at(int index, std::optional l) = 0; + virtual std::vector > loops() = 0; + virtual void set_loops(std::vector > loops) = 0; + virtual std::optional main_cue() = 0; + virtual void set_main_cue(std::optional sample_offset) = 0; + virtual std::optional publisher() = 0; + virtual void set_publisher(std::optional publisher) = 0; + virtual std::optional rating() = 0; + virtual void set_rating(std::optional rating) = 0; virtual std::string relative_path() = 0; virtual void set_relative_path(std::string relative_path) = 0; - virtual stdx::optional sample_count() = 0; - virtual void set_sample_count(stdx::optional sample_count) = 0; - virtual stdx::optional sample_rate() = 0; - virtual void set_sample_rate(stdx::optional sample_rate) = 0; - virtual stdx::optional title() = 0; - virtual void set_title(stdx::optional title) = 0; - virtual stdx::optional track_number() = 0; - virtual void set_track_number(stdx::optional track_number) = 0; + virtual std::optional sample_count() = 0; + virtual void set_sample_count(std::optional sample_count) = 0; + virtual std::optional sample_rate() = 0; + virtual void set_sample_rate(std::optional sample_rate) = 0; + virtual std::optional title() = 0; + virtual void set_title(std::optional title) = 0; + virtual std::optional track_number() = 0; + virtual void set_track_number(std::optional track_number) = 0; virtual std::vector waveform() = 0; virtual void set_waveform(std::vector waveform) = 0; - virtual stdx::optional year() = 0; - virtual void set_year(stdx::optional year) = 0; + virtual std::optional year() = 0; + virtual void set_year(std::optional year) = 0; private: int64_t id_; diff --git a/src/djinterop/track.cpp b/src/djinterop/track.cpp index ec788a6..7312c80 100644 --- a/src/djinterop/track.cpp +++ b/src/djinterop/track.cpp @@ -51,49 +51,49 @@ void track::update(const track_snapshot& snapshot) pimpl_->update(snapshot); } -stdx::optional track::album() const +std::optional track::album() const { return pimpl_->album(); } -void track::set_album(stdx::optional album) const +void track::set_album(std::optional album) const { pimpl_->set_album(album); } void track::set_album(std::string album) const { - set_album(stdx::make_optional(album)); + set_album(std::make_optional(album)); } -stdx::optional track::artist() const +std::optional track::artist() const { return pimpl_->artist(); } -void track::set_artist(stdx::optional artist) const +void track::set_artist(std::optional artist) const { pimpl_->set_artist(artist); } void track::set_artist(std::string artist) const { - set_artist(stdx::make_optional(artist)); + set_artist(std::make_optional(artist)); } -stdx::optional track::average_loudness() const +std::optional track::average_loudness() const { return pimpl_->average_loudness(); } -void track::set_average_loudness(stdx::optional average_loudness) const +void track::set_average_loudness(std::optional average_loudness) const { pimpl_->set_average_loudness(average_loudness); } void track::set_average_loudness(double average_loudness) const { - set_average_loudness(stdx::make_optional(average_loudness)); + set_average_loudness(std::make_optional(average_loudness)); } std::vector track::beatgrid() const @@ -106,64 +106,64 @@ void track::set_beatgrid(std::vector beatgrid) const pimpl_->set_beatgrid(std::move(beatgrid)); } -stdx::optional track::bitrate() const +std::optional track::bitrate() const { return pimpl_->bitrate(); } -void track::set_bitrate(stdx::optional bitrate) const +void track::set_bitrate(std::optional bitrate) const { pimpl_->set_bitrate(bitrate); } void track::set_bitrate(int bitrate) const { - set_bitrate(stdx::make_optional(bitrate)); + set_bitrate(std::make_optional(bitrate)); } -stdx::optional track::bpm() const +std::optional track::bpm() const { return pimpl_->bpm(); } -void track::set_bpm(stdx::optional bpm) const +void track::set_bpm(std::optional bpm) const { pimpl_->set_bpm(bpm); } void track::set_bpm(double bpm) const { - set_bpm(stdx::make_optional(bpm)); + set_bpm(std::make_optional(bpm)); } -stdx::optional track::comment() const +std::optional track::comment() const { return pimpl_->comment(); } -void track::set_comment(stdx::optional comment) const +void track::set_comment(std::optional comment) const { pimpl_->set_comment(comment); } void track::set_comment(std::string comment) const { - set_comment(stdx::make_optional(comment)); + set_comment(std::make_optional(comment)); } -stdx::optional track::composer() const +std::optional track::composer() const { return pimpl_->composer(); } -void track::set_composer(stdx::optional composer) const +void track::set_composer(std::optional composer) const { pimpl_->set_composer(composer); } void track::set_composer(std::string composer) const { - set_composer(stdx::make_optional(composer)); + set_composer(std::make_optional(composer)); } std::vector track::containing_crates() const @@ -176,19 +176,19 @@ database track::db() const return pimpl_->db(); } -stdx::optional track::duration() const +std::optional track::duration() const { return pimpl_->duration(); } -void track::set_duration(stdx::optional duration) +void track::set_duration(std::optional duration) { pimpl_->set_duration(duration); } void track::set_duration(milliseconds duration) { - set_duration(stdx::make_optional(duration)); + set_duration(std::make_optional(duration)); } std::string track::file_extension() const @@ -201,42 +201,42 @@ std::string track::filename() const return pimpl_->filename(); } -stdx::optional track::genre() const +std::optional track::genre() const { return pimpl_->genre(); } -void track::set_genre(stdx::optional genre) const +void track::set_genre(std::optional genre) const { pimpl_->set_genre(genre); } void track::set_genre(std::string genre) const { - set_genre(stdx::make_optional(genre)); + set_genre(std::make_optional(genre)); } -stdx::optional track::hot_cue_at(int index) const +std::optional track::hot_cue_at(int index) const { return pimpl_->hot_cue_at(index); } -void track::set_hot_cue_at(int index, stdx::optional cue) const +void track::set_hot_cue_at(int index, std::optional cue) const { pimpl_->set_hot_cue_at(index, cue); } void track::set_hot_cue_at(int index, hot_cue cue) const { - set_hot_cue_at(index, stdx::make_optional(std::move(cue))); + set_hot_cue_at(index, std::make_optional(std::move(cue))); } -std::vector > track::hot_cues() const +std::vector > track::hot_cues() const { return pimpl_->hot_cues(); } -void track::set_hot_cues(std::vector > cues) const +void track::set_hot_cues(std::vector > cues) const { pimpl_->set_hot_cues(std::move(cues)); } @@ -251,100 +251,100 @@ bool track::is_valid() const return pimpl_->is_valid(); } -stdx::optional track::key() const +std::optional track::key() const { return pimpl_->key(); } -void track::set_key(stdx::optional key) const +void track::set_key(std::optional key) const { pimpl_->set_key(key); } void track::set_key(musical_key key) const { - set_key(stdx::make_optional(key)); + set_key(std::make_optional(key)); } -stdx::optional track::last_played_at() const +std::optional track::last_played_at() const { return pimpl_->last_played_at(); } void track::set_last_played_at( - stdx::optional played_at) const + std::optional played_at) const { pimpl_->set_last_played_at(played_at); } void track::set_last_played_at(system_clock::time_point played_at) const { - set_last_played_at(stdx::make_optional(played_at)); + set_last_played_at(std::make_optional(played_at)); } -stdx::optional track::loop_at(int index) const +std::optional track::loop_at(int index) const { return pimpl_->loop_at(index); } -void track::set_loop_at(int index, stdx::optional l) const +void track::set_loop_at(int index, std::optional l) const { pimpl_->set_loop_at(index, l); } void track::set_loop_at(int index, loop l) const { - set_loop_at(index, stdx::make_optional(l)); + set_loop_at(index, std::make_optional(l)); } -std::vector > track::loops() const +std::vector > track::loops() const { return pimpl_->loops(); } -void track::set_loops(std::vector > loops) const +void track::set_loops(std::vector > loops) const { pimpl_->set_loops(std::move(loops)); } -stdx::optional track::main_cue() const +std::optional track::main_cue() const { return pimpl_->main_cue(); } -void track::set_main_cue(stdx::optional sample_offset) const +void track::set_main_cue(std::optional sample_offset) const { pimpl_->set_main_cue(sample_offset); } -stdx::optional track::publisher() const +std::optional track::publisher() const { return pimpl_->publisher(); } -void track::set_publisher(stdx::optional publisher) const +void track::set_publisher(std::optional publisher) const { pimpl_->set_publisher(publisher); } void track::set_publisher(std::string publisher) const { - set_publisher(stdx::make_optional(publisher)); + set_publisher(std::make_optional(publisher)); } -stdx::optional track::rating() const +std::optional track::rating() const { return pimpl_->rating(); } -void track::set_rating(stdx::optional rating) +void track::set_rating(std::optional rating) { pimpl_->set_rating(rating); } void track::set_rating(int32_t rating) { - pimpl_->set_rating(stdx::make_optional(rating)); + pimpl_->set_rating(std::make_optional(rating)); } std::string track::relative_path() const @@ -357,64 +357,64 @@ void track::set_relative_path(std::string relative_path) const pimpl_->set_relative_path(relative_path); } -stdx::optional track::sample_count() const +std::optional track::sample_count() const { return pimpl_->sample_count(); } -void track::set_sample_count(stdx::optional sample_count) +void track::set_sample_count(std::optional sample_count) { pimpl_->set_sample_count(sample_count); } void track::set_sample_count(unsigned long long sample_count) { - set_sample_count(stdx::make_optional(sample_count)); + set_sample_count(std::make_optional(sample_count)); } -stdx::optional track::sample_rate() const +std::optional track::sample_rate() const { return pimpl_->sample_rate(); } -void track::set_sample_rate(stdx::optional sample_rate) +void track::set_sample_rate(std::optional sample_rate) { pimpl_->set_sample_rate(sample_rate); } void track::set_sample_rate(double sample_rate) { - set_sample_rate(stdx::make_optional(sample_rate)); + set_sample_rate(std::make_optional(sample_rate)); } -stdx::optional track::title() const +std::optional track::title() const { return pimpl_->title(); } -void track::set_title(stdx::optional title) const +void track::set_title(std::optional title) const { pimpl_->set_title(title); } void track::set_title(std::string title) const { - set_title(stdx::make_optional(title)); + set_title(std::make_optional(title)); } -stdx::optional track::track_number() const +std::optional track::track_number() const { return pimpl_->track_number(); } -void track::set_track_number(stdx::optional track_number) const +void track::set_track_number(std::optional track_number) const { pimpl_->set_track_number(track_number); } void track::set_track_number(int track_number) const { - set_track_number(stdx::make_optional(track_number)); + set_track_number(std::make_optional(track_number)); } std::vector track::waveform() const @@ -427,19 +427,19 @@ void track::set_waveform(std::vector waveform) const pimpl_->set_waveform(waveform); } -stdx::optional track::year() const +std::optional track::year() const { return pimpl_->year(); } -void track::set_year(stdx::optional year) const +void track::set_year(std::optional year) const { pimpl_->set_year(year); } void track::set_year(int year) const { - set_year(stdx::make_optional(year)); + set_year(std::make_optional(year)); } track::track(std::shared_ptr pimpl) : pimpl_{std::move(pimpl)} {} diff --git a/src/djinterop/util/chrono.hpp b/src/djinterop/util/chrono.hpp index 5cb127a..2d218d7 100644 --- a/src/djinterop/util/chrono.hpp +++ b/src/djinterop/util/chrono.hpp @@ -19,10 +19,9 @@ #include #include +#include #include -#include - namespace djinterop::util { std::chrono::system_clock::time_point parse_ft(const std::string& str); @@ -36,10 +35,10 @@ inline std::chrono::system_clock::time_point to_time_point(int64_t timestamp) std::chrono::seconds(timestamp)}; } -inline stdx::optional to_time_point( - stdx::optional timestamp) +inline std::optional to_time_point( + std::optional timestamp) { - stdx::optional result; + std::optional result; if (timestamp) result = to_time_point(*timestamp); @@ -53,10 +52,10 @@ inline int64_t to_timestamp(std::chrono::system_clock::time_point time) .count(); } -inline stdx::optional to_timestamp( - stdx::optional time) +inline std::optional to_timestamp( + std::optional time) { - stdx::optional result; + std::optional result; if (time) result = to_timestamp(*time); diff --git a/src/djinterop/util/convert.hpp b/src/djinterop/util/convert.hpp index 2cfefbd..4d5a1ff 100644 --- a/src/djinterop/util/convert.hpp +++ b/src/djinterop/util/convert.hpp @@ -17,20 +17,20 @@ #pragma once -#include +#include namespace djinterop::util { template -djinterop::stdx::optional optional_static_cast( - const djinterop::stdx::optional& u) +std::optional optional_static_cast( + const std::optional& u) { if (u) { - return djinterop::stdx::make_optional(static_cast(*u)); + return std::make_optional(static_cast(*u)); } - return djinterop::stdx::nullopt; + return std::nullopt; } } // namespace djinterop::util diff --git a/src/djinterop/util/filesystem.cpp b/src/djinterop/util/filesystem.cpp index 6cf4f51..03a61d3 100644 --- a/src/djinterop/util/filesystem.cpp +++ b/src/djinterop/util/filesystem.cpp @@ -24,8 +24,6 @@ #include #endif -#include - namespace djinterop::util { void create_dir(const std::string& directory) @@ -53,10 +51,10 @@ std::string get_filename(const std::string& file_path) return file_path.substr(slash_pos + 1); } -stdx::optional get_file_extension(const std::string& file_path) +std::optional get_file_extension(const std::string& file_path) { auto filename = get_filename(file_path); - stdx::optional file_extension; + std::optional file_extension; auto dot_pos = filename.rfind('.'); if (dot_pos != std::string::npos) { diff --git a/src/djinterop/util/filesystem.hpp b/src/djinterop/util/filesystem.hpp index 8a6f2de..5c72f8c 100644 --- a/src/djinterop/util/filesystem.hpp +++ b/src/djinterop/util/filesystem.hpp @@ -17,15 +17,14 @@ #pragma once +#include #include -#include - namespace djinterop::util { void create_dir(const std::string& directory); bool path_exists(const std::string& directory); std::string get_filename(const std::string& file_path); -stdx::optional get_file_extension(const std::string& file_path); +std::optional get_file_extension(const std::string& file_path); } // namespace djinterop::util diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap deleted file mode 100644 index 91c1d4d..0000000 --- a/subprojects/zlib.wrap +++ /dev/null @@ -1,10 +0,0 @@ -[wrap-file] -directory = zlib-1.2.11 - -source_url = http://zlib.net/fossils/zlib-1.2.11.tar.gz -source_filename = zlib-1.2.11.tar.gz -source_hash = c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 - -patch_url = https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/4/get_zip -patch_filename = zlib-1.2.11-4-wrap.zip -patch_hash = f733976fbfc59e0bcde01aa9469a24eeb16faf0a4280b17e9eaa60a301d75657 diff --git a/test/djinterop/engine/crate_test.cpp b/test/djinterop/engine/crate_test.cpp index ff504e1..d5f8f8a 100644 --- a/test/djinterop/engine/crate_test.cpp +++ b/test/djinterop/engine/crate_test.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -33,7 +32,6 @@ namespace e = djinterop::engine; namespace utf = boost::unit_test; -namespace stdx = djinterop::stdx; namespace { @@ -367,10 +365,10 @@ BOOST_DATA_TEST_CASE( // Act BOOST_TEST_CHECKPOINT("(" << version << ") Setting parent..."); - crate.set_parent(stdx::nullopt); + crate.set_parent(std::nullopt); // Assert - BOOST_CHECK(crate.parent() == stdx::nullopt); + BOOST_CHECK(crate.parent() == std::nullopt); } BOOST_TEST_DECORATOR( @@ -393,7 +391,7 @@ BOOST_DATA_TEST_CASE( crate.set_parent(new_parent_crate); // Assert - BOOST_REQUIRE(crate.parent() != stdx::nullopt); + BOOST_REQUIRE(crate.parent() != std::nullopt); BOOST_CHECK(crate.parent()->id() == new_parent_crate.id()); } @@ -413,10 +411,10 @@ BOOST_DATA_TEST_CASE( // Act BOOST_TEST_CHECKPOINT("(" << version << ") Setting parent..."); - crate.set_parent(stdx::nullopt); + crate.set_parent(std::nullopt); // Assert - BOOST_CHECK(crate.parent() == stdx::nullopt); + BOOST_CHECK(crate.parent() == std::nullopt); } BOOST_TEST_DECORATOR( @@ -441,7 +439,7 @@ BOOST_DATA_TEST_CASE( crate.set_parent(new_parent_crate); // Assert - BOOST_REQUIRE(crate.parent() != stdx::nullopt); + BOOST_REQUIRE(crate.parent() != std::nullopt); BOOST_CHECK(crate.parent()->id() == new_parent_crate.id()); } diff --git a/test/djinterop/engine/database_test.cpp b/test/djinterop/engine/database_test.cpp index e1c8adc..61d69dd 100644 --- a/test/djinterop/engine/database_test.cpp +++ b/test/djinterop/engine/database_test.cpp @@ -52,7 +52,7 @@ BOOST_DATA_TEST_CASE( // Assert BOOST_CHECK_NE(crate.id(), 0); - BOOST_CHECK(crate.parent() == djinterop::stdx::nullopt); + BOOST_CHECK(crate.parent() == std::nullopt); } BOOST_TEST_DECORATOR(* utf::description( diff --git a/test/djinterop/engine/example_track_data.hpp b/test/djinterop/engine/example_track_data.hpp index 6222e97..4f161c7 100644 --- a/test/djinterop/engine/example_track_data.hpp +++ b/test/djinterop/engine/example_track_data.hpp @@ -81,82 +81,82 @@ inline void populate_track_snapshot( switch (variation) { case example_track_data_variation::empty: - s.album = djinterop::stdx::nullopt; - s.artist = djinterop::stdx::nullopt; - s.average_loudness = djinterop::stdx::nullopt; + s.album = std::nullopt; + s.artist = std::nullopt; + s.average_loudness = std::nullopt; s.beatgrid.clear(); - s.bitrate = djinterop::stdx::nullopt; - s.bpm = djinterop::stdx::nullopt; - s.comment = djinterop::stdx::nullopt; - s.composer = djinterop::stdx::nullopt; - s.duration = djinterop::stdx::nullopt; - s.file_bytes = djinterop::stdx::nullopt; - s.genre = djinterop::stdx::nullopt; + s.bitrate = std::nullopt; + s.bpm = std::nullopt; + s.comment = std::nullopt; + s.composer = std::nullopt; + s.duration = std::nullopt; + s.file_bytes = std::nullopt; + s.genre = std::nullopt; s.hot_cues.clear(); if (usage == example_track_data_usage::fetch) s.hot_cues.resize(8); - s.key = djinterop::stdx::nullopt; - s.last_played_at = djinterop::stdx::nullopt; + s.key = std::nullopt; + s.last_played_at = std::nullopt; s.loops.clear(); if (usage == example_track_data_usage::fetch) s.loops.resize(8); - s.main_cue = djinterop::stdx::nullopt; - s.publisher = djinterop::stdx::nullopt; - s.relative_path = djinterop::stdx::nullopt; - s.sample_count = djinterop::stdx::nullopt; - s.sample_rate = djinterop::stdx::nullopt; - s.title = djinterop::stdx::nullopt; - s.track_number = djinterop::stdx::nullopt; + s.main_cue = std::nullopt; + s.publisher = std::nullopt; + s.relative_path = std::nullopt; + s.sample_count = std::nullopt; + s.sample_rate = std::nullopt; + s.title = std::nullopt; + s.track_number = std::nullopt; s.waveform.clear(); - s.year = djinterop::stdx::nullopt; + s.year = std::nullopt; break; case example_track_data_variation::minimal_1: - s.album = djinterop::stdx::nullopt; - s.artist = djinterop::stdx::nullopt; - s.average_loudness = djinterop::stdx::nullopt; + s.album = std::nullopt; + s.artist = std::nullopt; + s.average_loudness = std::nullopt; s.beatgrid.clear(); - s.bitrate = djinterop::stdx::nullopt; - s.bpm = djinterop::stdx::nullopt; - s.comment = djinterop::stdx::nullopt; - s.composer = djinterop::stdx::nullopt; - s.duration = djinterop::stdx::nullopt; - s.file_bytes = djinterop::stdx::nullopt; - s.genre = djinterop::stdx::nullopt; + s.bitrate = std::nullopt; + s.bpm = std::nullopt; + s.comment = std::nullopt; + s.composer = std::nullopt; + s.duration = std::nullopt; + s.file_bytes = std::nullopt; + s.genre = std::nullopt; s.hot_cues.clear(); if (usage == example_track_data_usage::fetch) s.hot_cues.resize(8); - s.key = djinterop::stdx::nullopt; - s.last_played_at = djinterop::stdx::nullopt; + s.key = std::nullopt; + s.last_played_at = std::nullopt; s.loops.clear(); if (usage == example_track_data_usage::fetch) s.loops.resize(8); - s.main_cue = djinterop::stdx::nullopt; - s.publisher = djinterop::stdx::nullopt; + s.main_cue = std::nullopt; + s.publisher = std::nullopt; s.relative_path = "filename.ext"s; - s.sample_count = djinterop::stdx::nullopt; - s.sample_rate = djinterop::stdx::nullopt; - s.title = djinterop::stdx::nullopt; - s.track_number = djinterop::stdx::nullopt; + s.sample_count = std::nullopt; + s.sample_rate = std::nullopt; + s.title = std::nullopt; + s.track_number = std::nullopt; s.waveform.clear(); - s.year = djinterop::stdx::nullopt; + s.year = std::nullopt; break; case example_track_data_variation::basic_metadata_only_1: s.album = "Some Album"s; s.artist = "Some Artist"s; - s.average_loudness = djinterop::stdx::nullopt; + s.average_loudness = std::nullopt; s.beatgrid.clear(); s.bitrate = 320; s.bpm = 123; s.comment = "Comment"s; s.composer = "Composer"s; s.duration = std::chrono::milliseconds{210000}; - s.file_bytes = djinterop::stdx::nullopt; + s.file_bytes = std::nullopt; s.genre = "Genre"s; s.hot_cues.clear(); if (usage == example_track_data_usage::fetch) @@ -169,11 +169,11 @@ inline void populate_track_snapshot( if (usage == example_track_data_usage::fetch) s.loops.resize(8); - s.main_cue = djinterop::stdx::nullopt; + s.main_cue = std::nullopt; s.publisher = "Publisher"s; s.relative_path = "../01 - Some Artist - Some Track.mp3"s; - s.sample_count = djinterop::stdx::nullopt; - s.sample_rate = djinterop::stdx::nullopt; + s.sample_count = std::nullopt; + s.sample_rate = std::nullopt; s.title = "Some Title"s; s.track_number = 1; s.waveform.clear(); diff --git a/test/djinterop/engine/track_test.cpp b/test/djinterop/engine/track_test.cpp index 014f777..6bc8475 100644 --- a/test/djinterop/engine/track_test.cpp +++ b/test/djinterop/engine/track_test.cpp @@ -233,5 +233,5 @@ BOOST_DATA_TEST_CASE( track.set_average_loudness(0); // Assert - BOOST_CHECK(track.average_loudness() == djinterop::stdx::nullopt); + BOOST_CHECK(track.average_loudness() == std::nullopt); } diff --git a/test/djinterop/engine/v2/example_track_row_data.hpp b/test/djinterop/engine/v2/example_track_row_data.hpp index 1e9afd2..732cf78 100644 --- a/test/djinterop/engine/v2/example_track_row_data.hpp +++ b/test/djinterop/engine/v2/example_track_row_data.hpp @@ -117,7 +117,7 @@ inline void populate_track_row( if (version.schema_version >= djinterop::semantic_version{2, 20, 1}) r.active_on_load_loops = 123; else - r.active_on_load_loops = djinterop::stdx::nullopt; + r.active_on_load_loops = std::nullopt; r.last_edit_time = ev2::LAST_EDIT_TIME_NONE; @@ -183,7 +183,7 @@ inline void populate_track_row( if (version.schema_version >= djinterop::semantic_version{2, 20, 1}) r.active_on_load_loops = 123; else - r.active_on_load_loops = djinterop::stdx::nullopt; + r.active_on_load_loops = std::nullopt; r.last_edit_time = ev2::LAST_EDIT_TIME_NONE; diff --git a/test/djinterop/engine/v2/track_table_test.cpp b/test/djinterop/engine/v2/track_table_test.cpp index 5ffafaf..2bf65b2 100644 --- a/test/djinterop/engine/v2/track_table_test.cpp +++ b/test/djinterop/engine/v2/track_table_test.cpp @@ -105,7 +105,7 @@ BOOST_DATA_TEST_CASE( auto actual = track_tbl.get(id); // Assert - BOOST_REQUIRE(actual != djinterop::stdx::nullopt); + BOOST_REQUIRE(actual != std::nullopt); actual->last_edit_time = expected.last_edit_time; BOOST_CHECK_EQUAL(expected, *actual); } @@ -153,7 +153,7 @@ BOOST_DATA_TEST_CASE( "(" << version << ", " << initial_row_type << ", " << update_row_type << ") Fetching track..."); auto actual = track_tbl.get(id); - BOOST_REQUIRE(actual != djinterop::stdx::nullopt); + BOOST_REQUIRE(actual != std::nullopt); actual->last_edit_time = expected.last_edit_time; BOOST_CHECK_EQUAL(expected, *actual); }