template <typename T>
struct PropertyNameFinder
{
- PropertyNameFinder( const std::string& find )
- : mFind( find )
+ PropertyNameFinder(ConstString find)
+ : mFind(find)
{
}
}
private:
-
- const std::string& mFind;
+ ConstString mFind;
};
/**
}
}
-const std::string& TypeInfo::GetRegisteredPropertyName( Property::Index index ) const
+std::string_view TypeInfo::GetRegisteredPropertyName(Property::Index index) const
{
RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
if ( iter != mRegisteredProperties.end() )
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
{
return empty;
}
-std::string TypeInfo::GetPropertyName( Property::Index index ) const
+std::string_view TypeInfo::GetPropertyName(Property::Index index) const
{
- std::string propertyName;
+ std::string_view propertyName;
// default or custom
if ( mDefaultProperties && ( index < DEFAULT_PROPERTY_MAX_COUNT ) )
{
PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
if ( iter != mRegisteredProperties.end() )
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
}
// if not our property, go to parent
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, std::move(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, std::move(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, std::move(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(defaultValue.GetType(), std::move(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(defaultValue.GetType(), ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
mPropertyDefaultValues.push_back(PropertyDefaultValuePair(index, std::move(defaultValue)));
}
else
if ( iter == mRegisteredProperties.end() )
{
- mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, std::move(name), baseIndex, componentIndex)));
+ mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), baseIndex, componentIndex)));
success = true;
}
}
if ( iter == mRegisteredChildProperties.end() )
{
- mRegisteredChildProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, std::move(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
+ mRegisteredChildProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
return count;
}
-Property::Index TypeInfo::GetPropertyIndex( const std::string& name ) const
+Property::Index TypeInfo::GetPropertyIndex(ConstString name) const
{
Property::Index index = Property::INVALID_INDEX;
bool found = false;
// check default properties
if( mDefaultProperties )
{
+ auto stringView = name.GetStringView();
for( Property::Index tableIndex = 0; tableIndex < mDefaultPropertyCount; ++tableIndex )
{
- if(mDefaultProperties[tableIndex].name == name)
+ if(mDefaultProperties[tableIndex].name == stringView)
{
index = mDefaultProperties[ tableIndex ].enumIndex;
found = true;
return componentIndex;
}
-Property::Index TypeInfo::GetChildPropertyIndex( const std::string& name ) const
+Property::Index TypeInfo::GetChildPropertyIndex(ConstString name) const
{
Property::Index index = Property::INVALID_INDEX;
return index;
}
-const std::string& TypeInfo::GetChildPropertyName( Property::Index index ) const
+std::string_view TypeInfo::GetChildPropertyName(Property::Index index) const
{
RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
if ( iter != mRegisteredChildProperties.end() )
{
- return iter->second.name;
+ return iter->second.name.GetStringView();
}
if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
DALI_LOG_ERROR( "Property index %d not found\n", index );
- static std::string empty;
- return empty;
+ return {};
}
Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const
if( mCSharpType )
{
// CSharp wants a property name not an index
- const std::string& name = (iter->second).name;
+ auto name = (iter->second).name;
- iter->second.cSharpSetFunc( object,name.c_str(), const_cast< Property::Value* >(&value) );
+ iter->second.cSharpSetFunc(object, name.GetCString(), const_cast<Property::Value*>(&value));
}
else
{
void TypeInfo::SetProperty(BaseObject* object, const std::string& name, Property::Value value) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(ConstString(name)));
if ( iter != mRegisteredProperties.end() )
{
DALI_ASSERT_ALWAYS( iter->second.setFunc && "Trying to write to a read-only property" );
// CSharp wants a property name not an index
// CSharp callback can't return an object by value, it can only return a pointer
// CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
- const std::string& name = (iter->second).name;
-
- return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), name.c_str()) );
+ auto name = (iter->second).name;
+ return *(iter->second.cSharpGetFunc(const_cast<BaseObject*>(object), name.GetCString()));
}
else
{
Property::Value TypeInfo::GetProperty( const BaseObject *object, const std::string& name ) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
-
-
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(ConstString(name)));
if( iter != mRegisteredProperties.end() )
{