diff options
Diffstat (limited to 'indra/llxuixml')
-rw-r--r-- | indra/llxuixml/llinitparam.h | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 9a6ded47ff..1a131d15a3 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 (typename 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(); @@ -564,10 +581,6 @@ namespace LLInitParam public: typedef const T& value_assignment_t; - S32 mKeyVersion; - mutable S32 mValidatedVersion; - mutable bool mValidated; // lazy validation flag - ParamValue() : T(), mKeyVersion(0), @@ -607,6 +620,12 @@ namespace LLInitParam { return *this; } + + S32 mKeyVersion; + + protected: + mutable S32 mValidatedVersion; + mutable bool mValidated; // lazy validation flag }; template<typename T, typename NAME_VALUE_LOOKUP = TypeValues<T> > @@ -707,10 +726,7 @@ 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 @@ -718,7 +734,11 @@ namespace LLInitParam { 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); + } } } } @@ -1000,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 @@ -1665,7 +1690,7 @@ namespace LLInitParam *static_cast<DERIVED_BLOCK*>(this) = defaultBatchValue(); mLastParseGeneration = -1; // merge individual parameters into destination - return super_t::mergeBlock(super_t::selfBlockDescriptor(), src_typed_param, overwrite); + return super_t::mergeBlock(super_t::selfBlockDescriptor(), other, overwrite); } return false; } @@ -1679,8 +1704,6 @@ namespace LLInitParam S32 mLastParseGeneration; }; - - template<typename DERIVED_BLOCK, typename BASE_BLOCK, typename NAME_VALUE_LOOKUP> @@ -1690,17 +1713,18 @@ namespace LLInitParam : public Param, protected BatchBlock<DERIVED_BLOCK, BASE_BLOCK> { + typedef BatchBlock<DERIVED_BLOCK, BASE_BLOCK> block_t; typedef const BatchBlock<DERIVED_BLOCK, BASE_BLOCK>& value_assignment_t; ParamValue() - : T(), + : block_t(), mKeyVersion(0), mValidatedVersion(-1), mValidated(false) {} ParamValue(value_assignment_t other) - : T(other), + : block_t(other), mKeyVersion(0), mValidatedVersion(-1), mValidated(false) @@ -1710,7 +1734,7 @@ namespace LLInitParam void setValue(value_assignment_t val) { *this = val; - mLastParseGeneration = -1; + block_t::mLastParseGeneration = -1; } value_assignment_t getValue() const @@ -1733,6 +1757,11 @@ namespace LLInitParam return *this; } + S32 mKeyVersion; + + protected: + mutable S32 mValidatedVersion; + mutable bool mValidated; // lazy validation flag }; template<typename T> |