void DALI_TEST_EQUALS(const char* str1, const std::string& str2, const char* location);
/**
+ * Test whether two strings are equal.
+ * @param[in] str1 The first string
+ * @param[in] str2 The second string
+ * @param[in] location The TEST_LOCATION macro should be used here
+ */
+template<>
+inline void DALI_TEST_EQUALS<const std::string_view>(std::string_view str1, std::string_view str2, const char* location)
+{
+ DALI_TEST_EQUALS(str1.data(), str2.data(), location);
+}
+
+inline void DALI_TEST_EQUALS(std::string_view str1, const char* str2, const char* location)
+{
+ DALI_TEST_EQUALS(str1.data(), str2, location);
+}
+
+inline void DALI_TEST_EQUALS(std::string_view str1, const std::string& str2, const char* location)
+{
+ DALI_TEST_EQUALS(str1.data(), str2.c_str(), location);
+}
+
+inline void DALI_TEST_EQUALS(const std::string& str2, std::string_view str1, const char* location)
+{
+ DALI_TEST_EQUALS(str2.c_str(), str1.data(), location);
+}
+
+inline void DALI_TEST_EQUALS(const char* str1, std::string_view str2, const char* location)
+{
+ DALI_TEST_EQUALS(str1, str2.data(), location);
+}
+
+/**
* Test if a property value type is equal to a trivial type.
*/
template<typename Type>
#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/internal/event/common/type-info-impl.h>
+#include <dali/internal/common/const-string.h>
#include <dali/public-api/dali-core.h>
#include <stdlib.h>
// check the child property type
Internal::TypeInfo& typeInfoImpl = GetImplementation(typeInfo);
- Property::Type type = typeInfoImpl.GetChildPropertyType(typeInfoImpl.GetChildPropertyIndex("childProp4"));
+ Property::Type type = typeInfoImpl.GetChildPropertyType(typeInfoImpl.GetChildPropertyIndex(Dali::Internal::ConstString("childProp4")));
DALI_TEST_EQUALS(type, Property::INTEGER, TEST_LOCATION);
std::string unRegisteredChildName(typeInfoImpl.GetChildPropertyName(CHILD_PROPERTY_REGISTRATION_START_INDEX + 4));
return count;
}
-std::string Object::GetPropertyName( Property::Index index ) const
+std::string_view Object::GetPropertyName(Property::Index index) const
{
DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index out of bounds" );
CustomPropertyMetadata* custom = FindCustomProperty( index );
if( custom )
{
- return custom->name;
+ return custom->name.GetStringView();
}
}
DALI_LOG_ERROR( "Property index %d not found\n", index );
- return std::string();
+ return {};
}
-Property::Index Object::GetPropertyIndex( Property::Key key ) const
+Property::Index Object::GetPropertyIndex(KeyRef key) const
{
Property::Index index = Property::INVALID_INDEX;
- if( key.type == Property::Key::STRING )
+ if(key.mType == Property::Key::STRING)
{
const TypeInfo* typeInfo( GetTypeInfo() );
if ( typeInfo )
{
- index = typeInfo->GetPropertyIndex( key.stringKey );
+ index = typeInfo->GetPropertyIndex(key.mString);
}
}
{
CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>(*iter);
- if( ( key.type == Property::Key::STRING && custom->name == key.stringKey) ||
- ( key.type == Property::Key::INDEX && custom->key == key.indexKey ) )
+ if((key.mType == Property::Key::STRING && custom->name == key.mString) ||
+ (key.mType == Property::Key::INDEX && custom->key == key.mIndex))
{
if ( custom->childPropertyIndex != Property::INVALID_INDEX )
{
if( !custom )
{
// If the child property is not registered yet, register it.
- custom = new CustomPropertyMetadata( "", propertyValue, Property::READ_WRITE );
+ custom = new CustomPropertyMetadata({}, propertyValue, Property::READ_WRITE);
mCustomProperties.PushBack( custom );
}
const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
if( parentTypeInfo )
{
- custom->name = parentTypeInfo->GetChildPropertyName( index );
+ custom->name = ConstString(parentTypeInfo->GetChildPropertyName(index));
}
}
}
}
}
-Property::Index Object::RegisterProperty(std::string name, Property::Value propertyValue)
+Property::Index Object::RegisterProperty(std::string_view name, Property::Value propertyValue)
{
- return RegisterProperty(std::move(name), Property::INVALID_KEY, std::move(propertyValue), Property::ANIMATABLE);
+ return RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), Property::ANIMATABLE);
}
-Property::Index Object::RegisterProperty(std::string name, Property::Index key, Property::Value propertyValue)
+Property::Index Object::RegisterProperty(std::string_view name, Property::Index key, Property::Value propertyValue)
{
- return RegisterProperty(std::move(name), key, std::move(propertyValue), Property::ANIMATABLE);
+ return RegisterProperty(name, key, std::move(propertyValue), Property::ANIMATABLE);
}
void Object::SetProperties( const Property::Map& properties )
}
}
-Property::Index Object::RegisterProperty(std::string name,
+Property::Index Object::RegisterProperty(std::string_view name,
Property::Value propertyValue,
Property::AccessMode accessMode)
{
- return RegisterProperty(std::move(name), Property::INVALID_KEY, std::move(propertyValue), accessMode);
+ return RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), accessMode);
}
-Property::Index Object::RegisterProperty(std::string name,
+Property::Index Object::RegisterProperty(std::string_view name,
Property::Index key,
Property::Value propertyValue,
Property::AccessMode accessMode)
{
+ auto constString = ConstString(name);
// If property with the required key already exists, then just set it.
Property::Index index = Property::INVALID_INDEX;
if( key != Property::INVALID_KEY ) // Try integer key first if it's valid
}
if( index == Property::INVALID_INDEX ) // If it wasn't valid, or doesn't exist, try name
{
- index = GetPropertyIndex( name );
+ index = GetPropertyIndex(constString);
}
if( index != Property::INVALID_INDEX ) // If there was a valid index found by either key, set it.
if( Property::ANIMATABLE == accessMode )
{
index = RegisterSceneGraphProperty(
- name,
+ constString,
key,
PROPERTY_CUSTOM_START_INDEX + static_cast<Property::Index>(mCustomProperties.Count()),
std::move(propertyValue));
- AddUniformMapping(index, std::move(name));
+ AddUniformMapping(index, constString);
}
else
{
index = PROPERTY_CUSTOM_START_INDEX + static_cast<Property::Index>( mCustomProperties.Count() );
CustomPropertyMetadata* customProperty =
- new CustomPropertyMetadata(std::move(name), std::move(propertyValue), accessMode);
+ new CustomPropertyMetadata(constString, std::move(propertyValue), accessMode);
// Resolve index for the child property
Object* parent = GetParentObject();
const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
if( parentTypeInfo )
{
- Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( customProperty->name );
+ Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex(customProperty->name);
if( childPropertyIndex != Property::INVALID_INDEX )
{
customProperty->childPropertyIndex = childPropertyIndex;
}
}
-void Object::AddUniformMapping(Property::Index propertyIndex, std::string uniformName) const
+void Object::AddUniformMapping(Property::Index propertyIndex, ConstString uniformName) const
{
// Get the address of the property if it's a scene property
const PropertyInputImpl* propertyPtr = GetSceneObjectInputProperty( propertyIndex );
{
const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
- SceneGraph::UniformPropertyMapping map(ConstString(uniformName), propertyPtr);
+ SceneGraph::UniformPropertyMapping map(uniformName, propertyPtr);
// Message takes ownership of Uniform map (and will delete it after copy)
AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, map );
}
return nullptr;
}
-Property::Index Object::RegisterSceneGraphProperty( std::string name, Property::Index key, Property::Index index, Property::Value propertyValue ) const
+Property::Index Object::RegisterSceneGraphProperty(ConstString name, Property::Index key, Property::Index index, Property::Value propertyValue) const
{
// Create a new property
Dali::Internal::OwnerPointer<PropertyBase> newProperty;
{
DALI_ASSERT_ALWAYS( index <= PROPERTY_CUSTOM_MAX_INDEX && "Too many custom properties have been registered" );
- mCustomProperties.PushBack( new CustomPropertyMetadata( std::move(name), key, std::move(propertyValue), property ) );
+ mCustomProperties.PushBack(new CustomPropertyMetadata(name, key, std::move(propertyValue), property));
}
else
{
const Property::Value* value ) const
{
// If the property is not a component of a base property, register the whole property itself.
- const std::string& propertyName = typeInfo.GetPropertyName( index );
+ auto propertyName = ConstString(typeInfo.GetPropertyName(index));
Property::Value initialValue;
if( value )
{
{
CustomPropertyMetadata* customProperty = static_cast<CustomPropertyMetadata*>( entry );
- if( customProperty->name.empty() )
+ if(customProperty->name.IsEmpty())
{
if( customProperty->childPropertyIndex != Property::INVALID_INDEX )
{
// Resolve name for any child property with no name
- customProperty->name = parentTypeInfo->GetChildPropertyName( customProperty->childPropertyIndex );
+ customProperty->name = ConstString(parentTypeInfo->GetChildPropertyName(customProperty->childPropertyIndex));
}
}
else
{
- Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( customProperty->name );
+ Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex(customProperty->name);
if( childPropertyIndex != Property::INVALID_INDEX )
{
// Resolve index for any property with a name that matches the parent's child property name
#include <cstdint> // uint32_t
// INTERNAL INCLUDES
+#include <dali/devel-api/common/owner-container.h>
+#include <dali/devel-api/object/handle-devel.h>
+#include <dali/internal/common/const-string.h>
+#include <dali/internal/event/animation/animation-impl.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/common/property-input-impl.h>
+#include <dali/internal/event/common/property-metadata.h>
+#include <dali/internal/update/common/property-base.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/handle.h>
-#include <dali/public-api/object/property.h>
#include <dali/public-api/object/property-index-ranges.h>
#include <dali/public-api/object/property-input.h>
#include <dali/public-api/object/property-map.h>
#include <dali/public-api/object/property-notification.h>
-#include <dali/devel-api/common/owner-container.h>
-#include <dali/devel-api/object/handle-devel.h>
-#include <dali/internal/event/animation/animation-impl.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/event/common/property-input-impl.h>
-#include <dali/internal/event/common/property-metadata.h>
-#include <dali/internal/update/common/property-base.h>
+#include <dali/public-api/object/property.h>
namespace Dali
{
using ConstraintIter = ConstraintContainer::iterator;
using ConstraintConstIter = ConstraintContainer::const_iterator;
+class KeyRef
+{
+public:
+ KeyRef(const Property::Key& key)
+ : mType(key.type)
+ {
+ if(mType == Property::Key::STRING)
+ {
+ mString = ConstString(key.stringKey);
+ }
+ else
+ {
+ mIndex = key.indexKey;
+ }
+ }
+ KeyRef(ConstString str)
+ : mType(Property::Key::STRING)
+ {
+ mString = str;
+ }
+ KeyRef(Property::Index index)
+ : mType(Property::Key::INDEX)
+ {
+ mIndex = index;
+ }
+ Property::Key::Type mType;
+ Property::Index mIndex{Property::INVALID_INDEX};
+ ConstString mString;
+};
+
/**
* A base class for objects which optionally provide properties.
* The concrete derived class is responsible for implementing the property system methods.
/**
* @copydoc Dali::Handle::GetPropertyName()
*/
- std::string GetPropertyName( Property::Index index ) const;
+ std::string_view GetPropertyName(Property::Index index) const;
/**
* @copydoc Dali::Handle::GetPropertyIndex()
*/
- Property::Index GetPropertyIndex( Property::Key key ) const;
+ Property::Index GetPropertyIndex(KeyRef key) const;
/**
* @copydoc Dali::Handle::IsPropertyWritable()
/**
* @copydoc Dali::Handle::RegisterProperty()
*/
- Property::Index RegisterProperty(std::string name, Property::Value propertyValue);
+ Property::Index RegisterProperty(std::string_view name, Property::Value propertyValue);
/**
* @copydoc Dali::Handle::RegisterProperty()
*/
- Property::Index RegisterProperty(std::string name, Property::Index key, Property::Value propertyValue);
+ Property::Index RegisterProperty(std::string_view name, Property::Index key, Property::Value propertyValue);
/**
* @copydoc Dali::DevelHandle::SetProperties()
/**
* @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
*/
- Property::Index RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode);
+ Property::Index RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode);
/**
* @brief Implementing method for this override
*/
- Property::Index RegisterProperty(std::string name,
+ Property::Index RegisterProperty(std::string_view name,
Property::Index key,
Property::Value propertyValue,
Property::AccessMode accessMode);
* @param propertyIndex index of the property
* @param uniformName name of the uniform (same as property name)
*/
- void AddUniformMapping(Property::Index propertyIndex, std::string uniformName) const;
+ void AddUniformMapping(Property::Index propertyIndex, ConstString uniformName) const;
/**
* Removes uniform mapping for given property
* @param [in] value The value of the property.
* @return The index of the registered property or Property::INVALID_INDEX if registration failed.
*/
- Property::Index RegisterSceneGraphProperty( std::string name, Property::Index key, Property::Index index, Property::Value propertyValue ) const;
+ Property::Index RegisterSceneGraphProperty(ConstString name, Property::Index key, Property::Index index, Property::Value propertyValue) const;
/**
* Registers animatable scene property
#include <utility>
// INTERNAL INCLUDES
+#include <dali/internal/common/const-string.h>
#include <dali/public-api/common/constants.h>
-#include <dali/public-api/object/property.h>
#include <dali/public-api/object/property-value.h>
+#include <dali/public-api/object/property.h>
namespace Dali
{
*
* @note A valid sceneGraphProperty is mandatory otherwise this will debug assert.
*/
- CustomPropertyMetadata( std::string propertyName,
- Property::Index propertyKey,
- Property::Value propertyValue,
- const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( std::move(propertyValue), sceneGraphProperty, true ),
- name( std::move(propertyName) ),
- key( propertyKey ),
- childPropertyIndex( Property::INVALID_INDEX )
+ CustomPropertyMetadata(ConstString propertyName,
+ Property::Index propertyKey,
+ Property::Value propertyValue,
+ const SceneGraph::PropertyBase* sceneGraphProperty)
+ : PropertyMetadata(std::move(propertyValue), sceneGraphProperty, true),
+ name(propertyName),
+ key(propertyKey),
+ childPropertyIndex(Property::INVALID_INDEX)
{
DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
}
*
* @note The access mode MUST NOT be animatable otherwise this will debug assert.
*/
- CustomPropertyMetadata( std::string propertyName,
- Property::Value propertyValue,
- Property::AccessMode accessMode )
- : PropertyMetadata( std::move(propertyValue), nullptr, ( accessMode != Property::READ_ONLY ) ),
- name( std::move(propertyName) ),
- key( Property::INVALID_KEY ),
- childPropertyIndex( Property::INVALID_INDEX )
+ CustomPropertyMetadata(ConstString propertyName,
+ Property::Value propertyValue,
+ Property::AccessMode accessMode)
+ : PropertyMetadata(std::move(propertyValue), nullptr, (accessMode != Property::READ_ONLY)),
+ name(propertyName),
+ key(Property::INVALID_KEY),
+ childPropertyIndex(Property::INVALID_INDEX)
{
DALI_ASSERT_DEBUG( accessMode != Property::ANIMATABLE && "Event side only properties should not be animatable" );
}
CustomPropertyMetadata& operator=( const CustomPropertyMetadata& );
public: // Data
-
- std::string name; ///< The name of the property.
+ ConstString name; ///< The name of the property.
Property::Index key; ///< The key of the property.
Property::Index childPropertyIndex; ///< The index as a child property.
};
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() )
{
#include <string>
// INTERNAL INCLUDES
+#include <dali/devel-api/object/csharp-type-info.h>
+#include <dali/internal/common/const-string.h>
+#include <dali/internal/event/object/default-property-metadata.h>
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/object/type-info.h>
#include <dali/public-api/object/property.h>
-#include <dali/devel-api/object/csharp-type-info.h>
-#include <dali/internal/event/object/default-property-metadata.h>
+#include <dali/public-api/object/type-info.h>
namespace Dali
{
* @copydoc Dali::TypeInfo::GetPropertyName() const
* this API exists to keep the old public API, which cannot be changed
*/
- const std::string& GetRegisteredPropertyName( Property::Index index ) const;
+ std::string_view GetRegisteredPropertyName(Property::Index index) const;
/**
* Returns the property name for given index
* @param index of the property
* @return name or empty string
*/
- std::string GetPropertyName( Property::Index index ) const;
+ std::string_view GetPropertyName(Property::Index index) const;
/*
* Add an action function
* @param[in] name The name of the property.
* @return The index associated with that name.
*/
- Property::Index GetPropertyIndex( const std::string& name ) const;
+ Property::Index GetPropertyIndex(ConstString name) const;
/**
* Given a property index, retrieve the index of its base property.
* @param[in] name The name of the child property.
* @return The index associated with that name.
*/
- Property::Index GetChildPropertyIndex( const std::string& name ) const;
+ Property::Index GetChildPropertyIndex(ConstString name) const;
/**
* Retrieve the name of the child property at the given index.
* @param[in] index The property index.
* @return The name of the child property.
*/
- const std::string& GetChildPropertyName( Property::Index index ) const;
+ std::string_view GetChildPropertyName(Property::Index index) const;
/**
* Retrieve the Property::Type of the child property at the given index.
struct RegisteredProperty
{
- RegisteredProperty(Property::Type propType, std::string propName, Property::Index basePropertyIndex, int32_t componentIndex)
+ RegisteredProperty(Property::Type propType, ConstString propName, Property::Index basePropertyIndex, int32_t componentIndex)
: type(propType),
setFunc(nullptr),
getFunc(nullptr),
- name(std::move(propName)),
+ name(propName),
basePropertyIndex(basePropertyIndex),
componentIndex(componentIndex)
{
}
- RegisteredProperty(Property::Type propType, Dali::TypeInfo::SetPropertyFunction set, Dali::TypeInfo::GetPropertyFunction get, std::string propName, Property::Index basePropertyIndex, int componentIndex)
+ RegisteredProperty(Property::Type propType, Dali::TypeInfo::SetPropertyFunction set, Dali::TypeInfo::GetPropertyFunction get, ConstString propName, Property::Index basePropertyIndex, int componentIndex)
: type(propType),
setFunc(set),
getFunc(get),
- name(std::move(propName)),
+ name(propName),
basePropertyIndex(basePropertyIndex),
componentIndex(componentIndex)
{
}
- RegisteredProperty(Property::Type propType, Dali::CSharpTypeInfo::SetPropertyFunction set, Dali::CSharpTypeInfo::GetPropertyFunction get, std::string propName, Property::Index basePropertyIndex, int componentIndex)
+ RegisteredProperty(Property::Type propType, Dali::CSharpTypeInfo::SetPropertyFunction set, Dali::CSharpTypeInfo::GetPropertyFunction get, ConstString propName, Property::Index basePropertyIndex, int componentIndex)
: type(propType),
cSharpSetFunc(set),
cSharpGetFunc(get),
- name(std::move(propName)),
+ name(propName),
basePropertyIndex(basePropertyIndex),
componentIndex(componentIndex)
{
Dali::TypeInfo::GetPropertyFunction getFunc = nullptr;
Dali::CSharpTypeInfo::GetPropertyFunction cSharpGetFunc; // only one field can be initialized but this will have same value anyways
};
- std::string name;
+ ConstString name;
Property::Index basePropertyIndex = Property::INVALID_INDEX;
int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
};
std::string Handle::GetPropertyName(Property::Index index) const
{
- return GetImplementation(*this).GetPropertyName(index);
+ return std::string(GetImplementation(*this).GetPropertyName(index));
}
Property::Index Handle::GetPropertyIndex(Property::Key key) const
GetImplementation(*this).SetProperty(index, std::move(propertyValue));
}
-Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue)
+Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue)
{
- return GetImplementation(*this).RegisterProperty(std::move(name), std::move(propertyValue));
+ return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue));
}
-Property::Index Handle::RegisterProperty(Property::Index key, std::string name, Property::Value propertyValue)
+Property::Index Handle::RegisterProperty(Property::Index key, std::string_view name, Property::Value propertyValue)
{
- return GetImplementation(*this).RegisterProperty(std::move(name), key, std::move(propertyValue));
+ return GetImplementation(*this).RegisterProperty(name, key, std::move(propertyValue));
}
-Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
+Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode)
{
- return GetImplementation(*this).RegisterProperty(std::move(name), std::move(propertyValue), accessMode);
+ return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue), accessMode);
}
Property::Value Handle::GetProperty(Property::Index index) const
* - Property::ROTATION
* @note If a property with the desired name already exists, then the value given is just set.
*/
- Property::Index RegisterProperty(std::string name, Property::Value propertyValue);
+ Property::Index RegisterProperty(std::string_view name, Property::Value propertyValue);
/**
* @brief Register a new animatable property with an integer key.
* - Property::ROTATION
* @note If a property with the desired name already exists, then the value given is just set.
*/
- Property::Index RegisterProperty(Property::Index key,
- std::string name,
- Property::Value propertyValue);
+ Property::Index RegisterProperty(Property::Index key,
+ std::string_view name,
+ Property::Value propertyValue);
/**
* @brief Registers a new property.
* - Property::ROTATION
* @note If a property with the desired name already exists, then the value given is just set.
*/
- Property::Index RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode);
+ Property::Index RegisterProperty(std::string_view name, Property::Value propertyValue, Property::AccessMode accessMode);
/**
* @brief Retrieves a property value.
GetImplementation(*this).GetPropertyIndices(indices);
}
-const std::string& TypeInfo::GetPropertyName(Property::Index index) const
+std::string_view TypeInfo::GetPropertyName(Property::Index index) const
{
return GetImplementation(*this).GetRegisteredPropertyName(index);
}
Property::Index TypeInfo::GetChildPropertyIndex(const std::string& name) const
{
- return GetImplementation(*this).GetChildPropertyIndex(name);
+ return GetImplementation(*this).GetChildPropertyIndex(Internal::ConstString(name));
}
-const std::string& TypeInfo::GetChildPropertyName(Property::Index index) const
+std::string_view TypeInfo::GetChildPropertyName(Property::Index index) const
{
return GetImplementation(*this).GetChildPropertyName(index);
}
* @exception DaliException If index is not valid.
* @note this method only works for custom registered properties
*/
- const std::string& GetPropertyName(Property::Index index) const;
+ std::string_view GetPropertyName(Property::Index index) const;
/**
* @brief Given a child property name, retrieve the property index associated with it,
* @param[in] index The property index
* @return The name of the property at the given index, or empty string if it does not exist
*/
- const std::string& GetChildPropertyName(Property::Index index) const;
+ std::string_view GetChildPropertyName(Property::Index index) const;
/**
* @brief Given a child property index, retrieve the property name associated with it.