Use C++23

This commit is contained in:
Vyn 2024-11-03 18:27:36 +01:00
parent a15c23bb21
commit 668d1df06f
6 changed files with 13 additions and 34 deletions

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21)
project(mirai LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21)
project(mirai LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)

View file

@ -11,6 +11,7 @@
#include <chrono>
#include <iostream>
#include <ostream>
#include <print>
#include <string>
namespace cpputils::debug
@ -50,7 +51,7 @@ class Timer
durationToShow +=
std::chrono::duration_cast<std::chrono::milliseconds>(now - startTime).count();
}
std::cout << "[Debug - Timer] " << message << ": " << durationToShow << " ms" << std::endl;
std::println("[Debug - Timer] {}: {} ms", message, durationToShow);
}
private:

View file

@ -7,6 +7,7 @@
#include "MarkdownDataProvider.h"
#include "cpp-utils/debug.h"
#include "utils.h"
#include <print>
#include <regex>
namespace mirai
@ -43,16 +44,6 @@ TaskData stringToTask(const std::string &str, const std::string &date)
);
std::regex_match(str, matches, regex);
/*std::cout << "line " << str << std::endl;*/
/*std::cout << "M 0 " << matches[0] << std::endl;*/
/*std::cout << "M 1 " << matches[1] << std::endl;*/
/*std::cout << "M 2 " << matches[2] << std::endl;*/
/*std::cout << "M 3 " << matches[3] << std::endl;*/
/*std::cout << "M 4 " << matches[4] << std::endl;*/
/*std::cout << "M 5 " << matches[5] << std::endl;*/
/*std::cout << "M 6 " << matches[6] << std::endl;*/
/*std::cout << "M 7 " << matches[7] << std::endl;*/
std::string text = stringUtils::trim(matches[5]);
TaskData taskItem{
@ -83,15 +74,6 @@ EventData stringToEvent(const std::string &str, const std::string &dateString)
std::regex regex("> (([0-9]{2}h[0-9]{2})-([0-9]{2}h[0-9]{2}) )(.*?)( -- (.*))?");
std::regex_match(str, matches, regex);
/*std::cout << "line " << str << std::endl;*/
/*std::cout << "M 0 " << matches[0] << std::endl;*/
/*std::cout << "M 1 " << matches[1] << std::endl;*/
/*std::cout << "M 2 " << matches[2] << std::endl;*/
/*std::cout << "M 3 " << matches[3] << std::endl;*/
/*std::cout << "M 4 " << matches[4] << std::endl;*/
/*std::cout << "M 5 " << matches[5] << std::endl;*/
/*std::cout << "M 6 " << matches[6] << std::endl;*/
std::string text = stringUtils::trim(matches[4]);
auto date = stringToDate(dateString);
@ -101,8 +83,9 @@ EventData stringToEvent(const std::string &str, const std::string &dateString)
}
EventData eventData{
.title = text, .startsAt = stringToTime(matches[2]), .endsAt = stringToTime(matches[3]),
//.tags = extractTagsFromMetadata(matches[6])
.title = text,
.startsAt = stringToTime(matches[2]),
.endsAt = stringToTime(matches[3]),
};
return eventData;
}
@ -110,12 +93,6 @@ EventData stringToEvent(const std::string &str, const std::string &dateString)
std::string taskToString(const TaskData &task)
{
std::string str = task.title;
/*if (task.getTags().size() > 0) {*/
/*str += " --";*/
/*for (const std::string &tag : task.getTags()) {*/
/*str += " #" + tag;*/
/*}*/
/*}*/
str = (task.state == DONE ? "- [X] " : "- [ ] ") + str;
return str;
}
@ -170,13 +147,12 @@ MarkdownData MarkdownDataProvider::parseMarkdown(const std::string &content)
{
cpputils::debug::Timer readMdFormatDuration;
// std::vector<TaskItem> taskItems;
std::string line;
std::stringstream contentStream(content);
if (!std::getline(contentStream, line) || line.substr(0, 2) != "# ") {
std::cerr << "Couldn't find the task list name" << std::endl;
std::println("Couldn't find the task list name");
}
data.name = line.substr(2);

View file

@ -12,6 +12,7 @@
#include <algorithm>
#include <iostream>
#include <memory>
#include <print>
#include <string>
#include <vector>
@ -52,7 +53,7 @@ void Mirai::saveConfig()
{
std::ofstream file(configPath_);
if (!file.is_open()) {
std::cerr << "Can't save config to " << configPath_ << std::endl;
std::print(std::cerr, "Can't save config to {}", configPath_);
return;
}
auto configJson = nlohmann::json::parse(R"(

View file

@ -27,6 +27,7 @@
#include <memory>
#include <optional>
#include <ostream>
#include <print>
#include <ranges>
#include <string>
#include <string_view>
@ -50,7 +51,7 @@ AppWindowBackend::AppWindowBackend(mirai::Mirai *miraiInstance)
const auto palettePath = std::string(getenv("HOME")) + "/.config/evalyte/theme.json";
const auto palette = selenite::parseJson(palettePath);
if (palette.has_value()) {
std::cerr << "Warning, no " << palettePath << " found" << std::endl;
std::println(std::cerr, "Warning, no {} found", palettePath);
setSelenitePalette(mainWindow_->global<ui::Palette>(), palette.value());
setSelenitePalette(settingsWindow_->global<ui::Palette>(), palette.value());
setSelenitePalette(addSourceWindow_->global<ui::Palette>(), palette.value());