本文整理汇总了C++中TSharedRef::AsBool方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::AsBool方法的具体用法?C++ TSharedRef::AsBool怎么用?C++ TSharedRef::AsBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedRef
的用法示例。
在下文中一共展示了TSharedRef::AsBool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}