summaryrefslogtreecommitdiff
path: root/indra/llxuixml
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2009-10-15 19:56:45 +0000
committerRichard Nelson <richard@lindenlab.com>2009-10-15 19:56:45 +0000
commit5edb4f2171fb92ff64913459a63afb20474db25a (patch)
tree2a32ae948197921d81f90de735637df8c758c96a /indra/llxuixml
parent56fed69c4a5c801e46b61f85e6e01fcd302ae2e5 (diff)
removed requirement for specializing ParamCompare on boost::function types
eliminated usage of iterator_range from LLInitParam made LLTextEditor::addChar consistent with truncate in counting text bytes (not including null terminator) EXT-1494 - Avatar profile description text truncated to 255 characters reviewed by Leyla
Diffstat (limited to 'indra/llxuixml')
-rw-r--r--indra/llxuixml/llinitparam.cpp41
-rw-r--r--indra/llxuixml/llinitparam.h61
-rw-r--r--indra/llxuixml/lluicolor.cpp13
-rw-r--r--indra/llxuixml/lluicolor.h16
4 files changed, 52 insertions, 79 deletions
diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp
index 1b867b79c9..1abd411f37 100644
--- a/indra/llxuixml/llinitparam.cpp
+++ b/indra/llxuixml/llinitparam.cpp
@@ -127,7 +127,7 @@ namespace LLInitParam
bool BaseBlock::submitValue(const Parser::name_stack_t& name_stack, Parser& p, bool silent)
{
- if (!deserializeBlock(p, boost::make_iterator_range(name_stack.begin(), name_stack.end())))
+ if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end())))
{
if (!silent)
{
@@ -304,11 +304,11 @@ namespace LLInitParam
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack)
{
BlockDescriptor& block_data = getBlockDescriptor();
- bool names_left = !name_stack.empty();
+ bool names_left = name_stack.first != name_stack.second;
if (names_left)
{
- const std::string& top_name = name_stack.front().first;
+ const std::string& top_name = name_stack.first->first;
ParamDescriptor::deserialize_func_t deserialize_func = NULL;
Param* paramp = NULL;
@@ -331,10 +331,11 @@ namespace LLInitParam
}
}
- Parser::name_stack_range_t new_name_stack(++name_stack.begin(), name_stack.end());
+ Parser::name_stack_range_t new_name_stack(name_stack.first, name_stack.second);
+ ++new_name_stack.first;
if (deserialize_func)
{
- return deserialize_func(*paramp, p, new_name_stack, name_stack.empty() ? -1 : name_stack.front().second);
+ return deserialize_func(*paramp, p, new_name_stack, name_stack.first == name_stack.second ? -1 : name_stack.first->second);
}
}
@@ -346,7 +347,7 @@ namespace LLInitParam
Param* paramp = getParamFromHandle((*it)->mParamHandle);
ParamDescriptor::deserialize_func_t deserialize_func = (*it)->mDeserializeFunc;
- if (deserialize_func && deserialize_func(*paramp, p, name_stack, name_stack.empty() ? -1 : name_stack.front().second))
+ if (deserialize_func && deserialize_func(*paramp, p, name_stack, name_stack.first == name_stack.second ? -1 : name_stack.first->second))
{
mLastChangedParam = (*it)->mParamHandle;
return true;
@@ -499,33 +500,7 @@ namespace LLInitParam
return param_changed;
}
-
- template<>
- bool ParamCompare<boost::function<void (const std::string &,void *)> >::equals(
- const boost::function<void (const std::string &,void *)> &a,
- const boost::function<void (const std::string &,void *)> &b)
- {
- return false;
- }
-
- template<>
- bool ParamCompare<boost::function<void (const LLSD &,const LLSD &)> >::equals(
- const boost::function<void (const LLSD &,const LLSD &)> &a,
- const boost::function<void (const LLSD &,const LLSD &)> &b)
- {
- return false;
- }
-
- template<>
- bool ParamCompare<boost::function<void (void)> >::equals(
- const boost::function<void (void)> &a,
- const boost::function<void (void)> &b)
- {
- return false;
- }
-
- template<>
- bool ParamCompare<LLSD>::equals(const LLSD &a, const LLSD &b)
+ bool ParamCompare<LLSD, boost::false_type>::equals(const LLSD &a, const LLSD &b)
{
return false;
}
diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h
index 88bc430504..193d8c1f64 100644
--- a/indra/llxuixml/llinitparam.h
+++ b/indra/llxuixml/llinitparam.h
@@ -39,25 +39,31 @@
#include <stddef.h>
#include <boost/function.hpp>
#include <boost/bind.hpp>
-#include <boost/range/iterator_range.hpp>
+#include <boost/type_traits/is_convertible.hpp>
#include "llregistry.h"
#include "llmemory.h"
namespace LLInitParam
{
- template <typename T>
- class ParamCompare {
- public:
- static bool equals(const T &a, const T &b);
+ template <typename T, typename IS_BOOST_FUNCTION = boost::is_convertible<T, boost::function_base>::type >
+ struct ParamCompare
+ {
+ static bool equals(const T &a, const T &b)
+ {
+ return a == b;
+ }
};
- template<class T>
- bool ParamCompare<T>::equals(const T &a, const T&b)
- {
- return a == b;
- }
-
+ // boost function types are not comparable
+ template<typename T>
+ struct ParamCompare<T, boost::true_type>
+ {
+ static bool equals(const T&a, const T &b)
+ {
+ return false;
+ }
+ };
// default constructor adaptor for InitParam Values
// constructs default instances of the given type, returned by const reference
@@ -192,7 +198,7 @@ namespace LLInitParam
};
typedef std::vector<std::pair<std::string, S32> > name_stack_t;
- typedef boost::iterator_range<name_stack_t::const_iterator> name_stack_range_t;
+ typedef std::pair<name_stack_t::const_iterator, name_stack_t::const_iterator> name_stack_range_t;
typedef std::vector<std::string> possible_values_t;
typedef boost::function<bool (void*)> parser_read_func_t;
@@ -535,7 +541,7 @@ namespace LLInitParam
{
self_t& typed_param = static_cast<self_t&>(param);
// no further names in stack, attempt to parse value now
- if (name_stack.empty())
+ if (name_stack.first == name_stack.second)
{
if (parser.readValue<T>(typed_param.mData.mValue))
{
@@ -886,7 +892,7 @@ namespace LLInitParam
self_t& typed_param = static_cast<self_t&>(param);
value_t value;
// no further names in stack, attempt to parse value now
- if (name_stack.empty())
+ if (name_stack.first == name_stack.second)
{
// attempt to read value directly
if (parser.readValue<value_t>(value))
@@ -1541,7 +1547,7 @@ namespace LLInitParam
static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation)
{
- if (name_stack.empty())
+ if (name_stack.first == name_stack.second)
{
//std::string message = llformat("Deprecated value %s ignored", getName().c_str());
//parser.parserWarning(message);
@@ -1600,7 +1606,7 @@ namespace LLInitParam
{
self_t& typed_param = static_cast<self_t&>(param);
// type to apply parse direct value T
- if (name_stack.empty())
+ if (name_stack.first == name_stack.second)
{
if(parser.readValue<T>(typed_param.mData.mValue))
{
@@ -1811,24 +1817,11 @@ namespace LLInitParam
}
};
- template<>
- bool ParamCompare<boost::function<void (const std::string &,void *)> >::equals(
- const boost::function<void (const std::string &,void *)> &a,
- const boost::function<void (const std::string &,void *)> &b);
-
- template<>
- bool ParamCompare<boost::function<void (const LLSD &,const LLSD &)> >::equals(
- const boost::function<void (const LLSD &,const LLSD &)> &a,
- const boost::function<void (const LLSD &,const LLSD &)> &b);
-
- template<>
- bool ParamCompare<boost::function<void (void)> >::equals(
- const boost::function<void (void)> &a,
- const boost::function<void (void)> &b);
-
-
- template<>
- bool ParamCompare<LLSD>::equals(const LLSD &a, const LLSD &b);
+ template<>
+ struct ParamCompare<LLSD, boost::false_type>
+ {
+ static bool equals(const LLSD &a, const LLSD &b);
+ };
}
#endif // LL_LLPARAM_H
diff --git a/indra/llxuixml/lluicolor.cpp b/indra/llxuixml/lluicolor.cpp
index ef0fa5d634..0065edb309 100644
--- a/indra/llxuixml/lluicolor.cpp
+++ b/indra/llxuixml/lluicolor.cpp
@@ -58,14 +58,9 @@ bool LLUIColor::isReference() const
namespace LLInitParam
{
// used to detect equivalence with default values on export
- template<>
- class ParamCompare<LLUIColor>
+ bool ParamCompare<LLUIColor, boost::false_type>::equals(const LLUIColor &a, const LLUIColor &b)
{
- public:
- static bool equals(const LLUIColor &a, const LLUIColor &b)
- {
- // do not detect value equivalence, treat pointers to colors as distinct from color values
- return (a.mColorPtr == NULL && b.mColorPtr == NULL ? a.mColor == b.mColor : a.mColorPtr == b.mColorPtr);
- }
- };
+ // do not detect value equivalence, treat pointers to colors as distinct from color values
+ return (a.mColorPtr == NULL && b.mColorPtr == NULL ? a.mColor == b.mColor : a.mColorPtr == b.mColorPtr);
+ }
}
diff --git a/indra/llxuixml/lluicolor.h b/indra/llxuixml/lluicolor.h
index 365f61003b..aff81a695d 100644
--- a/indra/llxuixml/lluicolor.h
+++ b/indra/llxuixml/lluicolor.h
@@ -11,11 +11,12 @@
#define LL_LLUICOLOR_H_
#include "v4color.h"
+#include <boost/type_traits/integral_constant.hpp> // for boost::false_type
namespace LLInitParam
{
- template<typename T>
- class ParamCompare;
+ template<typename T, typename IS_BOOST_FUNCTION>
+ struct ParamCompare;
}
class LLUIColor
@@ -36,10 +37,19 @@ public:
bool isReference() const;
private:
- friend class LLInitParam::ParamCompare<LLUIColor>;
+ friend struct LLInitParam::ParamCompare<LLUIColor, boost::false_type>;
const LLColor4* mColorPtr;
LLColor4 mColor;
};
+namespace LLInitParam
+{
+ template<>
+ struct ParamCompare<class LLUIColor, boost::false_type>
+ {
+ static bool equals(const class LLUIColor& a, const class LLUIColor& b);
+ };
+}
+
#endif