diff options
author | Richard Nelson <richard@lindenlab.com> | 2011-10-03 18:52:22 -0700 |
---|---|---|
committer | Richard Nelson <richard@lindenlab.com> | 2011-10-03 18:52:22 -0700 |
commit | edacb7b3363dca6cd28a4ff7ea27154d6a30702f (patch) | |
tree | e98c16e34614536f392d5822e9998c10dec434bd /indra/llxuixml | |
parent | 05dd98a42327f8249b34dcf28cb7496a69b5f1ab (diff) |
implemented Range and ClampedValue classes to standardize min/max settings
fixed not serializing named values when values provided from code
Diffstat (limited to 'indra/llxuixml')
-rw-r--r-- | indra/llxuixml/llinitparam.h | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 3dce7a939f..9db67a15c8 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -87,6 +87,7 @@ namespace LLInitParam void setValueName(const std::string& key) {} std::string getValueName() const { return ""; } + std::string calcValueName(const T& value) const { return ""; } void clearValueName() const {} static bool getValueFromName(const std::string& name, T& value) @@ -124,6 +125,22 @@ namespace LLInitParam return mValueName; } + std::string calcValueName(const T& value) const + { + value_name_map_t* map = getValueNames(); + for (value_name_map_t::iterator it = map->begin(), end_it = map->end(); + it != end_it; + ++it) + { + if (ParamCompare<T>::equals(it->second, value)) + { + return it->first; + } + } + + return ""; + } + void clearValueName() const { mValueName.clear(); @@ -709,18 +726,19 @@ namespace LLInitParam { if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), key)) { - if (!parser.writeValue(key, name_stack)) - { - return; - } + parser.writeValue(key, name_stack); } } // then try to serialize value directly else if (!diff_param || !ParamCompare<T>::equals(typed_param.getValue(), static_cast<const self_t*>(diff_param)->getValue())) { - if (!parser.writeValue(typed_param.getValue(), name_stack)) + if (!parser.writeValue(typed_param.getValue(), name_stack)) { - return; + std::string calculated_key = typed_param.calcValueName(typed_param.getValue()); + if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), calculated_key)) + { + parser.writeValue(calculated_key, name_stack); + } } } } @@ -1002,9 +1020,14 @@ namespace LLInitParam if(key.empty()) // not parsed via name values, write out value directly { - if (!parser.writeValue(*it, name_stack)) + bool value_written == parser.writeValue(*it, name_stack); + if (!value_written) { - break; + std::string calculated_key = typed_param.calcValueName(typed_param.getValue()); + if (!parser.writeValue(calculated_key, name_stack)) + { + break; + } } } else |