d1a2576074f880ed24889fe4a3390283c0d2c390
[oweals/minetest.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::getMultiline(std::istream &is, size_t *num_lines)
67 {
68         size_t lines = 1;
69         std::string value;
70         std::string line;
71
72         while (is.good()) {
73                 lines++;
74                 std::getline(is, line);
75                 if (line == "\"\"\"")
76                         break;
77                 value += line;
78                 value.push_back('\n');
79         }
80
81         size_t len = value.size();
82         if (len)
83                 value.erase(len - 1);
84
85         if (num_lines)
86                 *num_lines = lines;
87
88         return value;
89 }
90
91
92 bool Settings::readConfigFile(const char *filename)
93 {
94         std::ifstream is(filename);
95         if (!is.good())
96                 return false;
97
98         return parseConfigLines(is, "");
99 }
100
101
102 bool Settings::parseConfigLines(std::istream &is, const std::string &end)
103 {
104         JMutexAutoLock lock(m_mutex);
105
106         std::string line, name, value;
107
108         while (is.good()) {
109                 std::getline(is, line);
110                 SettingsParseEvent event = parseConfigObject(line, end, name, value);
111
112                 switch (event) {
113                 case SPE_NONE:
114                 case SPE_INVALID:
115                 case SPE_COMMENT:
116                         break;
117                 case SPE_KVPAIR:
118                         m_settings[name] = SettingsEntry(value);
119                         break;
120                 case SPE_END:
121                         return true;
122                 case SPE_GROUP: {
123                         Settings *group = new Settings;
124                         if (!group->parseConfigLines(is, "}")) {
125                                 delete group;
126                                 return false;
127                         }
128                         m_settings[name] = SettingsEntry(group);
129                         break;
130                 }
131                 case SPE_MULTILINE:
132                         m_settings[name] = SettingsEntry(getMultiline(is));
133                         break;
134                 }
135         }
136
137         return end.empty();
138 }
139
140
141 void Settings::writeLines(std::ostream &os, u32 tab_depth) const
142 {
143         JMutexAutoLock lock(m_mutex);
144
145         for (std::map<std::string, SettingsEntry>::const_iterator
146                         it = m_settings.begin();
147                         it != m_settings.end(); ++it)
148                 printEntry(os, it->first, it->second, tab_depth);
149 }
150
151
152 void Settings::printEntry(std::ostream &os, const std::string &name,
153         const SettingsEntry &entry, u32 tab_depth)
154 {
155         for (u32 i = 0; i != tab_depth; i++)
156                 os << "\t";
157
158         if (entry.is_group) {
159                 os << name << " = {\n";
160
161                 entry.group->writeLines(os, tab_depth + 1);
162
163                 for (u32 i = 0; i != tab_depth; i++)
164                         os << "\t";
165                 os << "}\n";
166         } else {
167                 os << name << " = ";
168
169                 if (entry.value.find('\n') != std::string::npos)
170                         os << "\"\"\"\n" << entry.value << "\n\"\"\"\n";
171                 else
172                         os << entry.value << "\n";
173         }
174 }
175
176
177 bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
178         const std::string &end, u32 tab_depth)
179 {
180         std::map<std::string, SettingsEntry>::const_iterator it;
181         std::set<std::string> present_entries;
182         std::string line, name, value;
183         bool was_modified = false;
184         bool end_found = false;
185
186         // Add any settings that exist in the config file with the current value
187         // in the object if existing
188         while (is.good() && !end_found) {
189                 std::getline(is, line);
190                 SettingsParseEvent event = parseConfigObject(line, end, name, value);
191
192                 switch (event) {
193                 case SPE_END:
194                         os << line << (is.eof() ? "" : "\n");
195                         end_found = true;
196                         break;
197                 case SPE_MULTILINE:
198                         value = getMultiline(is);
199                         /* FALLTHROUGH */
200                 case SPE_KVPAIR:
201                         it = m_settings.find(name);
202                         if (it != m_settings.end() &&
203                                 (it->second.is_group || it->second.value != value)) {
204                                 printEntry(os, name, it->second, tab_depth);
205                                 was_modified = true;
206                         } else {
207                                 assert(it->second.group == NULL);
208                                 os << line << "\n";
209                                 if (event == SPE_MULTILINE)
210                                         os << value << "\n\"\"\"\n";
211                         }
212                         present_entries.insert(name);
213                         break;
214                 case SPE_GROUP:
215                         it = m_settings.find(name);
216                         if (it != m_settings.end() && it->second.is_group) {
217                                 os << line << "\n";
218                                 assert(it->second.group != NULL);
219                                 was_modified |= it->second.group->updateConfigObject(is, os,
220                                         "}", tab_depth + 1);
221                         } else {
222                                 printEntry(os, name, it->second, tab_depth);
223                                 was_modified = true;
224                         }
225                         present_entries.insert(name);
226                         break;
227                 default:
228                         os << line << (is.eof() ? "" : "\n");
229                         break;
230                 }
231         }
232
233         // Add any settings in the object that don't exist in the config file yet
234         for (it = m_settings.begin(); it != m_settings.end(); ++it) {
235                 if (present_entries.find(it->first) != present_entries.end())
236                         continue;
237
238                 printEntry(os, it->first, it->second, tab_depth);
239                 was_modified = true;
240         }
241
242         return was_modified;
243 }
244
245
246 bool Settings::updateConfigFile(const char *filename)
247 {
248         JMutexAutoLock lock(m_mutex);
249
250         std::ifstream is(filename);
251         std::ostringstream os(std::ios_base::binary);
252
253         bool was_modified = updateConfigObject(is, os, "");
254         is.close();
255
256         if (!was_modified)
257                 return true;
258
259         if (!fs::safeWriteToFile(filename, os.str())) {
260                 errorstream << "Error writing configuration file: \""
261                         << filename << "\"" << std::endl;
262                 return false;
263         }
264
265         return true;
266 }
267
268
269 bool Settings::parseCommandLine(int argc, char *argv[],
270                 std::map<std::string, ValueSpec> &allowed_options)
271 {
272         int nonopt_index = 0;
273         for (int i = 1; i < argc; i++) {
274                 std::string arg_name = argv[i];
275                 if (arg_name.substr(0, 2) != "--") {
276                         // If option doesn't start with -, read it in as nonoptX
277                         if (arg_name[0] != '-'){
278                                 std::string name = "nonopt";
279                                 name += itos(nonopt_index);
280                                 set(name, arg_name);
281                                 nonopt_index++;
282                                 continue;
283                         }
284                         errorstream << "Invalid command-line parameter \""
285                                         << arg_name << "\": --<option> expected." << std::endl;
286                         return false;
287                 }
288
289                 std::string name = arg_name.substr(2);
290
291                 std::map<std::string, ValueSpec>::iterator n;
292                 n = allowed_options.find(name);
293                 if (n == allowed_options.end()) {
294                         errorstream << "Unknown command-line parameter \""
295                                         << arg_name << "\"" << std::endl;
296                         return false;
297                 }
298
299                 ValueType type = n->second.type;
300
301                 std::string value = "";
302
303                 if (type == VALUETYPE_FLAG) {
304                         value = "true";
305                 } else {
306                         if ((i + 1) >= argc) {
307                                 errorstream << "Invalid command-line parameter \""
308                                                 << name << "\": missing value" << std::endl;
309                                 return false;
310                         }
311                         value = argv[++i];
312                 }
313
314                 set(name, value);
315         }
316
317         return true;
318 }
319
320
321
322 /***********
323  * Getters *
324  ***********/
325
326
327 const SettingsEntry &Settings::getEntry(const std::string &name) const
328 {
329         JMutexAutoLock lock(m_mutex);
330
331         std::map<std::string, SettingsEntry>::const_iterator n;
332         if ((n = m_settings.find(name)) == m_settings.end()) {
333                 if ((n = m_defaults.find(name)) == m_defaults.end())
334                         throw SettingNotFoundException("Setting [" + name + "] not found.");
335         }
336         return n->second;
337 }
338
339
340 Settings *Settings::getGroup(const std::string &name) const
341 {
342         const SettingsEntry &entry = getEntry(name);
343         if (!entry.is_group)
344                 throw SettingNotFoundException("Setting [" + name + "] is not a group.");
345         return entry.group;
346 }
347
348
349 std::string Settings::get(const std::string &name) const
350 {
351         const SettingsEntry &entry = getEntry(name);
352         if (entry.is_group)
353                 throw SettingNotFoundException("Setting [" + name + "] is a group.");
354         return entry.value;
355 }
356
357
358 bool Settings::getBool(const std::string &name) const
359 {
360         return is_yes(get(name));
361 }
362
363
364 u16 Settings::getU16(const std::string &name) const
365 {
366         return stoi(get(name), 0, 65535);
367 }
368
369
370 s16 Settings::getS16(const std::string &name) const
371 {
372         return stoi(get(name), -32768, 32767);
373 }
374
375
376 s32 Settings::getS32(const std::string &name) const
377 {
378         return stoi(get(name));
379 }
380
381
382 float Settings::getFloat(const std::string &name) const
383 {
384         return stof(get(name));
385 }
386
387
388 u64 Settings::getU64(const std::string &name) const
389 {
390         u64 value = 0;
391         std::string s = get(name);
392         std::istringstream ss(s);
393         ss >> value;
394         return value;
395 }
396
397
398 v2f Settings::getV2F(const std::string &name) const
399 {
400         v2f value;
401         Strfnd f(get(name));
402         f.next("(");
403         value.X = stof(f.next(","));
404         value.Y = stof(f.next(")"));
405         return value;
406 }
407
408
409 v3f Settings::getV3F(const std::string &name) const
410 {
411         v3f value;
412         Strfnd f(get(name));
413         f.next("(");
414         value.X = stof(f.next(","));
415         value.Y = stof(f.next(","));
416         value.Z = stof(f.next(")"));
417         return value;
418 }
419
420
421 u32 Settings::getFlagStr(const std::string &name, const FlagDesc *flagdesc,
422         u32 *flagmask) const
423 {
424         std::string val = get(name);
425         return std::isdigit(val[0])
426                 ? stoi(val)
427                 : readFlagString(val, flagdesc, flagmask);
428 }
429
430
431 // N.B. if getStruct() is used to read a non-POD aggregate type,
432 // the behavior is undefined.
433 bool Settings::getStruct(const std::string &name, const std::string &format,
434         void *out, size_t olen) const
435 {
436         std::string valstr;
437
438         try {
439                 valstr = get(name);
440         } catch (SettingNotFoundException &e) {
441                 return false;
442         }
443
444         if (!deSerializeStringToStruct(valstr, format, out, olen))
445                 return false;
446
447         return true;
448 }
449
450
451 bool Settings::getNoiseParams(const std::string &name, NoiseParams &np) const
452 {
453         return getNoiseParamsFromGroup(name, np) || getNoiseParamsFromValue(name, np);
454 }
455
456
457 bool Settings::getNoiseParamsFromValue(const std::string &name,
458         NoiseParams &np) const
459 {
460         std::string value;
461
462         if (!getNoEx(name, value))
463                 return false;
464
465         Strfnd f(value);
466
467         np.offset   = stof(f.next(","));
468         np.scale    = stof(f.next(","));
469         f.next("(");
470         np.spread.X = stof(f.next(","));
471         np.spread.Y = stof(f.next(","));
472         np.spread.Z = stof(f.next(")"));
473         f.next(",");
474         np.seed     = stoi(f.next(","));
475         np.octaves  = stoi(f.next(","));
476         np.persist  = stof(f.next(","));
477
478         std::string optional_params = f.next("");
479         if (optional_params != "")
480                 np.lacunarity = stof(optional_params);
481
482         return true;
483 }
484
485
486 bool Settings::getNoiseParamsFromGroup(const std::string &name,
487         NoiseParams &np) const
488 {
489         Settings *group = NULL;
490
491         if (!getGroupNoEx(name, group))
492                 return false;
493
494         group->getFloatNoEx("offset",      np.offset);
495         group->getFloatNoEx("scale",       np.scale);
496         group->getV3FNoEx("spread",        np.spread);
497         group->getS32NoEx("seed",          np.seed);
498         group->getU16NoEx("octaves",       np.octaves);
499         group->getFloatNoEx("persistence", np.persist);
500         group->getFloatNoEx("lacunarity",  np.lacunarity);
501
502         np.flags = 0;
503         if (!group->getFlagStrNoEx("flags", np.flags, flagdesc_noiseparams))
504                 np.flags = NOISE_FLAG_DEFAULTS;
505
506         return true;
507 }
508
509
510 bool Settings::exists(const std::string &name) const
511 {
512         JMutexAutoLock lock(m_mutex);
513
514         return (m_settings.find(name) != m_settings.end() ||
515                 m_defaults.find(name) != m_defaults.end());
516 }
517
518
519 std::vector<std::string> Settings::getNames() const
520 {
521         std::vector<std::string> names;
522         for (std::map<std::string, SettingsEntry>::const_iterator
523                         i = m_settings.begin();
524                         i != m_settings.end(); ++i) {
525                 names.push_back(i->first);
526         }
527         return names;
528 }
529
530
531
532 /***************************************
533  * Getters that don't throw exceptions *
534  ***************************************/
535
536 bool Settings::getEntryNoEx(const std::string &name, SettingsEntry &val) const
537 {
538         try {
539                 val = getEntry(name);
540                 return true;
541         } catch (SettingNotFoundException &e) {
542                 return false;
543         }
544 }
545
546
547 bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const
548 {
549         try {
550                 val = getGroup(name);
551                 return true;
552         } catch (SettingNotFoundException &e) {
553                 return false;
554         }
555 }
556
557
558 bool Settings::getNoEx(const std::string &name, std::string &val) const
559 {
560         try {
561                 val = get(name);
562                 return true;
563         } catch (SettingNotFoundException &e) {
564                 return false;
565         }
566 }
567
568
569 bool Settings::getFlag(const std::string &name) const
570 {
571         try {
572                 return getBool(name);
573         } catch(SettingNotFoundException &e) {
574                 return false;
575         }
576 }
577
578
579 bool Settings::getFloatNoEx(const std::string &name, float &val) const
580 {
581         try {
582                 val = getFloat(name);
583                 return true;
584         } catch (SettingNotFoundException &e) {
585                 return false;
586         }
587 }
588
589
590 bool Settings::getU16NoEx(const std::string &name, u16 &val) const
591 {
592         try {
593                 val = getU16(name);
594                 return true;
595         } catch (SettingNotFoundException &e) {
596                 return false;
597         }
598 }
599
600
601 bool Settings::getS16NoEx(const std::string &name, s16 &val) const
602 {
603         try {
604                 val = getS16(name);
605                 return true;
606         } catch (SettingNotFoundException &e) {
607                 return false;
608         }
609 }
610
611
612 bool Settings::getS32NoEx(const std::string &name, s32 &val) const
613 {
614         try {
615                 val = getS32(name);
616                 return true;
617         } catch (SettingNotFoundException &e) {
618                 return false;
619         }
620 }
621
622
623 bool Settings::getU64NoEx(const std::string &name, u64 &val) const
624 {
625         try {
626                 val = getU64(name);
627                 return true;
628         } catch (SettingNotFoundException &e) {
629                 return false;
630         }
631 }
632
633
634 bool Settings::getV2FNoEx(const std::string &name, v2f &val) const
635 {
636         try {
637                 val = getV2F(name);
638                 return true;
639         } catch (SettingNotFoundException &e) {
640                 return false;
641         }
642 }
643
644
645 bool Settings::getV3FNoEx(const std::string &name, v3f &val) const
646 {
647         try {
648                 val = getV3F(name);
649                 return true;
650         } catch (SettingNotFoundException &e) {
651                 return false;
652         }
653 }
654
655
656 // N.B. getFlagStrNoEx() does not set val, but merely modifies it.  Thus,
657 // val must be initialized before using getFlagStrNoEx().  The intention of
658 // this is to simplify modifying a flags field from a default value.
659 bool Settings::getFlagStrNoEx(const std::string &name, u32 &val,
660         FlagDesc *flagdesc) const
661 {
662         try {
663                 u32 flags, flagmask;
664
665                 flags = getFlagStr(name, flagdesc, &flagmask);
666
667                 val &= ~flagmask;
668                 val |=  flags;
669
670                 return true;
671         } catch (SettingNotFoundException &e) {
672                 return false;
673         }
674 }
675
676
677 /***********
678  * Setters *
679  ***********/
680
681 void Settings::setEntry(const std::string &name, const void *data,
682         bool set_group, bool set_default)
683 {
684         Settings *old_group = NULL;
685
686         // Strip any potentially dangerous characters from the name (note the value
687         // has no such restrictions)
688         std::string n(name);
689         for (const char *s = "\t\n\v\f\r\b =\""; *s; s++)
690                 n.erase(std::remove(n.begin(), n.end(), *s), n.end());
691
692         {
693                 JMutexAutoLock lock(m_mutex);
694
695                 SettingsEntry &entry = set_default ? m_defaults[n] : m_settings[n];
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 }