Skip to content

Commit

Permalink
Add libkrbn_core_configuration_get_selected_profile_complex_modificat…
Browse files Browse the repository at this point in the history
…ions_rule_json_string
  • Loading branch information
tekezo committed Sep 9, 2023
1 parent fadd7e0 commit ba085fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/libkrbn/include/libkrbn/libkrbn.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ void libkrbn_core_configuration_replace_selected_profile_fn_function_key(libkrbn

size_t libkrbn_core_configuration_get_selected_profile_complex_modifications_rules_size(libkrbn_core_configuration* p);
const char* libkrbn_core_configuration_get_selected_profile_complex_modifications_rule_description(libkrbn_core_configuration* p, size_t index);
bool libkrbn_core_configuration_get_selected_profile_complex_modifications_rule_json_string(libkrbn_core_configuration* p,
size_t index,
char* buffer,
size_t length);
void libkrbn_core_configuration_erase_selected_profile_complex_modifications_rule(libkrbn_core_configuration* p, size_t index);
void libkrbn_core_configuration_swap_selected_profile_complex_modifications_rules(libkrbn_core_configuration* p, size_t index1, size_t index2);
void libkrbn_core_configuration_move_selected_profile_complex_modifications_rule(libkrbn_core_configuration* p, size_t source_index, size_t destination_index);
Expand Down
18 changes: 18 additions & 0 deletions src/lib/libkrbn/src/libkrbn_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,24 @@ const char* _Nullable libkrbn_core_configuration_get_selected_profile_complex_mo
return 0;
}

bool libkrbn_core_configuration_get_selected_profile_complex_modifications_rule_json_string(libkrbn_core_configuration* p,
size_t index,
char* buffer,
size_t length) {
if (auto c = reinterpret_cast<libkrbn_core_configuration_class*>(p)) {
const auto& rules = c->get_core_configuration().get_selected_profile().get_complex_modifications().get_rules();
if (index < rules.size()) {
auto json_string = krbn::json_utility::dump(rules[index].get_json());
// Return false if no enough space.
if (json_string.length() < length) {
strlcpy(buffer, json_string.c_str(), length);
return true;
}
}
}
return false;
}

int libkrbn_core_configuration_get_selected_profile_complex_modifications_parameter(libkrbn_core_configuration* p,
const char* name) {
if (auto c = reinterpret_cast<libkrbn_core_configuration_class*>(p)) {
Expand Down

0 comments on commit ba085fc

Please sign in to comment.