Added an external header library for filesystem that defaults to the standard library on cpp 17 and finished cleaning up the c++14 issues
This commit is contained in:
parent
0eb960f028
commit
7c1fc138e5
22 changed files with 5467 additions and 99 deletions
|
|
@ -1,7 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
project(sfizz VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# Set the highest possible standard
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# Enable LTO
|
||||
|
|
@ -12,6 +11,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
|||
set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang")
|
||||
add_compile_options(-stdlib=libc++)
|
||||
# Presumably need the above for linking too, maybe other options missing as well
|
||||
add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release
|
||||
add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "Parser.h"
|
||||
#include "StringViewHelpers.h"
|
||||
#include "compat/filesystem.h"
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
#include <absl/flags/parse.h>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include "ADSREnvelope.h"
|
||||
#include "Config.h"
|
||||
#include "SIMDHelpers.h"
|
||||
#include "compat/algorithm.h"
|
||||
#include "MathHelpers.h"
|
||||
|
||||
namespace sfz {
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ void ADSREnvelope<Type>::reset(int attack, int release, Type sustain, int delay,
|
|||
ASSERT(start <= 1.0f);
|
||||
ASSERT(sustain <= 1.0f);
|
||||
|
||||
sustain = std::clamp<Type>(sustain, 0.0, 1.0);
|
||||
start = std::clamp<Type>(start, 0.0, 1.0);
|
||||
sustain = clamp<Type>(sustain, 0.0, 1.0);
|
||||
start = clamp<Type>(start, 0.0, 1.0);
|
||||
|
||||
currentState = State::Done;
|
||||
this->delay = delay;
|
||||
|
|
|
|||
|
|
@ -36,26 +36,20 @@ endif()
|
|||
|
||||
set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
|
||||
|
||||
# include(CheckCXXSourceCompiles)
|
||||
# check_cxx_source_compiles("
|
||||
# #include <filesystem>
|
||||
|
||||
# int main(int argc, char** argv)
|
||||
# {
|
||||
# std::filesystem::path p;
|
||||
# return 0;
|
||||
# }
|
||||
# " HAVE_STD_FILESYSTEM)
|
||||
|
||||
check_include_file_cxx("filesystem" HAVE_STD_FILESYSTEM)
|
||||
if (HAVE_STD_FILESYSTEM)
|
||||
# if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
|
||||
# add_compile_options(-DUSE_STD_FILESYSTEM)
|
||||
# endif()
|
||||
if (WIN32)
|
||||
add_compile_options(/DUSE_STD_FILESYSTEM)
|
||||
endif()
|
||||
endif()
|
||||
# check_include_file_cxx("filesystem" HAVE_STD_FILESYSTEM)
|
||||
# if (HAVE_STD_FILESYSTEM)
|
||||
# if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# # add_compile_options(-DUSE_STD_FILESYSTEM)
|
||||
# if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
|
||||
# link_libraries(c++fs)
|
||||
# endif()
|
||||
# elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
# link_libraries(stdc++fs)
|
||||
# elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
# add_compile_options(/DINCLUDE_STD_FILESYSTEM)
|
||||
# add_compile_options(/DUSE_STD_FILESYSTEM)
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
|
||||
add_library(sfizz_parser STATIC)
|
||||
|
|
@ -63,14 +57,6 @@ target_sources(sfizz_parser PRIVATE Parser.cpp Opcode.cpp)
|
|||
target_include_directories(sfizz_parser PUBLIC .)
|
||||
target_link_libraries(sfizz_parser PRIVATE absl::strings)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
||||
target_link_libraries(sfizz_parser PUBLIC c++fs)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_link_libraries(sfizz_parser PUBLIC stdc++fs)
|
||||
endif()
|
||||
|
||||
|
||||
add_library(sfizz STATIC ${SFIZZ_SOURCES})
|
||||
target_link_libraries(sfizz PRIVATE sfizz_parser)
|
||||
|
|
@ -81,14 +67,6 @@ if(UNIX)
|
|||
target_link_libraries(sfizz PUBLIC atomic)
|
||||
endif(UNIX)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
||||
target_link_libraries(sfizz PUBLIC c++fs)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_link_libraries(sfizz PUBLIC stdc++fs)
|
||||
endif()
|
||||
|
||||
target_link_libraries(sfizz PUBLIC absl::strings)
|
||||
target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include "LeakDetector.h"
|
||||
#include "AudioBuffer.h"
|
||||
#include "Voice.h"
|
||||
#include "compat/filesystem.h"
|
||||
#include "ghc/fs_std.hpp"
|
||||
#include "readerwriterqueue.h"
|
||||
#include <absl/container/flat_hash_map.h>
|
||||
#include <mutex>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#pragma once
|
||||
#include <atomic>
|
||||
#include "Debug.h"
|
||||
#include "compat/utils.h"
|
||||
|
||||
template <class Owner>
|
||||
class LeakDetector {
|
||||
|
|
@ -60,7 +59,7 @@ private:
|
|||
};
|
||||
std::atomic<int> count { 0 };
|
||||
};
|
||||
static SFZ_INLINE ObjectCounter objectCounter;
|
||||
static ObjectCounter objectCounter;
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@
|
|||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#include "compat/utils.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <random>
|
||||
|
||||
template <class T>
|
||||
|
|
@ -60,8 +60,8 @@ inline constexpr Type mag2db(Type in)
|
|||
}
|
||||
|
||||
namespace Random {
|
||||
static SFZ_INLINE std::random_device randomDevice;
|
||||
static SFZ_INLINE std::mt19937 randomGenerator { randomDevice() };
|
||||
static std::random_device randomDevice;
|
||||
static std::mt19937 randomGenerator { randomDevice() };
|
||||
} // namespace Random
|
||||
|
||||
inline float midiNoteFrequency(const int noteNumber)
|
||||
|
|
@ -69,6 +69,13 @@ inline float midiNoteFrequency(const int noteNumber)
|
|||
return 440.0f * std::pow(2.0f, (noteNumber - 69) / 12.0f);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi )
|
||||
{
|
||||
assert( !(hi < lo) );
|
||||
return (v < lo) ? lo : (hi < v) ? hi : v;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
constexpr Type pi { 3.141592653589793238462643383279502884 };
|
||||
template <class Type>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include <chrono>
|
||||
#include <array>
|
||||
#include "SfzHelpers.h"
|
||||
#include "compat/utils.h"
|
||||
|
||||
namespace sfz
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Opcode.h"
|
||||
#include "compat/filesystem.h"
|
||||
#include "ghc/fs_std.hpp"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "absl/strings/string_view.h"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#include "compat/algorithm.h"
|
||||
#include "MathHelpers.h"
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ public:
|
|||
if (end < _start)
|
||||
_start = end;
|
||||
}
|
||||
Type clamp(Type value) const noexcept { return std::clamp(value, _start, _end); }
|
||||
Type clamp(Type value) const noexcept { return ::clamp(value, _start, _end); }
|
||||
bool containsWithEnd(Type value) const noexcept { return (value >= _start && value <= _end); }
|
||||
bool contains(Type value) const noexcept { return (value >= _start && value < _end); }
|
||||
void shrinkIfSmaller(Type start, Type end)
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if __cplusplus <= 201402L
|
||||
#include <cassert>
|
||||
namespace std
|
||||
{
|
||||
template<class T>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi )
|
||||
{
|
||||
assert( !(hi < lo) );
|
||||
return (v < lo) ? lo : (hi < v) ? hi : v;
|
||||
}
|
||||
}
|
||||
#endif // lower than C++17
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#pragma once
|
||||
#ifdef USE_STD_FILESYSTEM
|
||||
#warning FS
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
#warning EXPFS
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
// #if __cplusplus < 201703L
|
||||
// #warning EXPFSNS
|
||||
// #else
|
||||
// #warning FSNS
|
||||
// #endif
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
||||
#define SFZ_HAVE_CXX17 1
|
||||
#define SFZ_INLINE inline
|
||||
#else
|
||||
#define SFZ_HAVE_CXX17 0
|
||||
#define SFZ_INLINE
|
||||
#endif
|
||||
#else
|
||||
#error unknown error
|
||||
#endif
|
||||
5159
sfizz/ghc/filesystem.hpp
Normal file
5159
sfizz/ghc/filesystem.hpp
Normal file
File diff suppressed because it is too large
Load diff
46
sfizz/ghc/fs_fwd.hpp
Normal file
46
sfizz/ghc/fs_fwd.hpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// fs_fwd.hpp - The forwarding header for the header/implementation seperated usage of
|
||||
// ghc::filesystem.
|
||||
// This file can be include at any place, where ghc::filesystem api is needed while
|
||||
// not bleeding implementation details (e.g. system includes) into the global namespace,
|
||||
// as long as one cpp includes fs_impl.hpp to deliver the matching implementations.
|
||||
//---------------------------------------------------------------------------------------
|
||||
#ifndef GHC_FILESYSTEM_FWD_H
|
||||
#define GHC_FILESYSTEM_FWD_H
|
||||
#define GHC_FILESYSTEM_FWD
|
||||
#include <ghc/filesystem.hpp>
|
||||
#endif // GHC_FILESYSTEM_FWD_H
|
||||
43
sfizz/ghc/fs_impl.hpp
Normal file
43
sfizz/ghc/fs_impl.hpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// fs_impl.hpp - The implementation header for the header/implementation seperated usage of
|
||||
// ghc::filesystem.
|
||||
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
|
||||
// The cpp has to include this before including fs_fwd.hpp directly or via a different
|
||||
// header to work.
|
||||
//---------------------------------------------------------------------------------------
|
||||
#define GHC_FILESYSTEM_IMPLEMENTATION
|
||||
#include <ghc/filesystem.hpp>
|
||||
64
sfizz/ghc/fs_std.hpp
Normal file
64
sfizz/ghc/fs_std.hpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// fs_std.hpp - The dynamic switching header that includes std::filesystem if detected
|
||||
// or ghc::filesystem if not, and makes the resulting API available in the
|
||||
// namespace fs.
|
||||
//---------------------------------------------------------------------------------------
|
||||
#ifndef GHC_FILESYSTEM_STD_H
|
||||
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
|
||||
#if __has_include(<filesystem>)
|
||||
#define GHC_USE_STD_FS
|
||||
#include <filesystem>
|
||||
namespace fs {
|
||||
using namespace std::filesystem;
|
||||
using ifstream = std::ifstream;
|
||||
using ofstream = std::ofstream;
|
||||
using fstream = std::fstream;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifndef GHC_USE_STD_FS
|
||||
#define GHC_WIN_WSTRING_STRING_TYPE
|
||||
#include <ghc/filesystem.hpp>
|
||||
namespace fs {
|
||||
using namespace ghc::filesystem;
|
||||
using ifstream = ghc::filesystem::ifstream;
|
||||
using ofstream = ghc::filesystem::ofstream;
|
||||
using fstream = ghc::filesystem::fstream;
|
||||
}
|
||||
#endif
|
||||
#endif // GHC_FILESYSTEM_STD_H
|
||||
|
||||
68
sfizz/ghc/fs_std_fwd.hpp
Normal file
68
sfizz/ghc/fs_std_fwd.hpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// fs_std_fwd.hpp - The forwarding header for the header/implementation seperated usage of
|
||||
// ghc::filesystem that uses std::filesystem if it detects it.
|
||||
// This file can be include at any place, where fs::filesystem api is needed while
|
||||
// not bleeding implementation details (e.g. system includes) into the global namespace,
|
||||
// as long as one cpp includes fs_std_impl.hpp to deliver the matching implementations.
|
||||
//---------------------------------------------------------------------------------------
|
||||
#ifndef GHC_FILESYSTEM_STD_FWD_H
|
||||
#define GHC_FILESYSTEM_STD_FWD_H
|
||||
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
|
||||
#if __has_include(<filesystem>)
|
||||
#define GHC_USE_STD_FS
|
||||
#include <filesystem>
|
||||
namespace fs {
|
||||
using namespace std::filesystem;
|
||||
using ifstream = std::ifstream;
|
||||
using ofstream = std::ofstream;
|
||||
using fstream = std::fstream;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifndef GHC_USE_STD_FS
|
||||
#define GHC_WIN_WSTRING_STRING_TYPE
|
||||
#define GHC_FILESYSTEM_FWD
|
||||
#include <ghc/filesystem.hpp>
|
||||
namespace fs {
|
||||
using namespace ghc::filesystem;
|
||||
using ifstream = ghc::filesystem::ifstream;
|
||||
using ofstream = ghc::filesystem::ofstream;
|
||||
using fstream = ghc::filesystem::fstream;
|
||||
}
|
||||
#endif
|
||||
#endif // GHC_FILESYSTEM_STD_FWD_H
|
||||
|
||||
51
sfizz/ghc/fs_std_impl.hpp
Normal file
51
sfizz/ghc/fs_std_impl.hpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------------
|
||||
// fs_std_impl.hpp - The implementation header for the header/implementation seperated usage of
|
||||
// ghc::filesystem that does nothing if std::filesystem is detected.
|
||||
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
|
||||
// The cpp has to include this before including fs_std_fwd.hpp directly or via a different
|
||||
// header to work.
|
||||
//---------------------------------------------------------------------------------------
|
||||
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
|
||||
#if __has_include(<filesystem>)
|
||||
#define GHC_USE_STD_FS
|
||||
#endif
|
||||
#endif
|
||||
#ifndef GHC_USE_STD_FS
|
||||
#define GHC_WIN_WSTRING_STRING_TYPE
|
||||
#define GHC_FILESYSTEM_IMPLEMENTATION
|
||||
#include <ghc/filesystem.hpp>
|
||||
#endif
|
||||
|
|
@ -33,7 +33,7 @@ target_link_libraries(sfizz_tests PRIVATE sfizz)
|
|||
|
||||
# Per OS properties
|
||||
if(UNIX)
|
||||
target_link_libraries(sfizz_tests PRIVATE stdc++fs atomic)
|
||||
target_link_libraries(sfizz_tests PRIVATE atomic)
|
||||
endif(UNIX)
|
||||
target_link_libraries(sfizz_tests PRIVATE absl::strings absl::str_format absl::flat_hash_map sndfile cnpy absl::span absl::algorithm)
|
||||
target_include_directories(sfizz_tests SYSTEM PRIVATE sources)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "Synth.h"
|
||||
#include "catch2/catch.hpp"
|
||||
#include "../sfizz/compat/filesystem.h"
|
||||
#include "../sfizz/ghc/fs_std.hpp"
|
||||
using namespace Catch::literals;
|
||||
|
||||
TEST_CASE("[Files] Single region (regions_one.sfz)")
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include "OnePoleFilter.h"
|
||||
#include "catch2/catch.hpp"
|
||||
#include "cnpy.h"
|
||||
#include "../sfizz/compat/filesystem.h"
|
||||
#include "../sfizz/ghc/fs_std.hpp"
|
||||
#include <absl/types/span.h>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue