]> git.lizzy.rs Git - dragonfireclient.git/blob - src/settings.cpp
487b3da785605bd4afc1aa877903a79ac5aaafd9
[dragonfireclient.git] / src / settings.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "settings.h"
21 #include "irrlichttypes_bloated.h"
22 #include "exceptions.h"
23 #include "jthread/jmutexautolock.h"
24 #include "strfnd.h"
25 #include <iostream>
26 #include <fstream>
27 #include <sstream>
28 #include "debug.h"
29 #include "log.h"
30 #include "util/serialize.h"
31 #include "filesys.h"
32 #include "noise.h"
33 #include <cctype>
34 #include <algorithm>
35
36
37 Settings::~Settings()
38 {
39         clear();
40 }
41
42
43 Settings & Settings::operator += (const Settings &other)
44 {
45         update(other);
46
47         return *this;
48 }
49
50
51 Settings & Settings::operator = (const Settings &other)
52 {
53         if (&other == this)
54                 return *this;
55
56         JMutexAutoLock lock(m_mutex);
57         JMutexAutoLock lock2(other.m_mutex);
58
59         clearNoLock();
60         updateNoLock(other);
61
62         return *this;
63 }
64
65
66 std::string Settings::sanitizeString(const std::string &value)
67 {
68         std::string str = value;
69         for (const char *s = "\t\n\v\f\r\b =\""; *s; s++)
70                 str.erase(std::remove(str.begin(), str.end(), *s), str.end());
71
72         return str;
73 }
74
75
76 std::string Settings::getMultiline(std::istream &is, size_t *num_lines)
77 {
78         size_t lines = 1;
79         std::string value;
80         std::string line;
81
82         while (is.good()) {
83                 lines++;
84                 std::getline(is, line);
85                 if (line == "\"\"\"")
86                         break;
87                 value += line;
88                 value.push_back('\n');
89         }
90
91         size_t len = value.size();
92         if (len)
93                 value.erase(len - 1);
94
95         if (num_lines)
96                 *num_lines = lines;
97
98         return value;
99 }
100
101
102 bool Settings::readConfigFile(const char *filename)
103 {
104         std::ifstream is(filename);
105         if (!is.good())
106                 return false;
107
108         return parseConfigLines(is, "");
109 }
110
111
112 bool Settings::parseConfigLines(std::istream &is, const std::string &end)
113 {
114         JMutexAutoLock lock(m_mutex);
115
116         std::string line, name, value;
117
118         while (is.good()) {
119                 std::getline(is, line);
120                 SettingsParseEvent event = parseConfigObject(line, end, name, value);
121
122                 switch (event) {
123                 case SPE_NONE:
124                 case SPE_INVALID:
125                 case SPE_COMMENT:
126                         break;
127                 case SPE_KVPAIR:
128                         m_settings[name] = SettingsEntry(value);
129                         break;
130                 case SPE_END:
131                         return true;
132                 case SPE_GROUP: {
133                         Settings *group = new Settings;
134                         if (!group->parseConfigLines(is, "}")) {
135                                 delete group;
136                                 return false;
137                         }
138                         m_settings[name] = SettingsEntry(group);
139                         break;
140                 }
141                 case SPE_MULTILINE:
142                         m_settings[name] = SettingsEntry(getMultiline(is));
143                         break;
144                 }
145         }
146
147         return end.empty();
148 }
149
150
151 void Settings::writeLines(std::ostream &os, u32 tab_depth) const
152 {
153         JMutexAutoLock lock(m_mutex);
154
155         for (std::map<std::string, SettingsEntry>::const_iterator
156                         it = m_settings.begin();
157                         it != m_settings.end(); ++it)
158                 printEntry(os, it->first, it->second, tab_depth);
159 }
160
161
162 void Settings::printEntry(std::ostream &os, const std::string &name,
163         const SettingsEntry &entry, u32 tab_depth)
164 {
165         for (u32 i = 0; i != tab_depth; i++)
166                 os << "\t";
167
168         if (entry.is_group) {
169                 os << name << " = {\n";
170
171                 entry.group->writeLines(os, tab_depth + 1);
172
173                 for (u32 i = 0; i != tab_depth; i++)
174                         os << "\t";
175                 os << "}\n";
176         } else {
177                 os << name << " = ";
178
179                 if (entry.value.find('\n') != std::string::npos)
180                         os << "\"\"\"\n" << entry.value << "\n\"\"\"\n";
181                 else
182                         os << entry.value << "\n";
183         }
184 }
185
186
187 bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
188         const std::string &end, u32 tab_depth)
189 {
190         std::map<std::string, SettingsEntry>::const_iterator it;
191         std::set<std::string> present_entries;
192         std::string line, name, value;
193         bool was_modified = false;
194         bool end_found = false;
195
196         // Add any settings that exist in the config file with the current value
197         // in the object if existing
198         while (is.good() && !end_found) {
199                 std::getline(is, line);
200                 SettingsParseEvent event = parseConfigObject(line, end, name, value);
201
202                 switch (event) {
203                 case SPE_END:
204                         os << line << (is.eof() ? "" : "\n");
205                         end_found = true;
206                         break;
207                 case SPE_MULTILINE:
208                         value = getMultiline(is);
209                         /* FALLTHROUGH */
210                 case SPE_KVPAIR:
211                         it = m_settings.find(name);
212                         if (it != m_settings.end() &&
213                                 (it->second.is_group || it->second.value != value)) {
214                                 printEntry(os, name, it->second, tab_depth);
215                                 was_modified = true;
216                         } else {
217                                 assert(it->second.group == NULL);
218                                 os << line << "\n";
219                                 if (event == SPE_MULTILINE)
220                                         os << value << "\n\"\"\"\n";
221                         }
222                         present_entries.insert(name);
223                         break;
224                 case SPE_GROUP:
225                         it = m_settings.find(name);
226                         if (it != m_settings.end() && it->second.is_group) {
227                                 os << line << "\n";
228                                 assert(it->second.group != NULL);
229                                 was_modified |= it->second.group->updateConfigObject(is, os,
230                                         "}", tab_depth + 1);
231                         } else {
232                                 printEntry(os, name, it->second, tab_depth);
233                                 was_modified = true;
234                         }
235                         present_entries.insert(name);
236                         break;
237                 default:
238                         os << line << (is.eof() ? "" : "\n");
239                         break;
240                 }
241         }
242
243         // Add any settings in the object that don't exist in the config file yet
244         for (it = m_settings.begin(); it != m_settings.end(); ++it) {
245                 if (present_entries.find(it->first) != present_entries.end())
246                         continue;
247
248                 printEntry(os, it->first, it->second, tab_depth);
249                 was_modified = true;
250         }
251
252         return was_modified;
253 }
254
255
256 bool Settings::updateConfigFile(const char *filename)
257 {
258         JMutexAutoLock lock(m_mutex);
259
260         std::ifstream is(filename);
261         std::ostringstream os(std::ios_base::binary);
262
263         bool was_modified = updateConfigObject(is, os, "");
264         is.close();
265
266         if (!was_modified)
267                 return true;
268
269         if (!fs::safeWriteToFile(filename, os.str())) {
270                 errorstream << "Error writing configuration file: \""
271                         << filename << "\"" << std::endl;
272                 return false;
273         }
274
275         return true;
276 }
277
278
279 bool Settings::parseCommandLine(int argc, char *argv[],
280                 std::map<std::string, ValueSpec> &allowed_options)
281 {
282         int nonopt_index = 0;
283         for (int i = 1; i < argc; i++) {
284                 std::string arg_name = argv[i];
285                 if (arg_name.substr(0, 2) != "--") {
286                         // If option doesn't start with -, read it in as nonoptX
287                         if (arg_name[0] != '-'){
288                                 std::string name = "nonopt";
289                                 name += itos(nonopt_index);
290                                 set(name, arg_name);
291                                 nonopt_index++;
292                                 continue;
293                         }
294                         errorstream << "Invalid command-line parameter \""
295                                         << arg_name << "\": --<option> expected." << std::endl;
296                         return false;
297                 }
298
299                 std::string name = arg_name.substr(2);
300
301                 std::map<std::string, ValueSpec>::iterator n;
302                 n = allowed_options.find(name);
303                 if (n == allowed_options.end()) {
304                         errorstream << "Unknown command-line parameter \""
305                                         << arg_name << "\"" << std::endl;
306                         return false;
307                 }
308
309                 ValueType type = n->second.type;
310
311                 std::string value = "";
312
313                 if (type == VALUETYPE_FLAG) {
314                         value = "true";
315                 } else {
316                         if ((i + 1) >= argc) {
317                                 errorstream << "Invalid command-line parameter \""
318                                                 << name << "\": missing value" << std::endl;
319                                 return false;
320                         }
321                         value = argv[++i];
322                 }
323
324                 set(name, value);
325         }
326
327         return true;
328 }
329
330
331
332 /***********
333  * Getters *
334  ***********/
335
336
337 const SettingsEntry &Settings::getEntry(const std::string &name) const
338 {
339         JMutexAutoLock lock(m_mutex);
340
341         std::map<std::string, SettingsEntry>::const_iterator n;
342         if ((n = m_settings.find(name)) == m_settings.end()) {
343                 if ((n = m_defaults.find(name)) == m_defaults.end())
344                         throw SettingNotFoundException("Setting [" + name + "] not found.");
345         }
346         return n->second;
347 }
348
349
350 Settings *Settings::getGroup(const std::string &name) const
351 {
352         const SettingsEntry &entry = getEntry(name);
353         if (!entry.is_group)
354                 throw SettingNotFoundException("Setting [" + name + "] is not a group.");
355         return entry.group;
356 }
357
358
359 std::string Settings::get(const std::string &name) const
360 {
361         const SettingsEntry &entry = getEntry(name);
362         if (entry.is_group)
363                 throw SettingNotFoundException("Setting [" + name + "] is a group.");
364         return entry.value;
365 }
366
367
368 bool Settings::getBool(const std::string &name) const
369 {
370         return is_yes(get(name));
371 }
372
373
374 u16 Settings::getU16(const std::string &name) const
375 {
376         return stoi(get(name), 0, 65535);
377 }
378
379
380 s16 Settings::getS16(const std::string &name) const
381 {
382         return stoi(get(name), -32768, 32767);
383 }
384
385
386 s32 Settings::getS32(const std::string &name) const
387 {
388         return stoi(get(name));
389 }
390
391
392 float Settings::getFloat(const std::string &name) const
393 {
394         return stof(get(name));
395 }
396
397
398 u64 Settings::getU64(const std::string &name) const
399 {
400         u64 value = 0;
401         std::string s = get(name);
402         std::istringstream ss(s);
403         ss >> value;
404         return value;
405 }
406
407
408 v2f Settings::getV2F(const std::string &name) const
409 {
410         v2f value;
411         Strfnd f(get(name));
412         f.next("(");
413         value.X = stof(f.next(","));
414         value.Y = stof(f.next(")"));
415         return value;
416 }
417
418
419 v3f Settings::getV3F(const std::string &name) const
420 {
421         v3f value;
422         Strfnd f(get(name));
423         f.next("(");
424         value.X = stof(f.next(","));
425         value.Y = stof(f.next(","));
426         value.Z = stof(f.next(")"));
427         return value;
428 }
429
430
431 u32 Settings::getFlagStr(const std::string &name, const FlagDesc *flagdesc,
432         u32 *flagmask) const
433 {
434         std::string val = get(name);
435         return std::isdigit(val[0])
436                 ? stoi(val)
437                 : readFlagString(val, flagdesc, flagmask);
438 }
439
440
441 // N.B. if getStruct() is used to read a non-POD aggregate type,
442 // the behavior is undefined.
443 bool Settings::getStruct(const std::string &name, const std::string &format,
444         void *out, size_t olen) const
445 {
446         std::string valstr;
447
448         try {
449                 valstr = get(name);
450         } catch (SettingNotFoundException &e) {
451                 return false;
452         }
453
454         if (!deSerializeStringToStruct(valstr, format, out, olen))
455                 return false;
456
457         return true;
458 }
459
460
461 bool Settings::getNoiseParams(const std::string &name, NoiseParams &np) const
462 {
463         return getNoiseParamsFromGroup(name, np) || getNoiseParamsFromValue(name, np);
464 }
465
466
467 bool Settings::getNoiseParamsFromValue(const std::string &name,
468         NoiseParams &np) const
469 {
470         std::string value;
471
472         if (!getNoEx(name, value))
473                 return false;
474
475         Strfnd f(value);
476
477         np.offset   = stof(f.next(","));
478         np.scale    = stof(f.next(","));
479         f.next("(");
480         np.spread.X = stof(f.next(","));
481         np.spread.Y = stof(f.next(","));
482         np.spread.Z = stof(f.next(")"));
483         f.next(",");
484         np.seed     = stoi(f.next(","));
485         np.octaves  = stoi(f.next(","));
486         np.persist  = stof(f.next(""));
487
488         return true;
489 }
490
491
492 bool Settings::getNoiseParamsFromGroup(const std::string &name,
493         NoiseParams &np) const
494 {
495         Settings *group = NULL;
496
497         if (!getGroupNoEx(name, group))
498                 return false;
499
500         group->getFloatNoEx("offset",      np.offset);
501         group->getFloatNoEx("scale",       np.scale);
502         group->getV3FNoEx("spread",        np.spread);
503         group->getS32NoEx("seed",          np.seed);
504         group->getU16NoEx("octaves",       np.octaves);
505         group->getFloatNoEx("persistence", np.persist);
506         group->getFloatNoEx("lacunarity",  np.lacunarity);
507
508         np.flags = 0;
509         if (!group->getFlagStrNoEx("flags", np.flags, flagdesc_noiseparams))
510                 np.flags = NOISE_FLAG_DEFAULTS;
511
512         return true;
513 }
514
515
516 bool Settings::exists(const std::string &name) const
517 {
518         JMutexAutoLock lock(m_mutex);
519
520         return (m_settings.find(name) != m_settings.end() ||
521                 m_defaults.find(name) != m_defaults.end());
522 }
523
524
525 std::vector<std::string> Settings::getNames() const
526 {
527         std::vector<std::string> names;
528         for (std::map<std::string, SettingsEntry>::const_iterator
529                         i = m_settings.begin();
530                         i != m_settings.end(); ++i) {
531                 names.push_back(i->first);
532         }
533         return names;
534 }
535
536
537
538 /***************************************
539  * Getters that don't throw exceptions *
540  ***************************************/
541
542 bool Settings::getEntryNoEx(const std::string &name, SettingsEntry &val) const
543 {
544         try {
545                 val = getEntry(name);
546                 return true;
547         } catch (SettingNotFoundException &e) {
548                 return false;
549         }
550 }
551
552
553 bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const
554 {
555         try {
556                 val = getGroup(name);
557                 return true;
558         } catch (SettingNotFoundException &e) {
559                 return false;
560         }
561 }
562
563
564 bool Settings::getNoEx(const std::string &name, std::string &val) const
565 {
566         try {
567                 val = get(name);
568                 return true;
569         } catch (SettingNotFoundException &e) {
570                 return false;
571         }
572 }
573
574
575 bool Settings::getFlag(const std::string &name) const
576 {
577         try {
578                 return getBool(name);
579         } catch(SettingNotFoundException &e) {
580                 return false;
581         }
582 }
583
584
585 bool Settings::getFloatNoEx(const std::string &name, float &val) const
586 {
587         try {
588                 val = getFloat(name);
589                 return true;
590         } catch (SettingNotFoundException &e) {
591                 return false;
592         }
593 }
594
595
596 bool Settings::getU16NoEx(const std::string &name, u16 &val) const
597 {
598         try {
599                 val = getU16(name);
600                 return true;
601         } catch (SettingNotFoundException &e) {
602                 return false;
603         }
604 }
605
606
607 bool Settings::getS16NoEx(const std::string &name, s16 &val) const
608 {
609         try {
610                 val = getS16(name);
611                 return true;
612         } catch (SettingNotFoundException &e) {
613                 return false;
614         }
615 }
616
617
618 bool Settings::getS32NoEx(const std::string &name, s32 &val) const
619 {
620         try {
621                 val = getS32(name);
622                 return true;
623         } catch (SettingNotFoundException &e) {
624                 return false;
625         }
626 }
627
628
629 bool Settings::getU64NoEx(const std::string &name, u64 &val) const
630 {
631         try {
632                 val = getU64(name);
633                 return true;
634         } catch (SettingNotFoundException &e) {
635                 return false;
636         }
637 }
638
639
640 bool Settings::getV2FNoEx(const std::string &name, v2f &val) const
641 {
642         try {
643                 val = getV2F(name);
644                 return true;
645         } catch (SettingNotFoundException &e) {
646                 return false;
647         }
648 }
649
650
651 bool Settings::getV3FNoEx(const std::string &name, v3f &val) const
652 {
653         try {
654                 val = getV3F(name);
655                 return true;
656         } catch (SettingNotFoundException &e) {
657                 return false;
658         }
659 }
660
661
662 // N.B. getFlagStrNoEx() does not set val, but merely modifies it.  Thus,
663 // val must be initialized before using getFlagStrNoEx().  The intention of
664 // this is to simplify modifying a flags field from a default value.
665 bool Settings::getFlagStrNoEx(const std::string &name, u32 &val,
666         FlagDesc *flagdesc) const
667 {
668         try {
669                 u32 flags, flagmask;
670
671                 flags = getFlagStr(name, flagdesc, &flagmask);
672
673                 val &= ~flagmask;
674                 val |=  flags;
675
676                 return true;
677         } catch (SettingNotFoundException &e) {
678                 return false;
679         }
680 }
681
682
683 /***********
684  * Setters *
685  ***********/
686
687 void Settings::setEntry(const std::string &name, const void *data,
688         bool set_group, bool set_default)
689 {
690         Settings *old_group = NULL;
691
692         {
693                 JMutexAutoLock lock(m_mutex);
694
695                 SettingsEntry &entry = set_default ? m_defaults[name] : m_settings[name];
696                 old_group = entry.group;
697
698                 entry.value    = set_group ? "" : *(const std::string *)data;
699                 entry.group    = set_group ? *(Settings **)data : NULL;
700                 entry.is_group = set_group;
701         }
702
703         delete old_group;
704 }
705
706
707 void Settings::set(const std::string &name, const std::string &value)
708 {
709         setEntry(name, &value, false, false);
710
711         doCallbacks(name);
712 }
713
714
715 void Settings::setDefault(const std::string &name, const std::string &value)
716 {
717         setEntry(name, &value, false, true);
718 }
719
720
721 void Settings::setGroup(const std::string &name, Settings *group)
722 {
723         setEntry(name, &group, true, false);
724 }
725
726
727 void Settings::setGroupDefault(const std::string &name, Settings *group)
728 {
729         setEntry(name, &group, true, true);
730 }
731
732
733 void Settings::setBool(const std::string &name, bool value)
734 {
735         set(name, value ? "true" : "false");
736 }
737
738
739 void Settings::setS16(const std::string &name, s16 value)
740 {
741         set(name, itos(value));
742 }
743
744
745 void Settings::setU16(const std::string &name, u16 value)
746 {
747         set(name, itos(value));
748 }
749
750
751 void Settings::setS32(const std::string &name, s32 value)
752 {
753         set(name, itos(value));
754 }
755
756
757 void Settings::setU64(const std::string &name, u64 value)
758 {
759         std::ostringstream os;
760         os << value;
761         set(name, os.str());
762 }
763
764
765 void Settings::setFloat(const std::string &name, float value)
766 {
767         set(name, ftos(value));
768 }
769
770
771 void Settings::setV2F(const std::string &name, v2f value)
772 {
773         std::ostringstream os;
774         os << "(" << value.X << "," << value.Y << ")";
775         set(name, os.str());
776 }
777
778
779 void Settings::setV3F(const std::string &name, v3f value)
780 {
781         std::ostringstream os;
782         os << "(" << value.X << "," << value.Y << "," << value.Z << ")";
783         set(name, os.str());
784 }
785
786
787 void Settings::setFlagStr(const std::string &name, u32 flags,
788         const FlagDesc *flagdesc, u32 flagmask)
789 {
790         set(name, writeFlagString(flags, flagdesc, flagmask));
791 }
792
793
794 bool Settings::setStruct(const std::string &name, const std::string &format,
795         void *value)
796 {
797         std::string structstr;
798         if (!serializeStructToString(&structstr, format, value))
799                 return false;
800
801         set(name, structstr);
802         return true;
803 }
804
805
806 void Settings::setNoiseParams(const std::string &name,
807         const NoiseParams &np, bool set_default)
808 {
809         Settings *group = new Settings;
810
811         group->setFloat("offset",      np.offset);
812         group->setFloat("scale",       np.scale);
813         group->setV3F("spread",        np.spread);
814         group->setS32("seed",          np.seed);
815         group->setU16("octaves",       np.octaves);
816         group->setFloat("persistence", np.persist);
817         group->setFloat("lacunarity",  np.lacunarity);
818         group->setFlagStr("flags",     np.flags, flagdesc_noiseparams, np.flags);
819
820         setEntry(name, &group, true, set_default);
821 }
822
823
824 bool Settings::remove(const std::string &name)
825 {
826         JMutexAutoLock lock(m_mutex);
827
828         delete m_settings[name].group;
829         return m_settings.erase(name);
830 }
831
832
833 void Settings::clear()
834 {
835         JMutexAutoLock lock(m_mutex);
836         clearNoLock();
837 }
838
839
840 void Settings::updateValue(const Settings &other, const std::string &name)
841 {
842         if (&other == this)
843                 return;
844
845         JMutexAutoLock lock(m_mutex);
846
847         try {
848                 std::string val = other.get(name);
849
850                 m_settings[name] = val;
851         } catch (SettingNotFoundException &e) {
852         }
853 }
854
855
856 void Settings::update(const Settings &other)
857 {
858         if (&other == this)
859                 return;
860
861         JMutexAutoLock lock(m_mutex);
862         JMutexAutoLock lock2(other.m_mutex);
863
864         updateNoLock(other);
865 }
866
867
868 SettingsParseEvent Settings::parseConfigObject(const std::string &line,
869         const std::string &end, std::string &name, std::string &value)
870 {
871         std::string trimmed_line = trim(line);
872
873         if (trimmed_line.empty())
874                 return SPE_NONE;
875         if (trimmed_line[0] == '#')
876                 return SPE_COMMENT;
877         if (trimmed_line == end)
878                 return SPE_END;
879
880         size_t pos = trimmed_line.find('=');
881         if (pos == std::string::npos)
882                 return SPE_INVALID;
883
884         name  = trim(trimmed_line.substr(0, pos));
885         value = trim(trimmed_line.substr(pos + 1));
886
887         if (value == "{")
888                 return SPE_GROUP;
889         if (value == "\"\"\"")
890                 return SPE_MULTILINE;
891
892         return SPE_KVPAIR;
893 }
894
895
896 void Settings::updateNoLock(const Settings &other)
897 {
898         m_settings.insert(other.m_settings.begin(), other.m_settings.end());
899         m_defaults.insert(other.m_defaults.begin(), other.m_defaults.end());
900 }
901
902
903 void Settings::clearNoLock()
904 {
905         std::map<std::string, SettingsEntry>::const_iterator it;
906         for (it = m_settings.begin(); it != m_settings.end(); ++it)
907                 delete it->second.group;
908         m_settings.clear();
909
910         for (it = m_defaults.begin(); it != m_defaults.end(); ++it)
911                 delete it->second.group;
912         m_defaults.clear();
913 }
914
915
916 void Settings::registerChangedCallback(std::string name,
917         setting_changed_callback cbf)
918 {
919         m_callbacks[name].push_back(cbf);
920 }
921
922
923 void Settings::doCallbacks(const std::string name)
924 {
925         std::vector<setting_changed_callback> tempvector;
926         {
927                 JMutexAutoLock lock(m_mutex);
928                 if (m_callbacks.find(name) != m_callbacks.end())
929                 {
930                         tempvector = m_callbacks[name];
931                 }
932         }
933
934         std::vector<setting_changed_callback>::iterator iter;
935         for (iter = tempvector.begin(); iter != tempvector.end(); iter++)
936         {
937                 (*iter)(name);
938         }
939 }