本文整理汇总了C++中TSharedRef::AsObject方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::AsObject方法的具体用法?C++ TSharedRef::AsObject怎么用?C++ TSharedRef::AsObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedRef
的用法示例。
在下文中一共展示了TSharedRef::AsObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConditionTranslationMetadata
void ConditionTranslationMetadata( TSharedRef<FLocMetadataValue> MetadataValue )
{
switch( MetadataValue->Type )
{
case ELocMetadataType::String:
{
TSharedPtr<FLocMetadataValue> MetadataValuePtr = MetadataValue;
TSharedPtr<FLocMetadataValueString> MetadataString = StaticCastSharedPtr<FLocMetadataValueString>( MetadataValuePtr );
MetadataString->SetString( TEXT("") );
}
break;
case ELocMetadataType::Array:
{
TArray< TSharedPtr< FLocMetadataValue > > MetadataArray = MetadataValue->AsArray();
for( auto ArrayIter = MetadataArray.CreateIterator(); ArrayIter; ++ArrayIter )
{
TSharedPtr<FLocMetadataValue>& Item = *ArrayIter;
if( Item.IsValid() )
{
ConditionTranslationMetadata( Item.ToSharedRef() );
}
}
}
break;
case ELocMetadataType::Object:
{
TSharedPtr< FLocMetadataObject > MetadataObject = MetadataValue->AsObject();
for( auto ValueIter = MetadataObject->Values.CreateConstIterator(); ValueIter; ++ValueIter )
{
const FString Name = (*ValueIter).Key;
TSharedPtr< FLocMetadataValue > Value = (*ValueIter).Value;
if( Value.IsValid() )
{
if( Value->Type == ELocMetadataType::String )
{
MetadataObject->SetStringField( Name, TEXT("") );
}
else
{
ConditionTranslationMetadata( Value.ToSharedRef() );
}
}
}
}
default:
break;
}
}
示例2: ConditionSourceMetadata
void ConditionSourceMetadata( TSharedRef<FLocMetadataValue> MetadataValue )
{
switch( MetadataValue->Type )
{
case ELocMetadataType::Object:
{
TSharedPtr< FLocMetadataObject > MetadataObject = MetadataValue->AsObject();
TArray< FString > NamesToBeReplaced;
// We go through all the source metadata entries and look for any that have names prefixed with a '*'. If we
// find any, we will replace them with a String type that contains an empty value
for( auto Iter = MetadataObject->Values.CreateConstIterator(); Iter; ++Iter )
{
const FString& Name = (*Iter).Key;
TSharedPtr< FLocMetadataValue > Value = (*Iter).Value;
if( Name.StartsWith( FLocMetadataObject::COMPARISON_MODIFIER_PREFIX ) )
{
NamesToBeReplaced.Add(Name);
}
else
{
ConditionSourceMetadata( Value.ToSharedRef() );
}
}
for( auto Iter = NamesToBeReplaced.CreateConstIterator(); Iter; ++Iter )
{
MetadataObject->RemoveField( *Iter );
MetadataObject->SetStringField( *Iter, TEXT("") );
}
}
default:
break;
}
}
示例3: MakeShareable
TSharedPtr<FJsonValue> LocMetaDataValueToJsonValue( const TSharedRef< FLocMetadataValue > MetadataValue )
{
switch( MetadataValue->Type )
{
case ELocMetadataType::Boolean:
{
return MakeShareable( new FJsonValueBoolean( MetadataValue->AsBool() ) );
}
break;
case ELocMetadataType::String:
{
return MakeShareable( new FJsonValueString( MetadataValue->AsString() ) );
}
break;
case ELocMetadataType::Array:
{
TArray< TSharedPtr<FJsonValue> > JsonArrayVals;
TArray< TSharedPtr< FLocMetadataValue > > MetaDataArray = MetadataValue->AsArray();
MetaDataArray.Sort( FCompareLocMetadataValue() );
for( auto ArrayIter = MetaDataArray.CreateConstIterator(); ArrayIter; ++ArrayIter )
{
const TSharedPtr<FLocMetadataValue>& Item = *ArrayIter;
if( Item.IsValid() )
{
TSharedPtr<FJsonValue> Entry = LocMetaDataValueToJsonValue( Item.ToSharedRef() );
if( Entry.IsValid() )
{
JsonArrayVals.Add( Entry );
}
}
}
if( JsonArrayVals.Num() > 0 )
{
return MakeShareable( new FJsonValueArray( JsonArrayVals ) );
}
}
break;
case ELocMetadataType::Object:
{
TSharedPtr< FJsonObject > JsonSubObject = MakeShareable( new FJsonObject );
TSharedPtr< FLocMetadataObject > MetaDataObject = MetadataValue->AsObject();
for( auto ValueIter = MetaDataObject->Values.CreateConstIterator(); ValueIter; ++ValueIter )
{
const FString Name = (*ValueIter).Key;
TSharedPtr< FLocMetadataValue > Value = (*ValueIter).Value;
if( Value.IsValid() )
{
TSharedPtr< FJsonValue > JsonValue = LocMetaDataValueToJsonValue( Value.ToSharedRef() );
if( JsonValue.IsValid() )
{
JsonSubObject->SetField( Name, JsonValue );
}
}
}
// Sorting by key is probably sufficient for now but ideally we would sort the resulting json object using
// the same logic that is in the FLocMetadata < operator
JsonSubObject->Values.KeySort( TLess<FString>() );
return MakeShareable( new FJsonValueObject(JsonSubObject) );
}
default:
break;
}
return NULL;
}