Moved osgIntrospection across to standard OSG coding style.
This commit is contained in:
@@ -16,11 +16,11 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
void ConstructorInfo::getInheritedProviders(CustomAttributeProviderList &providers) const
|
||||
void ConstructorInfo::getInheritedProviders(CustomAttributeProviderList& providers) const
|
||||
{
|
||||
for (int i=0; i<decltype_.getNumBaseTypes(); ++i)
|
||||
for (int i=0; i<_decltype.getNumBaseTypes(); ++i)
|
||||
{
|
||||
const ConstructorInfo *ci = decltype_.getBaseType(i).getConstructor(params_);
|
||||
const ConstructorInfo* ci = _decltype.getBaseType(i).getConstructor(_params);
|
||||
if (ci)
|
||||
{
|
||||
providers.push_back(ci);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
bool CustomAttributeProvider::isDefined(const Type &type, bool inherit) const
|
||||
bool CustomAttributeProvider::isDefined(const Type& type, bool inherit) const
|
||||
{
|
||||
for (CustomAttributeList::const_iterator i=attribs_.begin(); i!=attribs_.end(); ++i)
|
||||
if (typeid(**i) == type.getStdTypeInfo()) return true;
|
||||
@@ -36,7 +36,7 @@ bool CustomAttributeProvider::isDefined(const Type &type, bool inherit) const
|
||||
return false;
|
||||
}
|
||||
|
||||
const CustomAttribute *CustomAttributeProvider::getAttribute(const Type &type, bool inherit) const
|
||||
const CustomAttribute* CustomAttributeProvider::getAttribute(const Type& type, bool inherit) const
|
||||
{
|
||||
for (CustomAttributeList::const_iterator i=attribs_.begin(); i!=attribs_.end(); ++i)
|
||||
if (typeid(**i) == type.getStdTypeInfo()) return *i;
|
||||
@@ -48,7 +48,7 @@ const CustomAttribute *CustomAttributeProvider::getAttribute(const Type &type, b
|
||||
|
||||
for (CustomAttributeProviderList::const_iterator i=providers.begin(); i!=providers.end(); ++i)
|
||||
{
|
||||
const CustomAttribute *ca = (*i)->getAttribute(type, true);
|
||||
const CustomAttribute* ca = (*i)->getAttribute(type, true);
|
||||
if (ca) return ca;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
void MethodInfo::getInheritedProviders(CustomAttributeProviderList &providers) const
|
||||
void MethodInfo::getInheritedProviders(CustomAttributeProviderList& providers) const
|
||||
{
|
||||
for (int i=0; i<decltype_.getNumBaseTypes(); ++i)
|
||||
for (int i=0; i<_decltype.getNumBaseTypes(); ++i)
|
||||
{
|
||||
const MethodInfo *mi = decltype_.getBaseType(i).getMethod(name_, params_, false);
|
||||
const MethodInfo* mi = _decltype.getBaseType(i).getMethod(_name, _params, false);
|
||||
if (mi)
|
||||
{
|
||||
providers.push_back(mi);
|
||||
@@ -28,47 +28,47 @@ void MethodInfo::getInheritedProviders(CustomAttributeProviderList &providers) c
|
||||
}
|
||||
}
|
||||
|
||||
bool MethodInfo::overrides(const MethodInfo *other) const
|
||||
bool MethodInfo::overrides(const MethodInfo* other) const
|
||||
{
|
||||
if (isConst() != other->isConst()) return false;
|
||||
if (decltype_ != other->decltype_) return false;
|
||||
if (rtype_ != other->rtype_) return false;
|
||||
if (name_ != other->name_) return false;
|
||||
if (params_.size() != other->params_.size()) return false;
|
||||
if (isConst() != other->isConst()) return false;
|
||||
if (_decltype != other->_decltype) return false;
|
||||
if (_rtype != other->_rtype) return false;
|
||||
if (_name != other->_name) return false;
|
||||
if (_params.size() != other->_params.size()) return false;
|
||||
|
||||
ParameterInfoList::const_iterator i=params_.begin();
|
||||
ParameterInfoList::const_iterator j=other->params_.begin();
|
||||
for (; i!=params_.end(); ++i, ++j)
|
||||
{
|
||||
if (&(*i)->getParameterType() != &(*j)->getParameterType())
|
||||
return false;
|
||||
}
|
||||
ParameterInfoList::const_iterator i=_params.begin();
|
||||
ParameterInfoList::const_iterator j=other->_params.begin();
|
||||
for (; i!=_params.end(); ++i, ++j)
|
||||
{
|
||||
if (&(*i)->getParameterType() != &(*j)->getParameterType())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
/*
|
||||
std::size_t num_fixed_1 = 0;
|
||||
std::size_t num_optional_1 = 0;
|
||||
for (ParameterInfoList::const_iterator i=params_.begin(); i!=params_.end(); ++i)
|
||||
{
|
||||
if ((*i)->getDefaultValue().isEmpty())
|
||||
++num_fixed_1;
|
||||
else
|
||||
++num_optional_1;
|
||||
}
|
||||
std::size_t num_fixed_1 = 0;
|
||||
std::size_t num_optional_1 = 0;
|
||||
for (ParameterInfoList::const_iterator i=_params.begin(); i!=_params.end(); ++i)
|
||||
{
|
||||
if ((*i)->getDefaultValue().isEmpty())
|
||||
++num_fixed_1;
|
||||
else
|
||||
++num_optional_1;
|
||||
}
|
||||
|
||||
std::size_t num_fixed_2 = 0;
|
||||
std::size_t num_optional_2 = 0;
|
||||
for (ParameterInfoList::const_iterator i=other->params_.begin(); i!=other->params_.end(); ++i)
|
||||
{
|
||||
if ((*i)->getDefaultValue().isEmpty())
|
||||
++num_fixed_2;
|
||||
else
|
||||
++num_optional_2;
|
||||
}
|
||||
std::size_t num_fixed_2 = 0;
|
||||
std::size_t num_optional_2 = 0;
|
||||
for (ParameterInfoList::const_iterator i=other->_params.begin(); i!=other->_params.end(); ++i)
|
||||
{
|
||||
if ((*i)->getDefaultValue().isEmpty())
|
||||
++num_fixed_2;
|
||||
else
|
||||
++num_optional_2;
|
||||
}
|
||||
|
||||
if (num_fixed_1 > num_fixed_2)
|
||||
{
|
||||
}
|
||||
if (num_fixed_1 > num_fixed_2)
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
void PropertyInfo::getInheritedProviders(CustomAttributeProviderList &providers) const
|
||||
void PropertyInfo::getInheritedProviders(CustomAttributeProviderList& providers) const
|
||||
{
|
||||
for (int i=0; i<decltype_.getNumBaseTypes(); ++i)
|
||||
for (int i=0; i<_decltype.getNumBaseTypes(); ++i)
|
||||
{
|
||||
const PropertyInfo *pi = decltype_.getBaseType(i).getProperty(name_, ptype_, getIndexParameters(), false);
|
||||
const PropertyInfo* pi = _decltype.getBaseType(i).getProperty(_name, _ptype, getIndexParameters(), false);
|
||||
if (pi)
|
||||
{
|
||||
providers.push_back(pi);
|
||||
@@ -30,7 +30,7 @@ void PropertyInfo::getInheritedProviders(CustomAttributeProviderList &providers)
|
||||
}
|
||||
}
|
||||
|
||||
Value PropertyInfo::getValue(const Value &instance) const
|
||||
Value PropertyInfo::getValue(const Value& instance) const
|
||||
{
|
||||
const PropertyTypeAttribute *pta = getAttribute<PropertyTypeAttribute>(false);
|
||||
const CustomPropertyGetAttribute *cget = getAttribute<CustomPropertyGetAttribute>(false);
|
||||
@@ -42,15 +42,15 @@ Value PropertyInfo::getValue(const Value &instance) const
|
||||
return cget->getGetter()->get(instance);
|
||||
}
|
||||
|
||||
if (!getm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::GET);
|
||||
if (!_getm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::GET);
|
||||
|
||||
if (pta)
|
||||
return getm_->invoke(instance).convertTo(pta->getPropertyType());
|
||||
return getm_->invoke(instance);
|
||||
return _getm->invoke(instance).convertTo(pta->getPropertyType());
|
||||
return _getm->invoke(instance);
|
||||
}
|
||||
|
||||
Value PropertyInfo::getValue(Value &instance) const
|
||||
Value PropertyInfo::getValue(Value& instance) const
|
||||
{
|
||||
const PropertyTypeAttribute *pta = getAttribute<PropertyTypeAttribute>(false);
|
||||
const CustomPropertyGetAttribute *cget = getAttribute<CustomPropertyGetAttribute>(false);
|
||||
@@ -62,15 +62,15 @@ Value PropertyInfo::getValue(Value &instance) const
|
||||
return cget->getGetter()->get(instance);
|
||||
}
|
||||
|
||||
if (!getm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::GET);
|
||||
if (!_getm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::GET);
|
||||
|
||||
if (pta)
|
||||
return getm_->invoke(instance).convertTo(pta->getPropertyType());
|
||||
return getm_->invoke(instance);
|
||||
return _getm->invoke(instance).convertTo(pta->getPropertyType());
|
||||
return _getm->invoke(instance);
|
||||
}
|
||||
|
||||
void PropertyInfo::setValue(Value &instance, const Value &value) const
|
||||
void PropertyInfo::setValue(Value& instance, const Value& value) const
|
||||
{
|
||||
const CustomPropertySetAttribute *cset = getAttribute<CustomPropertySetAttribute>(false);
|
||||
|
||||
@@ -80,15 +80,15 @@ void PropertyInfo::setValue(Value &instance, const Value &value) const
|
||||
return;
|
||||
}
|
||||
|
||||
if (!setm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::SET);
|
||||
if (!_setm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::SET);
|
||||
|
||||
ValueList args;
|
||||
args.push_back(value);
|
||||
setm_->invoke(instance, args);
|
||||
_setm->invoke(instance, args);
|
||||
}
|
||||
|
||||
Value PropertyInfo::getIndexedValue(const Value &instance, ValueList &args) const
|
||||
Value PropertyInfo::getIndexedValue(const Value& instance, ValueList& args) const
|
||||
{
|
||||
const PropertyTypeAttribute *pta = getAttribute<PropertyTypeAttribute>(false);
|
||||
const CustomPropertyGetAttribute *cget = getAttribute<CustomPropertyGetAttribute>(false);
|
||||
@@ -100,15 +100,15 @@ Value PropertyInfo::getIndexedValue(const Value &instance, ValueList &args) cons
|
||||
return cget->getGetter()->get(instance, args);
|
||||
}
|
||||
|
||||
if (!getm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::IGET);
|
||||
if (!_getm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::IGET);
|
||||
|
||||
if (pta)
|
||||
return getm_->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return getm_->invoke(instance, args);
|
||||
return _getm->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return _getm->invoke(instance, args);
|
||||
}
|
||||
|
||||
Value PropertyInfo::getIndexedValue(Value &instance, ValueList &args) const
|
||||
Value PropertyInfo::getIndexedValue(Value& instance, ValueList& args) const
|
||||
{
|
||||
const PropertyTypeAttribute *pta = getAttribute<PropertyTypeAttribute>(false);
|
||||
const CustomPropertyGetAttribute *cget = getAttribute<CustomPropertyGetAttribute>(false);
|
||||
@@ -120,15 +120,15 @@ Value PropertyInfo::getIndexedValue(Value &instance, ValueList &args) const
|
||||
return cget->getGetter()->get(instance, args);
|
||||
}
|
||||
|
||||
if (!getm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::IGET);
|
||||
if (!_getm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::IGET);
|
||||
|
||||
if (pta)
|
||||
return getm_->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return getm_->invoke(instance, args);
|
||||
return _getm->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return _getm->invoke(instance, args);
|
||||
}
|
||||
|
||||
void PropertyInfo::setIndexedValue(Value &instance, ValueList &args, const Value &value) const
|
||||
void PropertyInfo::setIndexedValue(Value& instance, ValueList& args, const Value& value) const
|
||||
{
|
||||
const CustomPropertySetAttribute *cset = getAttribute<CustomPropertySetAttribute>(false);
|
||||
if (cset)
|
||||
@@ -137,26 +137,26 @@ void PropertyInfo::setIndexedValue(Value &instance, ValueList &args, const Value
|
||||
return;
|
||||
}
|
||||
|
||||
if (!setm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::ISET);
|
||||
if (!_setm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::ISET);
|
||||
|
||||
args.push_back(value);
|
||||
setm_->invoke(instance, args);
|
||||
_setm->invoke(instance, args);
|
||||
args.pop_back();
|
||||
}
|
||||
|
||||
int PropertyInfo::getNumArrayItems(const Value &instance) const
|
||||
int PropertyInfo::getNumArrayItems(const Value& instance) const
|
||||
{
|
||||
const CustomPropertyCountAttribute *ccount = getAttribute<CustomPropertyCountAttribute>(false);
|
||||
if (ccount) return ccount->getCounter()->count(instance);
|
||||
|
||||
if (!numm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::COUNT);
|
||||
if (!_numm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::COUNT);
|
||||
|
||||
return variant_cast<int>(numm_->invoke(instance));
|
||||
return variant_cast<int>(_numm->invoke(instance));
|
||||
}
|
||||
|
||||
Value PropertyInfo::getArrayItem(const Value &instance, int i) const
|
||||
Value PropertyInfo::getArrayItem(const Value& instance, int i) const
|
||||
{
|
||||
const PropertyTypeAttribute *pta = getAttribute<PropertyTypeAttribute>(false);
|
||||
const CustomPropertyGetAttribute *cget = getAttribute<CustomPropertyGetAttribute>(false);
|
||||
@@ -168,18 +168,18 @@ Value PropertyInfo::getArrayItem(const Value &instance, int i) const
|
||||
return cget->getGetter()->get(instance, i);
|
||||
}
|
||||
|
||||
if (!getm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::AGET);
|
||||
if (!_getm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::AGET);
|
||||
|
||||
ValueList args;
|
||||
args.push_back(i);
|
||||
|
||||
if (pta)
|
||||
return getm_->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return getm_->invoke(instance, args);
|
||||
return _getm->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return _getm->invoke(instance, args);
|
||||
}
|
||||
|
||||
Value PropertyInfo::getArrayItem(Value &instance, int i) const
|
||||
Value PropertyInfo::getArrayItem(Value& instance, int i) const
|
||||
{
|
||||
const PropertyTypeAttribute *pta = getAttribute<PropertyTypeAttribute>(false);
|
||||
const CustomPropertyGetAttribute *cget = getAttribute<CustomPropertyGetAttribute>(false);
|
||||
@@ -191,18 +191,18 @@ Value PropertyInfo::getArrayItem(Value &instance, int i) const
|
||||
return cget->getGetter()->get(instance, i);
|
||||
}
|
||||
|
||||
if (!getm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::AGET);
|
||||
if (!_getm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::AGET);
|
||||
|
||||
ValueList args;
|
||||
args.push_back(i);
|
||||
|
||||
if (pta)
|
||||
return getm_->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return getm_->invoke(instance, args);
|
||||
return _getm->invoke(instance, args).convertTo(pta->getPropertyType());
|
||||
return _getm->invoke(instance, args);
|
||||
}
|
||||
|
||||
void PropertyInfo::setArrayItem(Value &instance, int i, const Value &value) const
|
||||
void PropertyInfo::setArrayItem(Value& instance, int i, const Value& value) const
|
||||
{
|
||||
const CustomPropertySetAttribute *cset = getAttribute<CustomPropertySetAttribute>(false);
|
||||
if (cset)
|
||||
@@ -211,16 +211,16 @@ void PropertyInfo::setArrayItem(Value &instance, int i, const Value &value) cons
|
||||
return;
|
||||
}
|
||||
|
||||
if (!setm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::ASET);
|
||||
if (!_setm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::ASET);
|
||||
|
||||
ValueList args;
|
||||
args.push_back(i);
|
||||
args.push_back(value);
|
||||
setm_->invoke(instance, args);
|
||||
_setm->invoke(instance, args);
|
||||
}
|
||||
|
||||
void PropertyInfo::addArrayItem(Value &instance, const Value &value) const
|
||||
void PropertyInfo::addArrayItem(Value& instance, const Value& value) const
|
||||
{
|
||||
const CustomPropertyAddAttribute *cadd = getAttribute<CustomPropertyAddAttribute>(false);
|
||||
if (cadd)
|
||||
@@ -229,15 +229,15 @@ void PropertyInfo::addArrayItem(Value &instance, const Value &value) const
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::ADD);
|
||||
if (!_addm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::ADD);
|
||||
|
||||
ValueList args;
|
||||
args.push_back(value);
|
||||
addm_->invoke(instance, args);
|
||||
_addm->invoke(instance, args);
|
||||
}
|
||||
|
||||
void PropertyInfo::removeArrayItem(Value &instance, int i) const
|
||||
void PropertyInfo::removeArrayItem(Value& instance, int i) const
|
||||
{
|
||||
const CustomPropertyRemoveAttribute *crem = getAttribute<CustomPropertyRemoveAttribute>(false);
|
||||
if (crem)
|
||||
@@ -246,19 +246,19 @@ void PropertyInfo::removeArrayItem(Value &instance, int i) const
|
||||
return;
|
||||
}
|
||||
|
||||
if (!remm_)
|
||||
throw PropertyAccessException(decltype_.getQualifiedName() + "::" + name_, PropertyAccessException::REMOVE);
|
||||
if (!_remm)
|
||||
throw PropertyAccessException(_decltype.getQualifiedName() + "::" + _name, PropertyAccessException::REMOVE);
|
||||
|
||||
ValueList args;
|
||||
args.push_back(i);
|
||||
remm_->invoke(instance, args);
|
||||
_remm->invoke(instance, args);
|
||||
}
|
||||
|
||||
Value PropertyInfo::getDefaultValue() const
|
||||
{
|
||||
if (isArray() || isIndexed()) return Value();
|
||||
|
||||
const CustomAttributeList &cal = getCustomAttributes();
|
||||
const CustomAttributeList& cal = getCustomAttributes();
|
||||
for (CustomAttributeList::const_iterator i=cal.begin(); i!=cal.end(); ++i)
|
||||
{
|
||||
if (dynamic_cast<const NoDefaultValueAttribute *>(*i) != 0)
|
||||
@@ -271,19 +271,19 @@ Value PropertyInfo::getDefaultValue() const
|
||||
}
|
||||
}
|
||||
|
||||
if (decltype_.isAbstract())
|
||||
if (_decltype.isAbstract())
|
||||
{
|
||||
if (ptype_.isAbstract() || !ptype_.isDefined())
|
||||
if (_ptype.isAbstract() || !_ptype.isDefined())
|
||||
return Value();
|
||||
return ptype_.createInstance();
|
||||
return _ptype.createInstance();
|
||||
}
|
||||
|
||||
// auto default value
|
||||
Value instance = decltype_.createInstance();
|
||||
Value instance = _decltype.createInstance();
|
||||
return getValue(instance);
|
||||
}
|
||||
|
||||
void PropertyInfo::getIndexValueSet(int whichindex, const Value &instance, ValueList &values) const
|
||||
void PropertyInfo::getIndexValueSet(int whichindex, const Value& instance, ValueList& values) const
|
||||
{
|
||||
const CustomIndexAttribute *cia = getAttribute<CustomIndexAttribute>(false);
|
||||
if (cia)
|
||||
@@ -293,7 +293,7 @@ void PropertyInfo::getIndexValueSet(int whichindex, const Value &instance, Value
|
||||
else
|
||||
{
|
||||
std::map<int, const IndexTypeAttribute *> ita_map;
|
||||
const CustomAttributeList &cal = getCustomAttributes();
|
||||
const CustomAttributeList& cal = getCustomAttributes();
|
||||
for (CustomAttributeList::const_iterator i=cal.begin(); i!=cal.end(); ++i)
|
||||
{
|
||||
const IndexTypeAttribute *ita = dynamic_cast<const IndexTypeAttribute *>(*i);
|
||||
@@ -301,21 +301,21 @@ void PropertyInfo::getIndexValueSet(int whichindex, const Value &instance, Value
|
||||
ita_map[ita->getWhichIndex()] = ita;
|
||||
}
|
||||
|
||||
const EnumLabelMap &elm = getIndexParameters().at(whichindex)->getParameterType().getEnumLabels();
|
||||
const EnumLabelMap& elm = getIndexParameters().at(whichindex)->getParameterType().getEnumLabels();
|
||||
if (elm.empty())
|
||||
throw IndexValuesNotDefinedException(name_, getIndexParameters().at(whichindex)->getName());
|
||||
throw IndexValuesNotDefinedException(_name, getIndexParameters().at(whichindex)->getName());
|
||||
|
||||
for (EnumLabelMap::const_iterator i=elm.begin(); i!=elm.end(); ++i)
|
||||
{
|
||||
if (ita_map[whichindex])
|
||||
values.push_back(Value(i->first).convertTo(ita_map[whichindex]->getIndexType()));
|
||||
else
|
||||
values.push_back(Value(i->first).convertTo(indices_[whichindex]->getParameterType()));
|
||||
values.push_back(Value(i->first).convertTo(_indices[whichindex]->getParameterType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ParameterInfoList &PropertyInfo::getIndexParameters() const
|
||||
const ParameterInfoList& PropertyInfo::getIndexParameters() const
|
||||
{
|
||||
const CustomIndexAttribute *cia = getAttribute<CustomIndexAttribute>(false);
|
||||
if (cia)
|
||||
@@ -323,5 +323,5 @@ const ParameterInfoList &PropertyInfo::getIndexParameters() const
|
||||
return cia->getIndexInfo()->getIndexParameters();
|
||||
}
|
||||
|
||||
return indices_;
|
||||
return _indices;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
Reflection::StaticData *Reflection::staticdata__ = 0;
|
||||
Reflection::StaticData* Reflection::_static_data = 0;
|
||||
|
||||
Reflection::StaticData::~StaticData()
|
||||
{
|
||||
@@ -26,29 +26,29 @@ Reflection::StaticData::~StaticData()
|
||||
}
|
||||
}
|
||||
|
||||
const TypeMap &Reflection::getTypes()
|
||||
const TypeMap& Reflection::getTypes()
|
||||
{
|
||||
return getOrCreateStaticData().typemap;
|
||||
}
|
||||
|
||||
Reflection::StaticData &Reflection::getOrCreateStaticData()
|
||||
Reflection::StaticData& Reflection::getOrCreateStaticData()
|
||||
{
|
||||
static OpenThreads::Mutex access_mtx;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(access_mtx);
|
||||
|
||||
if (!staticdata__)
|
||||
if (!_static_data)
|
||||
{
|
||||
staticdata__ = new StaticData;
|
||||
_static_data = new StaticData;
|
||||
std::auto_ptr<Type> tvoid(new Type(typeid(void)));
|
||||
staticdata__->typemap.insert(std::make_pair(&typeid(void), tvoid.get()));
|
||||
staticdata__->type_void = tvoid.release();
|
||||
_static_data->typemap.insert(std::make_pair(&typeid(void), tvoid.get()));
|
||||
_static_data->type_void = tvoid.release();
|
||||
}
|
||||
return *staticdata__;
|
||||
return *_static_data;
|
||||
}
|
||||
|
||||
const Type &Reflection::getType(const std::type_info &ti)
|
||||
const Type& Reflection::getType(const std::type_info& ti)
|
||||
{
|
||||
const TypeMap &types = getTypes();
|
||||
const TypeMap& types = getTypes();
|
||||
|
||||
TypeMap::const_iterator i = types.find(&ti);
|
||||
if (i == types.end())
|
||||
@@ -58,9 +58,9 @@ const Type &Reflection::getType(const std::type_info &ti)
|
||||
return *i->second;
|
||||
}
|
||||
|
||||
const Type &Reflection::getType(const std::string &qname)
|
||||
const Type& Reflection::getType(const std::string& qname)
|
||||
{
|
||||
const TypeMap &types = getTypes();
|
||||
const TypeMap& types = getTypes();
|
||||
|
||||
for (TypeMap::const_iterator i=types.begin(); i!=types.end(); ++i)
|
||||
{
|
||||
@@ -74,21 +74,21 @@ const Type &Reflection::getType(const std::string &qname)
|
||||
throw TypeNotFoundException(qname);
|
||||
}
|
||||
|
||||
const Type &Reflection::type_void()
|
||||
const Type& Reflection::type_void()
|
||||
{
|
||||
return *getOrCreateStaticData().type_void;
|
||||
}
|
||||
|
||||
Type *Reflection::registerType(const std::type_info &ti)
|
||||
Type* Reflection::registerType(const std::type_info& ti)
|
||||
{
|
||||
std::auto_ptr<Type> type(new Type(ti));
|
||||
getOrCreateStaticData().typemap.insert(std::make_pair(&ti, type.get()));
|
||||
return type.release();
|
||||
}
|
||||
|
||||
Type *Reflection::getOrRegisterType(const std::type_info &ti, bool replace_if_defined)
|
||||
Type* Reflection::getOrRegisterType(const std::type_info& ti, bool replace_if_defined)
|
||||
{
|
||||
TypeMap &tm = getOrCreateStaticData().typemap;
|
||||
TypeMap& tm = getOrCreateStaticData().typemap;
|
||||
TypeMap::iterator i = tm.find(&ti);
|
||||
|
||||
if (i != tm.end())
|
||||
@@ -97,12 +97,12 @@ Type *Reflection::getOrRegisterType(const std::type_info &ti, bool replace_if_de
|
||||
{
|
||||
std::string old_name = i->second->getName();
|
||||
std::string old_namespace = i->second->getNamespace();
|
||||
std::vector<std::string> old_aliases = i->second->aliases_;
|
||||
std::vector<std::string> old_aliases = i->second->_aliases;
|
||||
|
||||
Type *newtype = new (i->second) Type(ti);
|
||||
newtype->name_ = old_name;
|
||||
newtype->namespace_ = old_namespace;
|
||||
newtype->aliases_.swap(old_aliases);
|
||||
Type* newtype = new (i->second) Type(ti);
|
||||
newtype->_name = old_name;
|
||||
newtype->_namespace = old_namespace;
|
||||
newtype->_aliases.swap(old_aliases);
|
||||
|
||||
return newtype;
|
||||
}
|
||||
@@ -112,20 +112,20 @@ Type *Reflection::getOrRegisterType(const std::type_info &ti, bool replace_if_de
|
||||
return registerType(ti);
|
||||
}
|
||||
|
||||
void Reflection::registerConverter(const Type &source, const Type &dest, const Converter *cvt)
|
||||
void Reflection::registerConverter(const Type& source, const Type& dest, const Converter* cvt)
|
||||
{
|
||||
getOrCreateStaticData().convmap[&source][&dest] = cvt;
|
||||
}
|
||||
|
||||
const Converter *Reflection::getConverter(const Type &source, const Type &dest)
|
||||
const Converter* Reflection::getConverter(const Type& source, const Type& dest)
|
||||
{
|
||||
return getOrCreateStaticData().convmap[&source][&dest];
|
||||
}
|
||||
|
||||
bool Reflection::getConversionPath(const Type &source, const Type &dest, ConverterList &conv)
|
||||
bool Reflection::getConversionPath(const Type& source, const Type& dest, ConverterList& conv)
|
||||
{
|
||||
ConverterList temp;
|
||||
std::vector<const Type *> chain;
|
||||
std::vector<const Type* > chain;
|
||||
if (accum_conv_path(source, dest, temp, chain))
|
||||
{
|
||||
conv.swap(temp);
|
||||
@@ -134,7 +134,7 @@ bool Reflection::getConversionPath(const Type &source, const Type &dest, Convert
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Reflection::accum_conv_path(const Type &source, const Type &dest, ConverterList &conv, std::vector<const Type *> &chain)
|
||||
bool Reflection::accum_conv_path(const Type& source, const Type& dest, ConverterList& conv, std::vector<const Type* > &chain)
|
||||
{
|
||||
// break unwanted loops
|
||||
if (std::find(chain.begin(), chain.end(), &source) != chain.end())
|
||||
@@ -147,7 +147,7 @@ bool Reflection::accum_conv_path(const Type &source, const Type &dest, Converter
|
||||
if (i == getOrCreateStaticData().convmap.end())
|
||||
return false;
|
||||
|
||||
const StaticData::ConverterMap &cmap = i->second;
|
||||
const StaticData::ConverterMap& cmap = i->second;
|
||||
StaticData::ConverterMap::const_iterator j = cmap.find(&dest);
|
||||
if (j != cmap.end())
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ using namespace osgIntrospection;
|
||||
namespace
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
template<typename T>
|
||||
struct ObjectMatch
|
||||
{
|
||||
int list_pos;
|
||||
@@ -46,28 +46,28 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
typedef ObjectMatch<MethodInfo> MethodMatch;
|
||||
typedef ObjectMatch<ConstructorInfo> ConstructorMatch;
|
||||
typedef ObjectMatch<MethodInfo> MethodMatch;
|
||||
typedef ObjectMatch<ConstructorInfo> ConstructorMatch;
|
||||
|
||||
}
|
||||
|
||||
Type::~Type()
|
||||
{
|
||||
for (PropertyInfoList::const_iterator i=props_.begin(); i!=props_.end(); ++i)
|
||||
for (PropertyInfoList::const_iterator i=_props.begin(); i!=_props.end(); ++i)
|
||||
delete *i;
|
||||
for (MethodInfoList::const_iterator i=methods_.begin(); i!=methods_.end(); ++i)
|
||||
for (MethodInfoList::const_iterator i=_methods.begin(); i!=_methods.end(); ++i)
|
||||
delete *i;
|
||||
for (ConstructorInfoList::const_iterator i=_cons.begin(); i!=_cons.end(); ++i)
|
||||
delete *i;
|
||||
for (ConstructorInfoList::const_iterator i=cons_.begin(); i!=cons_.end(); ++i)
|
||||
delete *i;
|
||||
|
||||
delete rw_;
|
||||
delete cmp_;
|
||||
delete _rw;
|
||||
delete _cmp;
|
||||
}
|
||||
|
||||
bool Type::isSubclassOf(const Type &type) const
|
||||
bool Type::isSubclassOf(const Type& type) const
|
||||
{
|
||||
check_defined();
|
||||
for (TypeList::const_iterator i=base_.begin(); i!=base_.end(); ++i)
|
||||
for (TypeList::const_iterator i=_base.begin(); i!=_base.end(); ++i)
|
||||
{
|
||||
if (**i == type.getStdTypeInfo())
|
||||
return true;
|
||||
@@ -77,7 +77,7 @@ bool Type::isSubclassOf(const Type &type) const
|
||||
return false;
|
||||
}
|
||||
|
||||
const MethodInfo *Type::getCompatibleMethod(const std::string &name, const ValueList &values, bool inherit) const
|
||||
const MethodInfo *Type::getCompatibleMethod(const std::string& name, const ValueList& values, bool inherit) const
|
||||
{
|
||||
check_defined();
|
||||
|
||||
@@ -89,7 +89,7 @@ const MethodInfo *Type::getCompatibleMethod(const std::string &name, const Value
|
||||
methods = &allmethods;
|
||||
}
|
||||
else
|
||||
methods = &methods_;
|
||||
methods = &_methods;
|
||||
|
||||
typedef std::vector<MethodMatch> MatchList;
|
||||
MatchList matches;
|
||||
@@ -100,15 +100,15 @@ const MethodInfo *Type::getCompatibleMethod(const std::string &name, const Value
|
||||
const MethodInfo *mi = *j;
|
||||
if (mi->getName().compare(name) == 0)
|
||||
{
|
||||
float match;
|
||||
if (areArgumentsCompatible(values, mi->getParameters(), match))
|
||||
{
|
||||
MethodMatch mm;
|
||||
float match;
|
||||
if (areArgumentsCompatible(values, mi->getParameters(), match))
|
||||
{
|
||||
MethodMatch mm;
|
||||
mm.list_pos = pos;
|
||||
mm.match = match;
|
||||
mm.object = mi;
|
||||
matches.push_back(mm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,24 +121,24 @@ const MethodInfo *Type::getCompatibleMethod(const std::string &name, const Value
|
||||
return 0;
|
||||
}
|
||||
|
||||
const MethodInfo *Type::getMethod(const std::string &name, const ParameterInfoList ¶ms, bool inherit) const
|
||||
const MethodInfo *Type::getMethod(const std::string& name, const ParameterInfoList& params, bool inherit) const
|
||||
{
|
||||
check_defined();
|
||||
for (MethodInfoList::const_iterator j=methods_.begin(); j!=methods_.end(); ++j)
|
||||
for (MethodInfoList::const_iterator j=_methods.begin(); j!=_methods.end(); ++j)
|
||||
{
|
||||
const MethodInfo *mi = *j;
|
||||
if (mi->getName().compare(name) == 0)
|
||||
{
|
||||
if (areParametersCompatible(params, mi->getParameters()))
|
||||
{
|
||||
return mi;
|
||||
}
|
||||
if (areParametersCompatible(params, mi->getParameters()))
|
||||
{
|
||||
return mi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inherit)
|
||||
{
|
||||
for (TypeList::const_iterator i=base_.begin(); i!=base_.end(); ++i)
|
||||
for (TypeList::const_iterator i=_base.begin(); i!=_base.end(); ++i)
|
||||
{
|
||||
const MethodInfo *mi = (*i)->getMethod(name, params, true);
|
||||
if (mi) return mi;
|
||||
@@ -148,30 +148,30 @@ const MethodInfo *Type::getMethod(const std::string &name, const ParameterInfoLi
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Type::getInheritedProviders(CustomAttributeProviderList &providers) const
|
||||
void Type::getInheritedProviders(CustomAttributeProviderList& providers) const
|
||||
{
|
||||
check_defined();
|
||||
providers.assign(base_.begin(), base_.end());
|
||||
providers.assign(_base.begin(), _base.end());
|
||||
}
|
||||
|
||||
const PropertyInfo *Type::getProperty(const std::string &name, const Type &ptype, const ParameterInfoList &indices, bool inherit) const
|
||||
const PropertyInfo *Type::getProperty(const std::string& name, const Type& ptype, const ParameterInfoList& indices, bool inherit) const
|
||||
{
|
||||
check_defined();
|
||||
for (PropertyInfoList::const_iterator i=props_.begin(); i!=props_.end(); ++i)
|
||||
for (PropertyInfoList::const_iterator i=_props.begin(); i!=_props.end(); ++i)
|
||||
{
|
||||
const PropertyInfo *pi = *i;
|
||||
if (pi->getName() == name && pi->getPropertyType() == ptype)
|
||||
{
|
||||
if (areParametersCompatible(indices, pi->getIndexParameters()))
|
||||
{
|
||||
return pi;
|
||||
}
|
||||
if (areParametersCompatible(indices, pi->getIndexParameters()))
|
||||
{
|
||||
return pi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inherit)
|
||||
{
|
||||
for (TypeList::const_iterator i=base_.begin(); i!=base_.end(); ++i)
|
||||
for (TypeList::const_iterator i=_base.begin(); i!=_base.end(); ++i)
|
||||
{
|
||||
const PropertyInfo *pi = (*i)->getProperty(name, ptype, indices, true);
|
||||
if (pi) return pi;
|
||||
@@ -181,55 +181,55 @@ const PropertyInfo *Type::getProperty(const std::string &name, const Type &ptype
|
||||
return 0;
|
||||
}
|
||||
|
||||
Value Type::invokeMethod(const std::string &name, const Value &instance, ValueList &args, bool inherit) const
|
||||
Value Type::invokeMethod(const std::string& name, const Value& instance, ValueList& args, bool inherit) const
|
||||
{
|
||||
check_defined();
|
||||
const MethodInfo *mi = getCompatibleMethod(name, args, inherit);
|
||||
if (!mi) throw MethodNotFoundException(name, name_);
|
||||
if (!mi) throw MethodNotFoundException(name, _name);
|
||||
return mi->invoke(instance, args);
|
||||
}
|
||||
|
||||
Value Type::invokeMethod(const std::string &name, Value &instance, ValueList &args, bool inherit) const
|
||||
Value Type::invokeMethod(const std::string& name, Value& instance, ValueList& args, bool inherit) const
|
||||
{
|
||||
check_defined();
|
||||
const MethodInfo *mi = getCompatibleMethod(name, args, inherit);
|
||||
if (!mi) throw MethodNotFoundException(name, name_);
|
||||
if (!mi) throw MethodNotFoundException(name, _name);
|
||||
return mi->invoke(instance, args);
|
||||
}
|
||||
|
||||
void Type::getAllProperties(PropertyInfoList &props) const
|
||||
void Type::getAllProperties(PropertyInfoList& props) const
|
||||
{
|
||||
check_defined();
|
||||
std::copy(props_.begin(), props_.end(), std::back_inserter(props));
|
||||
for (TypeList::const_iterator i=base_.begin(); i!=base_.end(); ++i)
|
||||
std::copy(_props.begin(), _props.end(), std::back_inserter(props));
|
||||
for (TypeList::const_iterator i=_base.begin(); i!=_base.end(); ++i)
|
||||
{
|
||||
(*i)->getAllProperties(props);
|
||||
}
|
||||
}
|
||||
|
||||
void Type::getAllMethods(MethodInfoList &methods) const
|
||||
void Type::getAllMethods(MethodInfoList& methods) const
|
||||
{
|
||||
check_defined();
|
||||
std::copy(methods_.begin(), methods_.end(), std::back_inserter(methods));
|
||||
for (TypeList::const_iterator i=base_.begin(); i!=base_.end(); ++i)
|
||||
std::copy(_methods.begin(), _methods.end(), std::back_inserter(methods));
|
||||
for (TypeList::const_iterator i=_base.begin(); i!=_base.end(); ++i)
|
||||
{
|
||||
(*i)->getAllMethods(methods);
|
||||
}
|
||||
}
|
||||
|
||||
Value Type::createInstance(ValueList &args) const
|
||||
Value Type::createInstance(ValueList& args) const
|
||||
{
|
||||
if (isAbstract())
|
||||
throw TypeIsAbstractException(ti_);
|
||||
if (isAbstract())
|
||||
throw TypeIsAbstractException(_ti);
|
||||
|
||||
const ConstructorInfo *ci = getCompatibleConstructor(args);
|
||||
if (!ci)
|
||||
throw ConstructorNotFoundException(ti_);
|
||||
const ConstructorInfo *ci = getCompatibleConstructor(args);
|
||||
if (!ci)
|
||||
throw ConstructorNotFoundException(_ti);
|
||||
|
||||
return ci->createInstance(args);
|
||||
return ci->createInstance(args);
|
||||
}
|
||||
|
||||
const ConstructorInfo *Type::getCompatibleConstructor(const ValueList &values) const
|
||||
const ConstructorInfo *Type::getCompatibleConstructor(const ValueList& values) const
|
||||
{
|
||||
check_defined();
|
||||
|
||||
@@ -237,17 +237,17 @@ const ConstructorInfo *Type::getCompatibleConstructor(const ValueList &values) c
|
||||
MatchList matches;
|
||||
|
||||
int pos = 0;
|
||||
for (ConstructorInfoList::const_iterator j=cons_.begin(); j!=cons_.end(); ++j, ++pos)
|
||||
for (ConstructorInfoList::const_iterator j=_cons.begin(); j!=_cons.end(); ++j, ++pos)
|
||||
{
|
||||
float match;
|
||||
if (areArgumentsCompatible(values, (*j)->getParameters(), match))
|
||||
{
|
||||
ConstructorMatch mm;
|
||||
float match;
|
||||
if (areArgumentsCompatible(values, (*j)->getParameters(), match))
|
||||
{
|
||||
ConstructorMatch mm;
|
||||
mm.list_pos = pos;
|
||||
mm.match = match;
|
||||
mm.object = *j;
|
||||
matches.push_back(mm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!matches.empty())
|
||||
@@ -259,14 +259,14 @@ const ConstructorInfo *Type::getCompatibleConstructor(const ValueList &values) c
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ConstructorInfo *Type::getConstructor(const ParameterInfoList ¶ms) const
|
||||
const ConstructorInfo *Type::getConstructor(const ParameterInfoList& params) const
|
||||
{
|
||||
check_defined();
|
||||
|
||||
for (ConstructorInfoList::const_iterator j=cons_.begin(); j!=cons_.end(); ++j)
|
||||
for (ConstructorInfoList::const_iterator j=_cons.begin(); j!=_cons.end(); ++j)
|
||||
{
|
||||
if (areParametersCompatible(params, (*j)->getParameters()))
|
||||
return *j;
|
||||
if (areParametersCompatible(params, (*j)->getParameters()))
|
||||
return *j;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
bool osgIntrospection::areParametersCompatible(const ParameterInfoList &pl1, const ParameterInfoList &pl2)
|
||||
bool osgIntrospection::areParametersCompatible(const ParameterInfoList& pl1, const ParameterInfoList& pl2)
|
||||
{
|
||||
if (pl1.size() == pl2.size())
|
||||
{
|
||||
@@ -37,20 +37,20 @@ bool osgIntrospection::areParametersCompatible(const ParameterInfoList &pl1, con
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool osgIntrospection::areArgumentsCompatible(const ValueList &vl, const ParameterInfoList &pl, float &match)
|
||||
bool osgIntrospection::areArgumentsCompatible(const ValueList& vl, const ParameterInfoList& pl, float &match)
|
||||
{
|
||||
if (pl.empty())
|
||||
{
|
||||
if (vl.empty())
|
||||
{
|
||||
match = 1.0f;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (pl.empty())
|
||||
{
|
||||
if (vl.empty())
|
||||
{
|
||||
match = 1.0f;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ParameterInfoList::const_iterator i1 = pl.begin();
|
||||
ValueList::const_iterator i2 = vl.begin();
|
||||
@@ -59,27 +59,27 @@ bool osgIntrospection::areArgumentsCompatible(const ValueList &vl, const Paramet
|
||||
|
||||
for (; i1<pl.end(); ++i1)
|
||||
{
|
||||
if (i2 == vl.end())
|
||||
{
|
||||
if ((*i1)->getDefaultValue().isEmpty())
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
if (i2 == vl.end())
|
||||
{
|
||||
if ((*i1)->getDefaultValue().isEmpty())
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((*i1)->getParameterType() != i2->getType())
|
||||
{
|
||||
if (i2->tryConvertTo((*i1)->getParameterType()).isEmpty())
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
++exact_args;
|
||||
|
||||
++i2;
|
||||
++i2;
|
||||
}
|
||||
|
||||
match = static_cast<float>(exact_args) / pl.size();
|
||||
return true;
|
||||
match = static_cast<float>(exact_args) / pl.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,27 +25,27 @@
|
||||
|
||||
using namespace osgIntrospection;
|
||||
|
||||
Value Value::convertTo(const Type &outtype) const
|
||||
Value Value::convertTo(const Type& outtype) const
|
||||
{
|
||||
Value v = tryConvertTo(outtype);
|
||||
if (v.isEmpty())
|
||||
throw TypeConversionException(type_->getStdTypeInfo(), outtype.getStdTypeInfo());
|
||||
throw TypeConversionException(_type->getStdTypeInfo(), outtype.getStdTypeInfo());
|
||||
return v;
|
||||
}
|
||||
|
||||
Value Value::tryConvertTo(const Type &outtype) const
|
||||
Value Value::tryConvertTo(const Type& outtype) const
|
||||
{
|
||||
check_empty();
|
||||
|
||||
if (type_ == &outtype)
|
||||
if (_type == &outtype)
|
||||
return *this;
|
||||
|
||||
if (type_->isConstPointer() && outtype.isNonConstPointer())
|
||||
if (_type->isConstPointer() && outtype.isNonConstPointer())
|
||||
return Value();
|
||||
|
||||
// search custom converters
|
||||
ConverterList conv;
|
||||
if (Reflection::getConversionPath(*type_, outtype, conv))
|
||||
if (Reflection::getConversionPath(*_type, outtype, conv))
|
||||
{
|
||||
std::auto_ptr<CompositeConverter> cvt(new CompositeConverter(conv));
|
||||
return cvt->convert(*this);
|
||||
@@ -53,16 +53,16 @@ Value Value::tryConvertTo(const Type &outtype) const
|
||||
|
||||
std::auto_ptr<ReaderWriter::Options> wopt;
|
||||
|
||||
if (type_->isEnum() && (outtype.getQualifiedName() == "int" || outtype.getQualifiedName() == "unsigned int"))
|
||||
if (_type->isEnum() && (outtype.getQualifiedName() == "int" || outtype.getQualifiedName() == "unsigned int"))
|
||||
{
|
||||
wopt.reset(new ReaderWriter::Options);
|
||||
wopt->setForceNumericOutput(true);
|
||||
}
|
||||
|
||||
const ReaderWriter *src_rw = type_->getReaderWriter();
|
||||
const ReaderWriter* src_rw = _type->getReaderWriter();
|
||||
if (src_rw)
|
||||
{
|
||||
const ReaderWriter *dst_rw = outtype.getReaderWriter();
|
||||
const ReaderWriter* dst_rw = outtype.getReaderWriter();
|
||||
if (dst_rw)
|
||||
{
|
||||
std::stringstream ss;
|
||||
@@ -84,7 +84,7 @@ std::string Value::toString() const
|
||||
{
|
||||
check_empty();
|
||||
|
||||
const ReaderWriter *rw = type_->getReaderWriter();
|
||||
const ReaderWriter* rw = _type->getReaderWriter();
|
||||
if (rw)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -92,23 +92,23 @@ std::string Value::toString() const
|
||||
throw StreamWriteErrorException();
|
||||
return oss.str();
|
||||
}
|
||||
throw StreamingNotSupportedException(StreamingNotSupportedException::ANY, type_->getStdTypeInfo());
|
||||
throw StreamingNotSupportedException(StreamingNotSupportedException::ANY, _type->getStdTypeInfo());
|
||||
}
|
||||
|
||||
void Value::check_empty() const
|
||||
{
|
||||
if (!type_ || !inbox_)
|
||||
if (!_type || !_inbox)
|
||||
throw EmptyValueException();
|
||||
}
|
||||
|
||||
void Value::swap(Value &v)
|
||||
void Value::swap(Value& v)
|
||||
{
|
||||
std::swap(inbox_, v.inbox_);
|
||||
std::swap(type_, v.type_);
|
||||
std::swap(ptype_, v.ptype_);
|
||||
std::swap(_inbox, v._inbox);
|
||||
std::swap(_type, v._type);
|
||||
std::swap(_ptype, v._ptype);
|
||||
}
|
||||
|
||||
bool Value::operator ==(const Value &other) const
|
||||
bool Value::operator ==(const Value& other) const
|
||||
{
|
||||
if (isEmpty() && other.isEmpty())
|
||||
return true;
|
||||
@@ -116,94 +116,94 @@ bool Value::operator ==(const Value &other) const
|
||||
if (isEmpty() ^ other.isEmpty())
|
||||
return false;
|
||||
|
||||
const Comparator *cmp1 = type_->getComparator();
|
||||
const Comparator *cmp2 = other.type_->getComparator();
|
||||
const Comparator* cmp1 = _type->getComparator();
|
||||
const Comparator* cmp2 = other._type->getComparator();
|
||||
|
||||
const Comparator *cmp = cmp1? cmp1: cmp2;
|
||||
const Comparator* cmp = cmp1? cmp1: cmp2;
|
||||
|
||||
if (!cmp)
|
||||
throw ComparisonNotPermittedException(type_->getStdTypeInfo());
|
||||
throw ComparisonNotPermittedException(_type->getStdTypeInfo());
|
||||
|
||||
if (cmp1 == cmp2)
|
||||
return cmp->isEqualTo(*this, other);
|
||||
|
||||
if (cmp1)
|
||||
return cmp1->isEqualTo(*this, other.convertTo(*type_));
|
||||
return cmp1->isEqualTo(*this, other.convertTo(*_type));
|
||||
|
||||
return cmp2->isEqualTo(convertTo(*other.type_), other);
|
||||
return cmp2->isEqualTo(convertTo(*other._type), other);
|
||||
}
|
||||
|
||||
bool Value::operator <=(const Value &other) const
|
||||
bool Value::operator <=(const Value& other) const
|
||||
{
|
||||
const Comparator *cmp1 = type_->getComparator();
|
||||
const Comparator *cmp2 = other.type_->getComparator();
|
||||
const Comparator* cmp1 = _type->getComparator();
|
||||
const Comparator* cmp2 = other._type->getComparator();
|
||||
|
||||
const Comparator *cmp = cmp1? cmp1: cmp2;
|
||||
const Comparator* cmp = cmp1? cmp1: cmp2;
|
||||
|
||||
if (!cmp)
|
||||
throw ComparisonNotPermittedException(type_->getStdTypeInfo());
|
||||
throw ComparisonNotPermittedException(_type->getStdTypeInfo());
|
||||
|
||||
if (cmp1 == cmp2)
|
||||
return cmp->isLessThanOrEqualTo(*this, other);
|
||||
|
||||
if (cmp1)
|
||||
return cmp1->isLessThanOrEqualTo(*this, other.convertTo(*type_));
|
||||
return cmp1->isLessThanOrEqualTo(*this, other.convertTo(*_type));
|
||||
|
||||
return cmp2->isLessThanOrEqualTo(convertTo(*other.type_), other);
|
||||
return cmp2->isLessThanOrEqualTo(convertTo(*other._type), other);
|
||||
}
|
||||
|
||||
bool Value::operator !=(const Value &other) const
|
||||
bool Value::operator !=(const Value& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool Value::operator >(const Value &other) const
|
||||
bool Value::operator >(const Value& other) const
|
||||
{
|
||||
return !operator<=(other);
|
||||
}
|
||||
|
||||
bool Value::operator <(const Value &other) const
|
||||
bool Value::operator <(const Value& other) const
|
||||
{
|
||||
const Comparator *cmp1 = type_->getComparator();
|
||||
const Comparator *cmp2 = other.type_->getComparator();
|
||||
const Comparator* cmp1 = _type->getComparator();
|
||||
const Comparator* cmp2 = other._type->getComparator();
|
||||
|
||||
const Comparator *cmp = cmp1? cmp1: cmp2;
|
||||
const Comparator* cmp = cmp1? cmp1: cmp2;
|
||||
|
||||
if (!cmp)
|
||||
throw ComparisonNotPermittedException(type_->getStdTypeInfo());
|
||||
throw ComparisonNotPermittedException(_type->getStdTypeInfo());
|
||||
|
||||
if (cmp1 == cmp2)
|
||||
return cmp->isLessThanOrEqualTo(*this, other) && !cmp->isEqualTo(*this, other);
|
||||
|
||||
if (cmp1)
|
||||
{
|
||||
Value temp(other.convertTo(*type_));
|
||||
Value temp(other.convertTo(*_type));
|
||||
return cmp1->isLessThanOrEqualTo(*this, temp) && !cmp1->isEqualTo(*this, temp);
|
||||
}
|
||||
|
||||
Value temp(convertTo(*other.type_));
|
||||
Value temp(convertTo(*other._type));
|
||||
return cmp2->isLessThanOrEqualTo(temp, other) && !cmp2->isEqualTo(temp, other);
|
||||
}
|
||||
|
||||
bool Value::operator >=(const Value &other) const
|
||||
bool Value::operator >=(const Value& other) const
|
||||
{
|
||||
const Comparator *cmp1 = type_->getComparator();
|
||||
const Comparator *cmp2 = other.type_->getComparator();
|
||||
const Comparator* cmp1 = _type->getComparator();
|
||||
const Comparator* cmp2 = other._type->getComparator();
|
||||
|
||||
const Comparator *cmp = cmp1? cmp1: cmp2;
|
||||
const Comparator* cmp = cmp1? cmp1: cmp2;
|
||||
|
||||
if (!cmp)
|
||||
throw ComparisonNotPermittedException(type_->getStdTypeInfo());
|
||||
throw ComparisonNotPermittedException(_type->getStdTypeInfo());
|
||||
|
||||
if (cmp1 == cmp2)
|
||||
return !cmp->isLessThanOrEqualTo(*this, other) || cmp->isEqualTo(*this, other);
|
||||
|
||||
if (cmp1)
|
||||
{
|
||||
Value temp(other.convertTo(*type_));
|
||||
Value temp(other.convertTo(*_type));
|
||||
return !cmp1->isLessThanOrEqualTo(*this, temp) || cmp1->isEqualTo(*this, temp);
|
||||
}
|
||||
|
||||
Value temp(convertTo(*other.type_));
|
||||
Value temp(convertTo(*other._type));
|
||||
return !cmp2->isLessThanOrEqualTo(temp, other) || cmp2->isEqualTo(temp, other);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user