Skip to content

Commit

Permalink
Revised code to also consider arg5...arg8 of input
Browse files Browse the repository at this point in the history
  • Loading branch information
FifthPotato committed Feb 16, 2024
1 parent 6a9833b commit 0aadb75
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,17 @@ namespace
// ]
// }

// arg6: new attribute name
// Per the API, any of arg5 to arg8 is eligible to be the new attribute
// (depending on which one starts with "n:")
// However, only one will be considered (multiples will throw CAT_INVALID_ARGUMENT)
// Therefore, find the first one that starts with "n:"
const auto candidates = {input->arg5, input->arg6, input->arg7, input->arg8};
const auto mod_attr_ptr = std::find_if(std::begin(candidates), std::end(candidates), [](char* arg) {
return arg && boost::starts_with(arg, "n:");
});
const char* mod_attr_name = nullptr;
if (input->arg6) {
if (boost::starts_with(input->arg6, "n:")) {
mod_attr_name = input->arg6 + 2;
}
if (mod_attr_ptr != std::end(candidates)) {
mod_attr_name = (*mod_attr_ptr) + 2;
}
for (auto&& prefix : config->at("prefixes")) {
// If the metadata attribute starts with the prefix, then verify that the user
Expand Down

0 comments on commit 0aadb75

Please sign in to comment.