aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/Bookmark.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-29 15:11:10 +0100
committer hop311 <hop3114@gmail.com>2023-10-29 21:08:08 +0100
commit1b5e43fa7750cc4025d32f18390593cbce3ba842 (patch)
treed37fcb69766ec029ea4e3e2816c419f9d7e05f7c /src/openvic-simulation/history/Bookmark.cpp
parent164264b047921dbe1567d2af183e1cffb200a8cb (diff)
Clang-format formatting (with manual cleanup)
Diffstat (limited to 'src/openvic-simulation/history/Bookmark.cpp')
-rw-r--r--src/openvic-simulation/history/Bookmark.cpp66
1 files changed, 25 insertions, 41 deletions
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
+}