本文整理汇总了C++中PropertyAccessor::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyAccessor::getName方法的具体用法?C++ PropertyAccessor::getName怎么用?C++ PropertyAccessor::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyAccessor
的用法示例。
在下文中一共展示了PropertyAccessor::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bindPropertyImpl
//------------------------------------------------------------------------------
void ClassDefinition::bindPropertyImpl(
const char * name,
const ObjectHandle & pBase,
PropertyAccessor & o_PropertyAccessor ) const
{
if (!*name)
{
// empty name causes noop
return;
}
// find property operator
auto propOperator = name;
while (true)
{
if( !*propOperator ||
*propOperator == INDEX_OPEN ||
*propOperator == DOT_OPERATOR )
{
break;
}
propOperator += 1;
}
auto propName = name;
auto propLength = propOperator - propName;
auto baseProp = findProperty( propName, propLength );
if (baseProp == nullptr)
{
// error: property `propName` is not found
o_PropertyAccessor.setBaseProperty( nullptr );
return;
}
o_PropertyAccessor.setObject( pBase );
o_PropertyAccessor.setBaseProperty( baseProp );
assert( strncmp( propName, o_PropertyAccessor.getName(), propLength ) == 0 );
if (!*propOperator)
{
// no operator, so that's it
return;
}
Variant propVal = o_PropertyAccessor.getValue();
if (*propOperator == INDEX_OPEN)
{
auto wholeIndex = propOperator;
// read "multidimensional" indices without recursive bind (optimization)
while (true)
{
Collection collection;
if (!propVal.tryCast( collection ))
{
// error: index operator is applicable to collections only
o_PropertyAccessor.setBaseProperty( nullptr );
return;
}
// determine key type (heterogeneous keys are not supported yet)
const auto begin = collection.begin();
const auto end = collection.end();
if (begin == end)
{
// error: can't index empty collection
o_PropertyAccessor.setBaseProperty( nullptr );
return;
}
// read key
Variant key( begin.key().type() );
{
propOperator += 1; // skip INDEX_OPEN
FixedMemoryStream dataStream( propOperator );
TextStream stream( dataStream );
stream >> key >> match( INDEX_CLOSE );
if (stream.fail())
{
// error: either key can't be read, or it isn't followed by INDEX_CLOSE
o_PropertyAccessor.setBaseProperty( nullptr );
return;
}
// skip key and closing bracket
propOperator += stream.seek( 0, std::ios_base::cur );
}
auto it = collection.find( key );
// If (it == end), still return a valid property accessor to end,
// rather than an invalid property accessor.
if (!*propOperator || (it == end))
//.........这里部分代码省略.........