Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to C++20 #408

Merged
merged 1 commit into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ msbuild /m /p:Platform=Win32 /p:Configuration=Release /t:Rebuild vc16\columns_ui

#### Using the Clang compiler (experimental)

Note: Currently not functional out of the box – should be functional again when the LLVM bundled with Visual Studio is updated to version 13.

Columns UI can be also compiled using the version of Clang distributed with Visual Studio.

(Note that Clang is not installed by default – in the Visual Studio 2019 installer, you will need to select the Clang compiler and the Clang build tools components.)
Expand Down
2 changes: 1 addition & 1 deletion fbh
Submodule fbh updated 2 files
+70 −13 .clang-format
+5 −5 fbh.vcxproj
2 changes: 1 addition & 1 deletion foo_ui_columns/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: c++17
Standard: c++20
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand Down
4 changes: 2 additions & 2 deletions foo_ui_columns/artwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void ArtworkPanel::show_stub_image()
const auto bitmap_data = cui::wic::decode_image_data(data->get_ptr(), data->get_size());
m_image = cui::gdip::create_bitmap_from_wic_data(bitmap_data);
} catch (const std::exception& ex) {
fbh::print_to_console(u8"Artwork panel – loading stub image failed: ", ex.what());
fbh::print_to_console(u8"Artwork panel – loading stub image failed: "_pcc, ex.what());
}
}

Expand All @@ -444,7 +444,7 @@ bool ArtworkPanel::refresh_image(std::optional<size_t> artwork_type_index_overri
const auto bitmap_data = cui::wic::decode_image_data(data->get_ptr(), data->get_size());
m_image = cui::gdip::create_bitmap_from_wic_data(bitmap_data);
} catch (const std::exception& ex) {
fbh::print_to_console(u8"Artwork panel – loading image failed: ", ex.what());
fbh::print_to_console(u8"Artwork panel – loading image failed: "_pcc, ex.what());
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions foo_ui_columns/artwork_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ DWORD ArtworkReader::on_thread()
} catch (pfc::exception const& e) {
m_content.clear();
console::formatter formatter;
formatter << u8"Artwork view – unhandled error reading artwork: " << e.what();
formatter << u8"Artwork view – unhandled error reading artwork: "_pcc << e.what();
ret = -1;
}
ArtworkReaderNotification::g_run(m_manager, b_aborted, ret, this);
Expand All @@ -252,7 +252,7 @@ album_art_data_ptr query_artwork_data(
throw;
} catch (exception_album_art_not_found const&) {
} catch (exception_io const& ex) {
fbh::print_to_console(u8"Artwork view – error loading artwork: ", ex.what());
fbh::print_to_console(u8"Artwork view – error loading artwork: "_pcc, ex.what());
}

return {};
Expand Down
2 changes: 1 addition & 1 deletion foo_ui_columns/buttons_button_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ButtonsToolbar::ButtonImage::load(const Button::CustomImage& p_image)
try {
m_bm = cui::wic::create_hbitmap_from_path(fullPath).release();
} catch (const std::exception& ex) {
fbh::print_to_console(u8"Buttons toolbar – loading image failed: ", ex.what());
fbh::print_to_console(u8"Buttons toolbar – loading image failed: "_pcc, ex.what());
m_bm = nullptr;
}
}
Expand Down
36 changes: 18 additions & 18 deletions foo_ui_columns/commandline.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "stdafx.h"
#include "fcl.h"

static const char* g_help_text = u8"syntax: foobar2000 /columnsui:<command> \"<path>\"\n\n"
"Available commands:\n"
"help, ? – displays this command-line help\n"
"import – imports an fcl file\n"
"import-quiet – imports an fcl file without confirmation dialog boxes";
static const char8_t* g_help_text = u8"syntax: foobar2000 /columnsui:<command> \"<path>\"\n\n"
u8"Available commands:\n"
u8"help, ? – displays this command-line help\n"
u8"import – imports an fcl file\n"
u8"import-quiet – imports an fcl file without confirmation dialog boxes";

class HelpCommandLineHandler : public commandline_handler {
public:
result on_token(const char* token) override
{
if (stricmp_utf8_partial(token, u8"/columnsui:help") != 0 && stricmp_utf8_partial(token, u8"/columnsui:?") != 0)
if (stricmp_utf8_partial(token, "/columnsui:help") != 0 && stricmp_utf8_partial(token, "/columnsui:?") != 0)
return RESULT_NOT_OURS;

execute();
Expand All @@ -21,7 +21,7 @@ class HelpCommandLineHandler : public commandline_handler {
{
HWND parent = core_api::get_main_window();
static_api_ptr_t<ui_control>()->activate();
uMessageBox(parent, g_help_text, u8"Columns UI command-line help", 0);
uMessageBox(parent, reinterpret_cast<const char*>(g_help_text), "Columns UI command-line help", 0);
}
};

Expand Down Expand Up @@ -63,16 +63,16 @@ class ImportCommandLineHandler : public commandline_handler {
CommandLineSingleFileHelper m_single_file_helper;

ImportCommandLineHandler()
: m_single_file_helper{u8"Import configuration – Columns UI", u8"No file to import specified.",
u8"Too many files to import specified. You can only import one file at a time, "
: m_single_file_helper{u8"Import configuration – Columns UI"_pcc, "No file to import specified.",
"Too many files to import specified. You can only import one file at a time, "
"and should use double quotes around paths containing spaces."}
{
}

result on_token(const char* token) override
{
m_is_quiet = !stricmp_utf8(token, u8"/columnsui:import-quiet");
const auto is_import = m_is_quiet || !stricmp_utf8(token, u8"/columnsui:import");
m_is_quiet = !stricmp_utf8(token, "/columnsui:import-quiet");
const auto is_import = m_is_quiet || !stricmp_utf8(token, "/columnsui:import");

if (!is_import)
return RESULT_NOT_OURS;
Expand All @@ -98,9 +98,9 @@ class ImportCommandLineHandler : public commandline_handler {
if (!is_quiet) {
static_api_ptr_t<ui_control>()->activate();
if (uMessageBox(main_window,
formatter << u8"Are you sure you want to import " << pfc::string_filename_ext(path)
<< u8"? Your current Columns UI configuration will be lost.",
u8"Import configuration", MB_YESNO)
formatter << "Are you sure you want to import " << pfc::string_filename_ext(path)
<< "? Your current Columns UI configuration will be lost.",
"Import configuration", MB_YESNO)
== IDNO) {
return;
}
Expand All @@ -115,16 +115,16 @@ class ExportCommandLineHandler : public commandline_handler {
CommandLineSingleFileHelper m_single_file_helper;

ExportCommandLineHandler()
: m_single_file_helper{u8"Export configuration – Columns UI", u8"No file to export to specified.",
u8"Too many destination files specified. You must specify only one destination path, "
: m_single_file_helper{u8"Export configuration – Columns UI"_pcc, "No file to export to specified.",
"Too many destination files specified. You must specify only one destination path, "
"and should use double quotes around paths containing spaces."}
{
}

result on_token(const char* token) override
{
m_is_quiet = !stricmp_utf8(token, u8"/columnsui:export-quiet");
const auto is_import = m_is_quiet || !stricmp_utf8(token, u8"/columnsui:export");
m_is_quiet = !stricmp_utf8(token, "/columnsui:export-quiet");
const auto is_import = m_is_quiet || !stricmp_utf8(token, "/columnsui:export");

if (!is_import)
return RESULT_NOT_OURS;
Expand Down
10 changes: 5 additions & 5 deletions foo_ui_columns/config_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ cfg_string cfg_colour(
ConfigMenuItem cfg_playlist_double(GUID{0xffc47d9d, 0xb43d, 0x8fad, {0x8f, 0xb3, 0x42, 0x84, 0xbf, 0x9a, 0x22, 0x2a}});
cfg_string cfg_playlist_switcher_tagz(
GUID{0x13f4b9ae, 0x5db5, 0xb083, {0x15, 0x36, 0x08, 0x4d, 0x55, 0xe3, 0xb5, 0x64}},
u8"%title%\r\n"
u8"\r\n"
u8"$tab()\r\n"
u8"\r\n"
u8"$if(%is_playing%,🔉)");
reinterpret_cast<const char*>(u8"%title%\r\n"
u8"\r\n"
u8"$tab()\r\n"
u8"\r\n"
u8"$if(%is_playing%,🔉)"));

// {F006EC50-7F52-4037-9D48-7447BBF742AA}
static const GUID guid_columns = {0xf006ec50, 0x7f52, 0x4037, {0x9d, 0x48, 0x74, 0x47, 0xbb, 0xf7, 0x42, 0xaa}};
Expand Down
6 changes: 3 additions & 3 deletions foo_ui_columns/file_info_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ std::shared_ptr<file_info_impl> FullFileInfoRequest::get_safe(const char* reques
if (error_message == nullptr) {
error_message = "Unknown error";
}
formatter << requester_name << u8": Error reading file info for track \"" << display_path << u8"\": "
<< error_message;
formatter << requester_name << ": Error reading file info for track \"" << display_path
<< "\": " << error_message;
} catch (...) {
pfc::string8 display_path;
filesystem::g_get_display_path(m_track->get_path(), display_path);
formatter << requester_name << u8": Unknown error reading file info for track \"" << display_path << u8"\"";
formatter << requester_name << ": Unknown error reading file info for track \"" << display_path << "\"";
}
return nullptr;
}
Expand Down
8 changes: 4 additions & 4 deletions foo_ui_columns/foo_ui_columns.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<AdditionalOptions>/Zc:preprocessor /source-charset:utf-8 %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BufferSecurityCheck>false</BufferSecurityCheck>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Caret</DiagnosticsFormat>
Expand Down Expand Up @@ -154,7 +154,7 @@
<AdditionalOptions>/Zc:preprocessor /source-charset:utf-8 %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BufferSecurityCheck>false</BufferSecurityCheck>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Caret</DiagnosticsFormat>
Expand Down Expand Up @@ -203,7 +203,7 @@
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Caret</DiagnosticsFormat>
</ClCompile>
Expand Down Expand Up @@ -248,7 +248,7 @@
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<ConformanceMode>true</ConformanceMode>
<DiagnosticsFormat>Caret</DiagnosticsFormat>
</ClCompile>
Expand Down
4 changes: 2 additions & 2 deletions foo_ui_columns/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ void cui::MainWindow::queue_taskbar_button_update(bool update)
void cui::MainWindow::warn_if_ui_hacks_installed()
{
constexpr auto ui_hacks_warning
= u8"Columns UI detected that the UI Hacks (foo_ui_hacks) component is installed. UI Hacks "
u8"interferes with normal Columns UI operation and should be uninstalled to avoid problems.";
= "Columns UI detected that the UI Hacks (foo_ui_hacks) component is installed. UI Hacks "
"interferes with normal Columns UI operation and should be uninstalled to avoid problems.";

HMODULE ui_hacks_module = nullptr;
const auto is_ui_hacks_installed
Expand Down
6 changes: 3 additions & 3 deletions foo_ui_columns/ng_playlist/ng_playlist_artwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ DWORD ArtworkReader::on_thread()
} catch (pfc::exception const& e) {
m_bitmaps.clear();
console::formatter formatter;
formatter << u8"Playlist view – unhandled error loading artwork: " << e.what();
formatter << u8"Playlist view – unhandled error loading artwork: "_pcc << e.what();
ret = -1;
}
// send this first so thread gets closed first
Expand Down Expand Up @@ -148,7 +148,7 @@ unsigned ArtworkReader::read_artwork(abort_callback& p_abort)
} catch (exception_io_not_found const&) {
} catch (pfc::exception const& e) {
console::formatter formatter;
formatter << u8"Playlist view – error loading artwork: " << e.what();
formatter << u8"Playlist view – error loading artwork: "_pcc << e.what();
}

// Warning: Broken input components can intitialise COM as apartment-threaded. Hence, COM intialisation
Expand Down Expand Up @@ -284,7 +284,7 @@ wil::unique_hbitmap g_create_hbitmap_from_data(
const auto bitmap_data = cui::wic::decode_image_data(data->get_ptr(), data->get_size());
bitmap = cui::gdip::create_bitmap_from_wic_data(bitmap_data);
} catch (const std::exception& ex) {
fbh::print_to_console(u8"Playlist view – loading image failed: ", ex.what());
fbh::print_to_console(u8"Playlist view – loading image failed: "_pcc, ex.what());
return nullptr;
}

Expand Down
20 changes: 2 additions & 18 deletions foo_ui_columns/rebar_band.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace cui::rebar {

class RebarBandState {
public:
struct RebarBandState {
GUID m_guid{};
// Although we store the DPI, this does virtually nothing as remaining space is automatically
// distributed among the remaining bands.
Expand All @@ -17,27 +16,12 @@ class RebarBandState {
void read_from_stream(stream_reader* reader, abort_callback& aborter);
void write_extra(stream_writer* writer, abort_callback& aborter) const;
void read_extra(stream_reader* reader, abort_callback& aborter);

RebarBandState& operator=(RebarBandState&&) = default;
RebarBandState& operator=(const RebarBandState& band_state) = default;
RebarBandState() = default;

RebarBandState(RebarBandState&&) = default;
RebarBandState(const RebarBandState& band_state) = default;
};

class RebarBand {
public:
struct RebarBand {
RebarBandState m_state;
ui_extension::window_ptr m_window{};
HWND m_wnd{};

RebarBand& operator=(RebarBand&&) = default;
RebarBand& operator=(const RebarBand& band) = default;
RebarBand() = default;

RebarBand(RebarBand&&) = default;
RebarBand(const RebarBand& band) = default;
};

} // namespace cui::rebar
4 changes: 2 additions & 2 deletions foo_ui_columns/splitter_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pfc::array_t<t_uint8> serialise_splitter_item(const uie::splitter_item_t* item)
return serialise_splitter_item(normalised_item.get());
}

std::unique_ptr<uie::splitter_item_full_v3_impl_t> deserialise_splitter_item(gsl::span<const t_uint8> data)
std::unique_ptr<uie::splitter_item_full_v3_impl_t> deserialise_splitter_item(std::span<const t_uint8> data)
{
auto item = std::make_unique<uie::splitter_item_full_v3_impl_t>();
stream_reader_memblock_ref reader(data.data(), data.size());
Expand Down Expand Up @@ -161,7 +161,7 @@ std::unique_ptr<uie::splitter_item_full_v3_impl_t> get_splitter_item_from_clipbo
try {
return get_splitter_item_from_clipboard();
} catch (const exception_io& ex) {
uMessageBox(wnd, ex.what(), u8"Error – Paste Panel", MB_OK | MB_ICONERROR);
uMessageBox(wnd, ex.what(), u8"Error – Paste Panel"_pcc, MB_OK | MB_ICONERROR);
}
return {};
}
Expand Down
4 changes: 2 additions & 2 deletions foo_ui_columns/splitter_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace cui::splitter_utils {

pfc::array_t<t_uint8> serialise_splitter_item(const uie::splitter_item_full_v3_impl_t* item);
pfc::array_t<t_uint8> serialise_splitter_item(const uie::splitter_item_t* item);
std::unique_ptr<uie::splitter_item_full_v3_impl_t> deserialise_splitter_item(gsl::span<t_uint8> data);
std::unique_ptr<uie::splitter_item_full_v3_impl_t> deserialise_splitter_item(std::span<t_uint8> data);

CLIPFORMAT get_splitter_item_clipboard_format();

Expand All @@ -26,7 +26,7 @@ void copy_splitter_item_to_clipboard_safe(HWND wnd, const SplitterItem* item)
try {
copy_splitter_item_to_clipboard(item);
} catch (const exception_io& ex) {
uMessageBox(wnd, ex.what(), u8"Error – Copy Panel", MB_OK | MB_ICONERROR);
uMessageBox(wnd, ex.what(), u8"Error – Copy Panel"_pcc, MB_OK | MB_ICONERROR);
}
}

Expand Down
2 changes: 2 additions & 0 deletions foo_ui_columns/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <memory>
#include <optional>
#include <set>
#include <span>
#include <string_view>
#include <utility>
#include <unordered_map>
Expand Down Expand Up @@ -60,6 +61,7 @@
#include "../fbh/stdafx.h"
#include "../pfc/range_based_for.h"

using namespace mmh::literals::pcc;
using namespace uih::literals::spx;

#include "functional.h"
Expand Down
2 changes: 1 addition & 1 deletion foo_ui_columns/title_formatting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ValueVisitor {
bool operator()(const internal::ExplicitBool& value) const
{
if (value) {
m_out->write(titleformat_inputtypes::unknown, u8"1");
m_out->write(titleformat_inputtypes::unknown, "1");
}
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion foo_ui_columns/version.h.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

namespace cui {

constexpr auto version = u8"${{ Version }}";
constexpr auto version = "${{ Version }}";

}
2 changes: 1 addition & 1 deletion mmh
Submodule mmh updated 4 files
+70 −13 .clang-format
+5 −5 mmh.vcxproj
+6 −1 string.cpp
+7 −1 string.h
2 changes: 1 addition & 1 deletion ui_helpers