summaryrefslogtreecommitdiff
path: root/indra/llxuixml/llinitparam.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llxuixml/llinitparam.h')
-rw-r--r--indra/llxuixml/llinitparam.h125
1 files changed, 65 insertions, 60 deletions
diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h
index ce8a921cfe..2c854d8287 100644
--- a/indra/llxuixml/llinitparam.h
+++ b/indra/llxuixml/llinitparam.h
@@ -632,38 +632,38 @@ namespace LLInitParam
class BaseBlock* mCurrentBlockPtr; // pointer to block currently being constructed
};
- //TODO: implement in terms of owned_ptr
- template<typename T>
+ //TODO: implement in terms of owned_ptr
+ template<typename T>
class LazyValue
- {
- public:
+ {
+ public:
LazyValue()
- : mPtr(NULL)
- {}
+ : mPtr(NULL)
+ {}
~LazyValue()
- {
- delete mPtr;
- }
+ {
+ delete mPtr;
+ }
LazyValue(const T& value)
- {
+ {
mPtr = new T(value);
}
LazyValue(const LazyValue& other)
: mPtr(NULL)
- {
+ {
*this = other;
- }
+ }
LazyValue& operator = (const LazyValue& other)
{
if (!other.mPtr)
- {
+ {
delete mPtr;
- mPtr = NULL;
- }
+ mPtr = NULL;
+ }
else
{
if (!mPtr)
@@ -674,9 +674,9 @@ namespace LLInitParam
{
*mPtr = *(other.mPtr);
}
+ }
+ return *this;
}
- return *this;
- }
bool operator==(const LazyValue& other) const
{
@@ -684,13 +684,13 @@ namespace LLInitParam
return *mPtr == *other.mPtr;
}
- bool empty() const
- {
- return mPtr == NULL;
- }
+ bool empty() const
+ {
+ return mPtr == NULL;
+ }
- void set(const T& other)
- {
+ void set(const T& other)
+ {
if (!mPtr)
{
mPtr = new T(other);
@@ -701,36 +701,36 @@ namespace LLInitParam
}
}
- const T& get() const
- {
+ const T& get() const
+ {
return *ensureInstance();
- }
+ }
- T& get()
- {
+ T& get()
+ {
return *ensureInstance();
}
operator const T&() const
{
return get();
- }
+ }
- private:
- // lazily allocate an instance of T
- T* ensureInstance() const
- {
- if (mPtr == NULL)
+ private:
+ // lazily allocate an instance of T
+ T* ensureInstance() const
{
- mPtr = new T();
+ if (mPtr == NULL)
+ {
+ mPtr = new T();
+ }
+ return mPtr;
}
- return mPtr;
- }
- private:
+ private:
- mutable T* mPtr;
- };
+ mutable T* mPtr;
+ };
// root class of all parameter blocks
@@ -918,7 +918,7 @@ namespace LLInitParam
U32 mIsProvided:1;
};
-
+
template<typename T, typename NAME_VALUE_LOOKUP = TypeValues<T> >
struct ParamIterator
{
@@ -1291,7 +1291,7 @@ namespace LLInitParam
public:
typedef typename param_value_t::value_t value_t;
-
+
TypedParam(BlockDescriptor& block_descriptor, const char* name, const default_value_t& value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count)
: Param(block_descriptor.mCurrentBlockPtr)
{
@@ -1398,13 +1398,14 @@ namespace LLInitParam
return mValues.back();
}
- void add(const value_t& item)
+ self_t& add(const value_t& item)
{
mValues.push_back(item);
setProvided();
+ return *this;
}
- void add(const typename named_value_t::name_t& name)
+ self_t& add(const typename named_value_lookup_t::name_t& name)
{
value_t value;
@@ -1414,6 +1415,8 @@ namespace LLInitParam
add(value);
mValues.back().setValueName(name);
}
+
+ return *this;
}
// implicit conversion
@@ -1490,7 +1493,7 @@ namespace LLInitParam
typedef typename container_t::iterator iterator;
typedef typename container_t::const_iterator const_iterator;
public:
- typedef typename param_value_t::value_t value_t;
+ typedef typename param_value_t::value_t value_t;
TypedParam(BlockDescriptor& block_descriptor, const char* name, const default_value_t& value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count)
: Param(block_descriptor.mCurrentBlockPtr)
@@ -1584,7 +1587,7 @@ namespace LLInitParam
if (named_value_t::getPossibleValues())
{
parser.inspectValue<std::string>(name_stack, min_count, max_count, named_value_t::getPossibleValues());
- }
+ }
value_param.inspectBlock(parser, name_stack, min_count, max_count);
}
@@ -1602,13 +1605,14 @@ namespace LLInitParam
return mValues.back();
}
- void add(const value_t& item)
+ self_t& add(const value_t& item)
{
mValues.push_back(item);
setProvided();
+ return *this;
}
- void add(const typename named_value_t::name_t& name)
+ self_t& add(const typename named_value_lookup_t::name_t& name)
{
value_t value;
@@ -1618,6 +1622,7 @@ namespace LLInitParam
add(value);
mValues.back().setValueName(name);
}
+ return *this;
}
// implicit conversion
@@ -1914,7 +1919,7 @@ namespace LLInitParam
class Mandatory : public TypedParam<T, NAME_VALUE_LOOKUP, false>
{
typedef TypedParam<T, NAME_VALUE_LOOKUP, false> super_t;
- typedef Mandatory<T, NAME_VALUE_LOOKUP> self_t;
+ typedef Mandatory<T, NAME_VALUE_LOOKUP> self_t;
typedef typename super_t::value_t value_t;
typedef typename super_t::default_value_t default_value_t;
@@ -1951,13 +1956,13 @@ namespace LLInitParam
class Multiple : public TypedParam<T, NAME_VALUE_LOOKUP, true>
{
typedef TypedParam<T, NAME_VALUE_LOOKUP, true> super_t;
- typedef Multiple<T, RANGE, NAME_VALUE_LOOKUP> self_t;
- typedef typename super_t::container_t container_t;
+ typedef Multiple<T, RANGE, NAME_VALUE_LOOKUP> self_t;
+ typedef typename super_t::container_t container_t;
typedef typename super_t::value_t value_t;
public:
- typedef typename super_t::iterator iterator;
- typedef typename super_t::const_iterator const_iterator;
+ typedef typename super_t::iterator iterator;
+ typedef typename super_t::const_iterator const_iterator;
explicit Multiple(const char* name = "")
: super_t(DERIVED_BLOCK::getBlockDescriptor(), name, container_t(), &validate, RANGE::minCount, RANGE::maxCount)
@@ -2123,7 +2128,7 @@ namespace LLInitParam
resetToDefault();
}
return mValue.deserializeBlock(p, name_stack_range, new_name);
- }
+ }
void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const self_t* diff_block = NULL) const
{
@@ -2308,7 +2313,7 @@ namespace LLInitParam
public:
typedef typename InnerMostType<T>::value_t value_t;
typedef LazyValue<T> default_value_t;
-
+
ParamValue()
: mValue(),
mValidated(false)
@@ -2382,7 +2387,7 @@ namespace LLInitParam
template<typename T, typename BLOCK_T>
class ParamValue <BaseBlock::Lazy<T, NOT_BLOCK>, BLOCK_T>
- {
+ {
typedef ParamValue <BaseBlock::Lazy<T, NOT_BLOCK>, BLOCK_T> self_t;
public:
@@ -2403,7 +2408,7 @@ namespace LLInitParam
: mValue(value),
mValidated(false)
{}
-
+
void setValue(const value_t& val)
{
mValue.set(val);
@@ -2478,10 +2483,10 @@ namespace LLInitParam
} EValueAge;
typedef ParamValue<T> derived_t;
- typedef CustomParamValue<T> self_t;
- typedef Block<derived_t> block_t;
+ typedef CustomParamValue<T> self_t;
+ typedef Block<derived_t> block_t;
typedef T default_value_t;
- typedef T value_t;
+ typedef T value_t;
typedef void baseblock_base_class_t;