diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llxuixml/llinitparam.h | 93 | ||||
| -rw-r--r-- | indra/llxuixml/llxuiparser.cpp | 4 | 
2 files changed, 80 insertions, 17 deletions
| diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index ec14bc2fdc..575e8231bd 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -572,7 +572,7 @@ namespace LLInitParam  		static bool equals(const BaseBlock::Lazy<T>& a, const BaseBlock::Lazy<T>& b) { return !a.empty() || !b.empty(); }  	}; -		class Param +	class Param  	{  	public:  		void setProvided(bool is_provided = true) @@ -580,6 +580,12 @@ namespace LLInitParam  			mIsProvided = is_provided;  			enclosingBlock().paramChanged(*this, is_provided);  		} + +		Param& operator =(const Param& other) +		{ +			setProvided(other.mIsProvided); +			return *this; +		}  	protected:  		bool anyProvided() const { return mIsProvided; } @@ -671,7 +677,7 @@ namespace LLInitParam  		self_t& operator =(const self_t& other)  		{  			mValue = other.mValue; -			static_cast<NAME_VALUE_LOOKUP&>(*this) = other; +			NAME_VALUE_LOOKUP::operator =(other);  			return *this;  		} @@ -742,8 +748,8 @@ namespace LLInitParam  		self_t& operator =(const self_t& other)  		{ -			static_cast<T&>(*this) = other; -			static_cast<NAME_VALUE_LOOKUP&>(*this) = other; +			T::operator = (other); +			NAME_VALUE_LOOKUP::operator =(other);  			mValidatedVersion = other.mValidatedVersion;  			mValidated = other.mValidated;  			return *this; @@ -753,6 +759,54 @@ namespace LLInitParam  		mutable bool 	mValidated; // lazy validation flag  	}; +	template<typename NAME_VALUE_LOOKUP> +	class ParamValue<std::string, NAME_VALUE_LOOKUP, false> +	: public NAME_VALUE_LOOKUP +	{ +	public: +		typedef const std::string&	value_assignment_t; +		typedef ParamValue<std::string, NAME_VALUE_LOOKUP, false>	self_t; + +		ParamValue(): mValue() {} +		ParamValue(value_assignment_t other) : mValue(other) {} + +		void setValue(value_assignment_t val) +		{ +			if (NAME_VALUE_LOOKUP::getValueFromName(val, mValue)) +			{ +				setValueName(val); +			} +			else +			{ +				mValue = val; +			} +		} + +		value_assignment_t getValue() const +		{ +			return mValue; +		} + +		std::string& getValue() +		{ +			return mValue; +		} + +		operator value_assignment_t() const +		{ +			return mValue; +		} + +		value_assignment_t operator()() const +		{ +			return mValue; +		} + +	protected: +		std::string mValue; +	}; + +  	template<typename T, typename NAME_VALUE_LOOKUP = TypeValues<T> >  	struct ParamIterator  	{ @@ -776,6 +830,8 @@ namespace LLInitParam  		typedef NAME_VALUE_LOOKUP															name_value_lookup_t;  		typedef ParamValue<T, NAME_VALUE_LOOKUP>											param_value_t; +		using param_value_t::operator(); +  		TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count)   		:	Param(block_descriptor.mCurrentBlockPtr)  		{ @@ -877,11 +933,6 @@ namespace LLInitParam  			}  		} -		self_t& operator =(typename const name_value_lookup_t::name_t& name) -		{ -			return static_cast<self_t&>(param_value_t::operator =(name)); -		} -  		void set(value_assignment_t val, bool flag_as_provided = true)  		{  			param_value_t::clearValueName(); @@ -889,6 +940,11 @@ namespace LLInitParam  			setProvided(flag_as_provided);  		} +		self_t& operator =(const typename NAME_VALUE_LOOKUP::name_t& name) +		{ +			return static_cast<self_t&>(param_value_t::operator =(name)); +		} +  	protected:  		static bool mergeWith(Param& dst, const Param& src, bool overwrite)  		{ @@ -919,6 +975,8 @@ namespace LLInitParam  		typedef NAME_VALUE_LOOKUP								name_value_lookup_t;  		typedef ParamValue<T, NAME_VALUE_LOOKUP>				param_value_t; +		using param_value_t::operator(); +  		TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count)  		:	Param(block_descriptor.mCurrentBlockPtr),  			param_value_t(value) @@ -1023,6 +1081,11 @@ namespace LLInitParam  			setProvided(flag_as_provided);  		} +		self_t& operator =(const typename NAME_VALUE_LOOKUP::name_t& name) +		{ +			return static_cast<self_t&>(param_value_t::operator =(name)); +		} +  		// propagate changed status up to enclosing block  		/*virtual*/ void paramChanged(const Param& changed_param, bool user_provided)  		{  @@ -1189,7 +1252,9 @@ namespace LLInitParam  		void add(const value_t& item)  		{ -			mValues.push_back(param_value_t(item)); +			param_value_t param_value; +			param_value.setValue(item); +			mValues.push_back(param_value);  			setProvided();  		} @@ -1537,7 +1602,7 @@ namespace LLInitParam  			typedef TypedParam<T, NAME_VALUE_LOOKUP, false, IsBlock<ParamValue<T, NAME_VALUE_LOOKUP> >::value>		super_t;  			typedef typename super_t::value_assignment_t								value_assignment_t; -			using super_t::param_value_t::operator =; +			using super_t::operator =;  			explicit Alternative(const char* name = "", value_assignment_t val = defaultValue<T>())  			:	super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1), @@ -1656,8 +1721,8 @@ namespace LLInitParam  			typedef typename super_t::value_assignment_t								value_assignment_t;  			using super_t::operator(); -			using super_t::param_value_t::operator =; - +			using super_t::operator =; +			  			explicit Optional(const char* name = "", value_assignment_t val = defaultValue<T>())  			:	super_t(DERIVED_BLOCK::selfBlockDescriptor(), name, val, NULL, 0, 1)  			{ @@ -1686,7 +1751,7 @@ namespace LLInitParam  			typedef typename super_t::value_assignment_t								value_assignment_t;  			using super_t::operator(); -			using super_t::param_value_t::operator =; +			using super_t::operator =;  			// mandatory parameters require a name to be parseable  			explicit Mandatory(const char* name = "", value_assignment_t val = defaultValue<T>()) diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index cdf578113a..90c2671242 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -61,8 +61,6 @@ const S32 LINE_NUMBER_HERE = 0;  struct MaxOccursValues : public LLInitParam::TypeValuesHelper<U32, MaxOccursValues>  { -	using TypeValuesHelper<U32, MaxOccursValues>::operator =; -	typedef std::string name_t;  	static void declareValues()  	{  		declare("unbounded", U32_MAX); @@ -73,11 +71,11 @@ struct Occurs : public LLInitParam::Block<Occurs>  {  	Optional<U32>					minOccurs;  	Optional<U32, MaxOccursValues>	maxOccurs; -	Multiple<U32, AnyAmount, MaxOccursValues> foo;  	Occurs()  	:	minOccurs("minOccurs", 0),  		maxOccurs("maxOccurs", U32_MAX) +  	{}  }; | 
