add Modify::replace_fix() convenience function
This commit is contained in:
@ -998,6 +998,23 @@ void Modify::replace_fix(const char *replaceID,
|
||||
add_fix(narg,arg,trysuffix);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convenience function to allow replacing a fix from a single string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::replace_fix(const std::string &oldfix,
|
||||
const std::string &fixcmd, int trysuffix)
|
||||
{
|
||||
auto args = utils::split_words(fixcmd);
|
||||
char **newarg = new char*[args.size()];
|
||||
int i=0;
|
||||
for (const auto &arg : args) {
|
||||
newarg[i++] = (char *)arg.c_str();
|
||||
}
|
||||
replace_fix(oldfix.c_str(),args.size(),newarg,trysuffix);
|
||||
delete[] newarg;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
one instance per fix in style_fix.h
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -101,6 +101,7 @@ class Modify : protected Pointers {
|
||||
void add_fix(int, char **, int trysuffix=1);
|
||||
void add_fix(const std::string &, int trysuffix=1);
|
||||
void replace_fix(const char *, int, char **, int trysuffix=1);
|
||||
void replace_fix(const std::string &, const std::string &, int trysuffix=1);
|
||||
void modify_fix(int, char **);
|
||||
void delete_fix(const std::string &);
|
||||
void delete_fix(int);
|
||||
|
||||
Reference in New Issue
Block a user