|
|
|
@ -34,6 +34,11 @@ bool Save::check_save(string flag_save, string key_name) {
|
|
|
|
|
}
|
|
|
|
|
iter_map_data = (*map_gui).find(key_name);
|
|
|
|
|
iter_map_data_old = (*map_data_old).find(key_name);
|
|
|
|
|
if ((*map_local).find(key_name) != (*map_local).end() && (*map_global).find(key_name) != (*map_global).end()) {
|
|
|
|
|
if ((*map_local)[key_name] != (*map_global)[key_name]) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (iter_map_data_old == (*map_data_old).end() && iter_map_data != (*map_gui).end()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -52,16 +57,32 @@ bool Save::check_save(string flag_save, string key_name) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Save::save(std::map <string, string> &map_gui, string sections, string str_flag_save) {
|
|
|
|
|
int Save::get_count_error() {
|
|
|
|
|
return process.get_count_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string Save::get_cmd_error() {
|
|
|
|
|
return process.get_cmd_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Save::set_count_error(int count_error) {
|
|
|
|
|
process.set_count_error(count_error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Save::set_vec_params(vector<string>& vec_param_names) {
|
|
|
|
|
this->vec_param_names = &vec_param_names;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Save::save(string sections, string str_flag_save) {
|
|
|
|
|
string key = "";
|
|
|
|
|
string value = "";
|
|
|
|
|
string cmd = "";
|
|
|
|
|
string str_error = "";
|
|
|
|
|
this->flag_no_save = false;
|
|
|
|
|
for (const auto &map_iter: map_gui) {
|
|
|
|
|
key = map_iter.first;
|
|
|
|
|
value = map_iter.second;
|
|
|
|
|
if (this->check_save(str_flag_save, key) == true) {
|
|
|
|
|
this->flag_no_save = true;
|
|
|
|
|
for (const auto &key: *vec_param_names) {
|
|
|
|
|
if (map_gui->find(key) != map_gui->end()) {
|
|
|
|
|
value = (*map_gui)[key];
|
|
|
|
|
if (this->check_save(str_flag_save, key)) {
|
|
|
|
|
if (value.length() != 0) {
|
|
|
|
|
cmd = "ubconfig --target " + str_flag_save + " set " + sections + " " +
|
|
|
|
|
key + "=\"" + value + "\"";
|
|
|
|
@ -74,7 +95,43 @@ void Save::save(std::map <string, string> &map_gui, string sections, string str_
|
|
|
|
|
}
|
|
|
|
|
if (cmd.length() != 0) {
|
|
|
|
|
process.call(cmd, "");
|
|
|
|
|
this->flag_no_save = false;
|
|
|
|
|
str_error = process.get_cmd_error();
|
|
|
|
|
if (str_error.length() != 0) {
|
|
|
|
|
this->vec_errors.push_back(str_error);
|
|
|
|
|
str_error = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Save::save_all(string sections, string str_flag_save) {
|
|
|
|
|
string key = "";
|
|
|
|
|
string value = "";
|
|
|
|
|
string cmd_all = "ubconfig --target " + str_flag_save + " set " + sections;
|
|
|
|
|
size_t len_start_cmd_all = cmd_all.length();
|
|
|
|
|
string str_error = "";
|
|
|
|
|
this->flag_no_save = true;
|
|
|
|
|
string cmd = "";
|
|
|
|
|
string cmd_remove = "";
|
|
|
|
|
for (const auto &key: *vec_param_names) {
|
|
|
|
|
if (map_gui->find(key) != map_gui->end()) {
|
|
|
|
|
value = (*map_gui)[key];
|
|
|
|
|
if (this->check_save(str_flag_save, key)) {
|
|
|
|
|
if (value.length() != 0) {
|
|
|
|
|
cmd_all += " " + key + "=\"" + value + "\"";
|
|
|
|
|
}
|
|
|
|
|
else if (value.length() == 0) {
|
|
|
|
|
cmd = "ubconfig --target " + str_flag_save + " remove " + sections + " " + key;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cmd = "";
|
|
|
|
|
}
|
|
|
|
|
if (cmd.length() != 0) {
|
|
|
|
|
process.call(cmd, "");
|
|
|
|
|
this->flag_no_save = false;
|
|
|
|
|
str_error = process.get_cmd_error();
|
|
|
|
|
if (str_error.length() != 0) {
|
|
|
|
|
this->vec_errors.push_back(str_error);
|
|
|
|
@ -83,5 +140,16 @@ void Save::save(std::map <string, string> &map_gui, string sections, string str_
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (len_start_cmd_all != cmd_all.length()) {
|
|
|
|
|
process.call(cmd, "");
|
|
|
|
|
this->flag_no_save = false;
|
|
|
|
|
str_error = process.get_cmd_error();
|
|
|
|
|
if (str_error.length() != 0) {
|
|
|
|
|
this->vec_errors.push_back(str_error);
|
|
|
|
|
str_error = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|