Skip to content

Commit

Permalink
modify CMD2_VAR_LIST
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Sep 14, 2022
1 parent e89bac8 commit a89bf6d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 25 additions & 21 deletions include/command_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,37 +270,41 @@ cleanup_commands();

#define CMD2_VAR_C_STRING(key, value, is_readonly) \
do { \
control->object_storage()->insert_c_str( \
key, value, rpc::object_storage::flag_string_type); \
if (is_readonly) rpc::readonly_command.insert(key); \
control->object_storage()->insert_c_str( \
key, value, rpc::object_storage::flag_string_type); \
\
CMD2_ANY(key, \
CMD2_ANY(key, \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto&) { return storage->get(raw_key); }), true); \
} while (0) \

#define CMD2_VAR_LIST(key) \
control->object_storage()->insert_c_str( \
#define CMD2_VAR_LIST(key, is_readonly) \
do { \
if (is_readonly) rpc::readonly_command.insert(key); \
control->object_storage()->insert_c_str( \
key, torrent::Object::create_list(), rpc::object_storage::flag_list_type); \
\
CMD2_ANY(key, \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto&) { return storage->get(raw_key); }), true); \
CMD2_ANY(key, \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto&) { return storage->get(raw_key); }), false); \
\
CMD2_ANY_LIST(key ".set", \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto& object) { \
return storage->set_list(raw_key, object); \
}), false); \
CMD2_ANY_LIST(key ".set", \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto& object) { \
return storage->set_list(raw_key, object); \
}), false); \
\
CMD2_ANY_VOID(key ".push_back", \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto& object) { \
return storage->list_push_back(raw_key, object); \
}));
CMD2_ANY_VOID(key ".push_back", \
([storage = control->object_storage(), \
raw_key = torrent::raw_string::from_c_str(key)]( \
const auto&, const auto& object) { \
return storage->list_push_back(raw_key, object); \
})); \
} while (0) \

#define CMD2_FUNC_SINGLE(key, cmds) \
CMD2_ANY(key, \
Expand Down
4 changes: 2 additions & 2 deletions src/command_local.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ initialize_command_local() {
}, false);

CMD2_VAR_BOOL("file.prioritize_toc", 0, false);
CMD2_VAR_LIST("file.prioritize_toc.first");
CMD2_VAR_LIST("file.prioritize_toc.last");
CMD2_VAR_LIST("file.prioritize_toc.first", false);
CMD2_VAR_LIST("file.prioritize_toc.last", false);

CMD2_ANY("system.files.opened_counter",
[fileManager](const auto&, const auto&) {
Expand Down

0 comments on commit a89bf6d

Please sign in to comment.