mirror of https://github.com/AxioDL/amuse.git
string_view refactor
This commit is contained in:
parent
e18c0a62de
commit
75830dc6dd
|
@ -64,7 +64,7 @@ struct AudioGroupDataCollection
|
|||
bool loadSamp(AudioGroupFilePresenter* presenter);
|
||||
bool loadMeta(AudioGroupFilePresenter* presenter);
|
||||
|
||||
AudioGroupDataCollection(const std::string& name, NSURL* proj, NSURL* pool, NSURL* sdir, NSURL* samp, NSURL* meta);
|
||||
AudioGroupDataCollection(std::string_view name, NSURL* proj, NSURL* pool, NSURL* sdir, NSURL* samp, NSURL* meta);
|
||||
bool isDataComplete() const
|
||||
{
|
||||
return m_projData.size() && m_poolData.size() && m_sdirData.size() && m_sampData.size() && m_metaData;
|
||||
|
@ -88,7 +88,7 @@ struct AudioGroupCollection
|
|||
void addCollection(AudioGroupFilePresenter* presenter,
|
||||
std::vector<std::pair<std::string, amuse::IntrusiveAudioGroupData>>&& collection);
|
||||
void update(AudioGroupFilePresenter* presenter);
|
||||
bool doSearch(const std::string& str);
|
||||
bool doSearch(std::string_view str);
|
||||
bool doActiveFilter();
|
||||
void addSFX(std::vector<AudioGroupSFXToken*>& vecOut);
|
||||
void addSamples(std::vector<AudioGroupSampleToken*>& vecOut);
|
||||
|
|
|
@ -161,13 +161,13 @@ void AudioGroupCollection::update(AudioGroupFilePresenter* presenter)
|
|||
}
|
||||
}
|
||||
|
||||
bool AudioGroupCollection::doSearch(const std::string& str)
|
||||
bool AudioGroupCollection::doSearch(std::string_view str)
|
||||
{
|
||||
bool ret = false;
|
||||
m_filterGroups.clear();
|
||||
m_filterGroups.reserve(m_groups.size());
|
||||
for (auto it = m_groups.begin() ; it != m_groups.end() ; ++it)
|
||||
if (str.empty() || StrToLower(it->first).find(str) != std::string::npos)
|
||||
if (str.empty() || StrToLower(it->first).find(str.data()) != std::string::npos)
|
||||
{
|
||||
m_filterGroups.push_back(it);
|
||||
ret = true;
|
||||
|
|
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) # because of CMAKE_CXX_STANDAR
|
|||
|
||||
project(amuse)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(NOT MSVC)
|
||||
|
|
|
@ -217,7 +217,7 @@ bool AudioGroupDataCollection::loadMeta()
|
|||
return ret.operator bool();
|
||||
}
|
||||
|
||||
AudioGroupDataCollection::AudioGroupDataCollection(const std::wstring& path, const std::wstring& name)
|
||||
AudioGroupDataCollection::AudioGroupDataCollection(std::wstring_view path, std::wstring_view name)
|
||||
: m_path(path), m_name(name)
|
||||
{
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ void AudioGroupDataCollection::addToEngine(amuse::Engine& engine)
|
|||
|
||||
void AudioGroupDataCollection::removeFromEngine(amuse::Engine& engine) const { engine.removeAudioGroup(*m_loadedData); }
|
||||
|
||||
AudioGroupCollection::AudioGroupCollection(const std::wstring& path, const std::wstring& name)
|
||||
AudioGroupCollection::AudioGroupCollection(std::wstring_view path, std::wstring_view name)
|
||||
: m_path(path), m_name(name)
|
||||
{
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ void AudioGroupFilePresenter::update()
|
|||
}
|
||||
|
||||
void AudioGroupFilePresenter::addCollection(
|
||||
const std::wstring& name, std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection)
|
||||
std::wstring_view name, std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection)
|
||||
{
|
||||
std::wstring path = m_backend.getUserDir() + L'\\' + name;
|
||||
AudioGroupCollection& insert =
|
||||
|
|
|
@ -61,7 +61,7 @@ struct AudioGroupDataCollection
|
|||
bool loadSamp();
|
||||
bool loadMeta();
|
||||
|
||||
AudioGroupDataCollection(const std::wstring& path, const std::wstring& name);
|
||||
AudioGroupDataCollection(std::wstring_view path, std::wstring_view name);
|
||||
bool isDataComplete() const
|
||||
{
|
||||
return m_projData.size() && m_poolData.size() && m_sdirData.size() && m_sampData.size() && m_metaData;
|
||||
|
@ -82,7 +82,7 @@ struct AudioGroupCollection
|
|||
std::map<std::wstring, std::unique_ptr<AudioGroupDataCollection>> m_groups;
|
||||
std::vector<GroupIterator> m_iteratorVec;
|
||||
|
||||
AudioGroupCollection(const std::wstring& path, const std::wstring& name);
|
||||
AudioGroupCollection(std::wstring_view path, std::wstring_view name);
|
||||
void addCollection(std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection);
|
||||
void update(AudioGroupFilePresenter& presenter);
|
||||
void populateFiles(VSTEditor& editor, HTREEITEM colHandle, size_t parentIdx);
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
void populateCollectionColumn(VSTEditor& editor);
|
||||
void populateGroupColumn(VSTEditor& editor, int collectionIdx, int fileIdx);
|
||||
void populatePageColumn(VSTEditor& editor, int collectionIdx, int fileIdx, int groupIdx);
|
||||
void addCollection(const std::wstring& name,
|
||||
void addCollection(std::wstring_view name,
|
||||
std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>>&& collection);
|
||||
void removeCollection(unsigned idx);
|
||||
VSTBackend& getBackend() { return m_backend; }
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
void setBlockSize(VstInt32 blockSize);
|
||||
|
||||
amuse::Engine& getAmuseEngine() { return *m_engine; }
|
||||
const std::wstring& getUserDir() const { return m_userDir; }
|
||||
std::wstring_view getUserDir() const { return m_userDir; }
|
||||
AudioGroupFilePresenter& getFilePresenter() { return m_filePresenter; }
|
||||
|
||||
void loadGroupFile(int collectionIdx, int fileIdx);
|
||||
|
|
|
@ -31,22 +31,22 @@ static void ReportConvType(ConvType tp)
|
|||
}
|
||||
}
|
||||
|
||||
static bool BuildAudioGroup(const amuse::SystemString& groupBase, const amuse::SystemString& targetPath)
|
||||
static bool BuildAudioGroup(amuse::SystemStringView groupBase, amuse::SystemStringView targetPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ExtractAudioGroup(const amuse::SystemString& inPath, const amuse::SystemString& targetPath)
|
||||
static bool ExtractAudioGroup(amuse::SystemStringView inPath, amuse::SystemStringView targetPath)
|
||||
{
|
||||
amuse::ContainerRegistry::Type type;
|
||||
auto groups = amuse::ContainerRegistry::LoadContainer(inPath.c_str(), type);
|
||||
auto groups = amuse::ContainerRegistry::LoadContainer(inPath.data(), type);
|
||||
|
||||
if (groups.size())
|
||||
{
|
||||
Log.report(logvisor::Info, _S("Found '%s'"), amuse::ContainerRegistry::TypeToName(type));
|
||||
|
||||
amuse::Mkdir(targetPath.c_str(), 0755);
|
||||
Log.report(logvisor::Info, _S("Established directory at %s"), targetPath.c_str());
|
||||
amuse::Mkdir(targetPath.data(), 0755);
|
||||
Log.report(logvisor::Info, _S("Established directory at %s"), targetPath.data());
|
||||
|
||||
for (auto& group : groups)
|
||||
{
|
||||
|
@ -54,14 +54,14 @@ static bool ExtractAudioGroup(const amuse::SystemString& inPath, const amuse::Sy
|
|||
}
|
||||
}
|
||||
|
||||
auto songs = amuse::ContainerRegistry::LoadSongs(inPath.c_str());
|
||||
auto songs = amuse::ContainerRegistry::LoadSongs(inPath.data());
|
||||
amuse::SystemString songsDir = targetPath + _S("/midifiles");
|
||||
bool madeDir = false;
|
||||
for (auto& pair : songs)
|
||||
{
|
||||
if (!madeDir)
|
||||
{
|
||||
amuse::Mkdir(targetPath.c_str(), 0755);
|
||||
amuse::Mkdir(targetPath.data(), 0755);
|
||||
amuse::Mkdir(songsDir.c_str(), 0755);
|
||||
madeDir = true;
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ static bool ExtractAudioGroup(const amuse::SystemString& inPath, const amuse::Sy
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool BuildSNG(const amuse::SystemString& inPath, const amuse::SystemString& targetPath, int version, bool big)
|
||||
static bool BuildSNG(amuse::SystemStringView inPath, amuse::SystemStringView targetPath, int version, bool big)
|
||||
{
|
||||
FILE* fp = amuse::FOpen(inPath.c_str(), _S("rb"));
|
||||
FILE* fp = amuse::FOpen(inPath.data(), _S("rb"));
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
|
@ -100,16 +100,16 @@ static bool BuildSNG(const amuse::SystemString& inPath, const amuse::SystemStrin
|
|||
if (out.empty())
|
||||
return false;
|
||||
|
||||
fp = amuse::FOpen(targetPath.c_str(), _S("wb"));
|
||||
fp = amuse::FOpen(targetPath.data(), _S("wb"));
|
||||
fwrite(out.data(), 1, out.size(), fp);
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ExtractSNG(const amuse::SystemString& inPath, const amuse::SystemString& targetPath)
|
||||
static bool ExtractSNG(amuse::SystemStringView inPath, amuse::SystemStringView targetPath)
|
||||
{
|
||||
FILE* fp = amuse::FOpen(inPath.c_str(), _S("rb"));
|
||||
FILE* fp = amuse::FOpen(inPath.data(), _S("rb"));
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
|
@ -126,7 +126,7 @@ static bool ExtractSNG(const amuse::SystemString& inPath, const amuse::SystemStr
|
|||
if (out.empty())
|
||||
return false;
|
||||
|
||||
fp = amuse::FOpen(targetPath.c_str(), _S("wb"));
|
||||
fp = amuse::FOpen(targetPath.data(), _S("wb"));
|
||||
fwrite(out.data(), 1, out.size(), fp);
|
||||
fclose(fp);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -47,6 +48,7 @@ static inline int Mkdir(const wchar_t* path, int) { return _wmkdir(path); }
|
|||
static inline int Stat(const wchar_t* path, Sstat* statout) { return _wstat(path, statout); }
|
||||
#else
|
||||
using SystemString = std::string;
|
||||
using SystemStringView = std::string_view;
|
||||
using SystemChar = char;
|
||||
#ifndef _S
|
||||
#define _S(val) val
|
||||
|
|
|
@ -9,21 +9,21 @@ namespace amuse
|
|||
|
||||
struct CaseInsensitiveCompare
|
||||
{
|
||||
bool operator()(const std::string& lhs, const std::string& rhs) const
|
||||
bool operator()(std::string_view lhs, std::string_view rhs) const
|
||||
{
|
||||
#if _WIN32
|
||||
if (_stricmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||
if (_stricmp(lhs.data(), rhs.data()) < 0)
|
||||
#else
|
||||
if (strcasecmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||
if (strcasecmp(lhs.data(), rhs.data()) < 0)
|
||||
#endif
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
bool operator()(const std::wstring& lhs, const std::wstring& rhs) const
|
||||
bool operator()(std::wstring_view lhs, std::wstring_view rhs) const
|
||||
{
|
||||
if (_wcsicmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||
if (_wcsicmp(lhs.data(), rhs.data()) < 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -59,12 +59,7 @@ private:
|
|||
std::vector<Entry> m_entries;
|
||||
|
||||
public:
|
||||
DirectoryEnumerator(const SystemString& path, Mode mode = Mode::DirsThenFilesSorted, bool sizeSort = false,
|
||||
bool reverse = false, bool noHidden = false)
|
||||
: DirectoryEnumerator(path.c_str(), mode, sizeSort, reverse, noHidden)
|
||||
{
|
||||
}
|
||||
DirectoryEnumerator(const SystemChar* path, Mode mode = Mode::DirsThenFilesSorted, bool sizeSort = false,
|
||||
DirectoryEnumerator(SystemStringView path, Mode mode = Mode::DirsThenFilesSorted, bool sizeSort = false,
|
||||
bool reverse = false, bool noHidden = false);
|
||||
|
||||
operator bool() const { return m_entries.size() != 0; }
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
namespace amuse
|
||||
{
|
||||
|
||||
DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool sizeSort, bool reverse, bool noHidden)
|
||||
DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, bool sizeSort, bool reverse, bool noHidden)
|
||||
{
|
||||
Sstat theStat;
|
||||
if (Stat(path, &theStat) || !S_ISDIR(theStat.st_mode))
|
||||
if (Stat(path.data(), &theStat) || !S_ISDIR(theStat.st_mode))
|
||||
return;
|
||||
|
||||
#if _WIN32
|
||||
|
@ -160,7 +160,7 @@ DirectoryEnumerator::DirectoryEnumerator(const SystemChar* path, Mode mode, bool
|
|||
|
||||
#else
|
||||
|
||||
DIR* dir = opendir(path);
|
||||
DIR* dir = opendir(path.data());
|
||||
if (!dir)
|
||||
return;
|
||||
const dirent* d;
|
||||
|
|
Loading…
Reference in New Issue