From 1b5e43fa7750cc4025d32f18390593cbce3ba842 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 29 Oct 2023 14:11:10 +0000 Subject: Clang-format formatting (with manual cleanup) --- src/openvic-simulation/history/Bookmark.cpp | 66 +++++++++++------------------ 1 file changed, 25 insertions(+), 41 deletions(-) (limited to 'src/openvic-simulation/history/Bookmark.cpp') diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp index 1786821..edfa064 100644 --- a/src/openvic-simulation/history/Bookmark.cpp +++ b/src/openvic-simulation/history/Bookmark.cpp @@ -12,20 +12,10 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; Bookmark::Bookmark( - size_t new_index, - std::string_view new_name, - std::string_view new_description, - Date new_date, - uint32_t new_initial_camera_x, + size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date, uint32_t new_initial_camera_x, uint32_t new_initial_camera_y -) - : HasIdentifier { std::to_string(new_index) }, - name { new_name }, - description { new_description }, - date { new_date }, - initial_camera_x { new_initial_camera_x }, - initial_camera_y { new_initial_camera_y } { -} +) : HasIdentifier { std::to_string(new_index) }, name { new_name }, description { new_description }, date { new_date }, + initial_camera_x { new_initial_camera_x }, initial_camera_y { new_initial_camera_y } {} std::string_view Bookmark::get_name() const { return name; @@ -50,40 +40,34 @@ uint32_t Bookmark::get_initial_camera_y() const { BookmarkManager::BookmarkManager() : bookmarks { "bookmarks" } {} bool BookmarkManager::add_bookmark( - std::string_view name, - std::string_view description, - Date date, - uint32_t initial_camera_x, - uint32_t initial_camera_y + std::string_view name, std::string_view description, Date date, uint32_t initial_camera_x, uint32_t initial_camera_y ) { return bookmarks.add_item({ bookmarks.size(), name, description, date, initial_camera_x, initial_camera_y }); } bool BookmarkManager::load_bookmark_file(ast::NodeCPtr root) { - bool ret = expect_dictionary( - [this](std::string_view key, ast::NodeCPtr value) -> bool { - if (key != "bookmark") { - Logger::error("Invalid bookmark declaration ", key); - return false; - } - - std::string_view name, description; - Date date; - uint32_t initial_camera_x, initial_camera_y; - - bool ret = expect_dictionary_keys( - "name", ONE_EXACTLY, expect_string(assign_variable_callback(name)), - "desc", ONE_EXACTLY, expect_string(assign_variable_callback(description)), - "date", ONE_EXACTLY, expect_date(assign_variable_callback(date)), - "cameraX", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_x)), - "cameraY", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_y)) - )(value); - - ret &= add_bookmark(name, description, date, initial_camera_x, initial_camera_y); - return ret; + const bool ret = expect_dictionary([this](std::string_view key, ast::NodeCPtr value) -> bool { + if (key != "bookmark") { + Logger::error("Invalid bookmark declaration ", key); + return false; } - )(root); + + std::string_view name, description; + Date date; + uint32_t initial_camera_x, initial_camera_y; + + bool ret = expect_dictionary_keys( + "name", ONE_EXACTLY, expect_string(assign_variable_callback(name)), + "desc", ONE_EXACTLY, expect_string(assign_variable_callback(description)), + "date", ONE_EXACTLY, expect_date(assign_variable_callback(date)), + "cameraX", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_x)), + "cameraY", ONE_EXACTLY, expect_uint(assign_variable_callback(initial_camera_y)) + )(value); + + ret &= add_bookmark(name, description, date, initial_camera_x, initial_camera_y); + return ret; + })(root); lock_bookmarks(); return ret; -} \ No newline at end of file +} -- cgit v1.2.3-56-ga3b1