本文整理汇总了C++中TSharedRef::GetBoolField方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::GetBoolField方法的具体用法?C++ TSharedRef::GetBoolField怎么用?C++ TSharedRef::GetBoolField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedRef
的用法示例。
在下文中一共展示了TSharedRef::GetBoolField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
TSharedPtr< FQuestionBlock > FQuestionBlock::Create( const TSharedRef< class FEpicSurvey >& InEpicSurvey, const TSharedRef< FJsonObject >& JsonConfig )
{
TSharedPtr< FQuestionBlock > Block = MakeShareable( new FQuestionBlock( InEpicSurvey ) );
Block->Style = Style_Inline;
if ( JsonConfig->HasTypedField< EJson::String >( TEXT("style") ) )
{
const FString Style = JsonConfig->GetStringField( TEXT("style") );
if ( Style == TEXT("multiline") )
{
Block->Style = Style_Multiline;
}
else if ( Style == TEXT("multiline-text") )
{
Block->Style = Style_MultilineText;
}
else if ( Style == TEXT("inline-text") )
{
Block->Style = Style_InlineText;
}
else if ( Style == TEXT("columns") )
{
Block->Style = Style_Columns;
}
}
Block->Instructions = FText::GetEmpty();
if ( JsonConfig->HasTypedField< EJson::String >( TEXT("instructions") ) )
{
Block->Instructions = FText::FromString( JsonConfig->GetStringField( TEXT("instructions") ) );
}
Block->bIsRequired = true;
if ( JsonConfig->HasTypedField< EJson::Boolean >( TEXT("required") ) )
{
Block->bIsRequired = JsonConfig->GetBoolField( TEXT("required") );
}
Block->Response = FQuestionBlock::Response_Single;
if ( JsonConfig->HasTypedField< EJson::String >( TEXT("response") ) )
{
const FString ResponseString = JsonConfig->GetStringField( TEXT("response") );
if ( ResponseString == TEXT("multi") )
{
Block->Response = FQuestionBlock::Response_Multi;
}
}
else if ( JsonConfig->HasTypedField< EJson::Number >( TEXT("response") ) )
{
int32 ResponseNumber = (int32)( JsonConfig->GetNumberField( TEXT("response") ) );
if ( ResponseNumber <= 0 )
{
Block->Response = FQuestionBlock::Response_Multi;
}
else if ( ResponseNumber == 1 )
{
Block->Response = FQuestionBlock::Response_Multi;
}
else
{
Block->Response = (FQuestionBlock::EResponse)ResponseNumber;
}
}
if ( JsonConfig->HasTypedField< EJson::Array >( TEXT("questions") ) )
{
TArray< TSharedPtr< FJsonValue > > QuestionStrings = JsonConfig->GetArrayField( TEXT("questions") );
for (int Index = 0; Index < QuestionStrings.Num(); Index++)
{
const FString Question = QuestionStrings[Index]->AsString();
if ( !Question.IsEmpty() )
{
Block->Questions.Add( FText::FromString( Question ) );
Block->UserAnswers.Add( TArray< int32 >() );
Block->UserTextAnswers.Add( TArray< FString >() );
}
}
}
if ( JsonConfig->HasTypedField< EJson::Array >( TEXT("answers") ) )
{
TArray< TSharedPtr< FJsonValue > > AnswerStrings = JsonConfig->GetArrayField( TEXT("answers") );
for (int AnswerIndex = 0; AnswerIndex < AnswerStrings.Num(); AnswerIndex++)
{
for (int QuestionIndex = 0; QuestionIndex < Block->UserTextAnswers.Num(); QuestionIndex++)
{
Block->UserTextAnswers[QuestionIndex].Push( FString() );
}
FAnswer Answer;
switch( AnswerStrings[AnswerIndex]->Type )
{
case EJson::String:
{
Answer.Text = FText::FromString( AnswerStrings[AnswerIndex]->AsString() );
}
break;
case EJson::Object:
{
TSharedPtr<FJsonObject> SubObject = AnswerStrings[AnswerIndex]->AsObject();
//.........这里部分代码省略.........
示例2: NewSurvey
TSharedPtr< FSurvey > FSurvey::Create( const TSharedRef< class FEpicSurvey >& InEpicSurvey, const TSharedRef< FJsonObject >& JsonConfig )
{
FGuid Identifier;
if (!FGuid::ParseExact(JsonConfig->GetStringField( TEXT("id") ), EGuidFormats::DigitsWithHyphens, Identifier))
{
return nullptr;
}
TSharedPtr< FSurvey > NewSurvey( new FSurvey( InEpicSurvey ) );
NewSurvey->Identifier = Identifier;
NewSurvey->BannerBrushPath = JsonConfig->GetStringField( TEXT("banner") );
NewSurvey->DisplayName = FText::FromString( JsonConfig->GetStringField( TEXT("name") ) );
NewSurvey->Instructions = FText::FromString( JsonConfig->GetStringField( TEXT("instructions") ) );
NewSurvey->SurveyType = ESurveyType::Normal;
NewSurvey->AutoPrompt = true;
NewSurvey->SurveyVersion = 1;
NewSurvey->MinEngineVersion.Empty();
NewSurvey->MaxEngineVersion.Empty();
if ( JsonConfig->HasTypedField<EJson::Boolean>( TEXT("auto_prompt") ) )
{
NewSurvey->AutoPrompt = int32(JsonConfig->GetBoolField( TEXT("auto_prompt") ) );
}
if( JsonConfig->HasTypedField<EJson::Number>( TEXT("survey_version") ) )
{
NewSurvey->SurveyVersion = int32(JsonConfig->GetNumberField( TEXT("survey_version") ) );
}
if( JsonConfig->HasTypedField<EJson::String>( TEXT("min_engine_version") ) )
{
FEngineVersion::Parse( JsonConfig->GetStringField( TEXT("min_engine_version") ), NewSurvey->MinEngineVersion );
}
if (JsonConfig->HasTypedField<EJson::String>(TEXT("max_engine_version")))
{
FEngineVersion::Parse( JsonConfig->GetStringField( TEXT("max_engine_version") ), NewSurvey->MaxEngineVersion );
}
if( (NewSurvey->SurveyVersion != CurrentSurveyVersion)
|| (!NewSurvey->MinEngineVersion.IsEmpty() && GEngineVersion.IsCompatibleWith(NewSurvey->MinEngineVersion))
|| (!NewSurvey->MaxEngineVersion.IsEmpty() && NewSurvey->MaxEngineVersion.IsCompatibleWith(GEngineVersion)) )
{
return NULL;
}
if( JsonConfig->HasTypedField<EJson::String>( "type" ) )
{
FString SurveyType = JsonConfig->GetStringField( TEXT("type") );
if( !SurveyType.IsEmpty() )
{
if( SurveyType == TEXT( "branch" ) )
{
NewSurvey->SurveyType = ESurveyType::Branch;
}
}
}
if( JsonConfig->HasTypedField< EJson::Array >( "branches" ) )
{
TArray< TSharedPtr< FJsonValue > > JsonSurveyBranches = JsonConfig->GetArrayField( "branches" );
for (int Index = 0; Index < JsonSurveyBranches.Num(); Index++)
{
TSharedPtr< FSurveyBranch > Branch = FSurveyBranch::Create( InEpicSurvey, JsonSurveyBranches[Index]->AsObject().ToSharedRef() );
if ( Branch.IsValid() )
{
NewSurvey->Branches.Add( Branch.ToSharedRef() );
InEpicSurvey->AddBranch( Branch->GetBranchName() );
}
}
}
if( JsonConfig->HasTypedField< EJson::Array >( "pages" ) )
{
TArray< TSharedPtr< FJsonValue > > JsonSurveyPages = JsonConfig->GetArrayField( "pages" );
for (int Index = 0; Index < JsonSurveyPages.Num(); Index++)
{
TSharedPtr< FJsonObject > PageObject = JsonSurveyPages[Index]->AsObject();
if( PageObject.IsValid() )
{
TSharedPtr<FSurveyPage> Page = FSurveyPage::Create( InEpicSurvey, PageObject.ToSharedRef() );
if( Page.IsValid() )
{
NewSurvey->Pages.Add( Page.ToSharedRef() );
if( NewSurvey->SurveyType == ESurveyType::Branch )
{
Page->SetBranchSurvey( NewSurvey );
}
}
}
}
}
else
{
TSharedPtr<FSurveyPage> Page = FSurveyPage::Create( InEpicSurvey, JsonConfig );
if( Page.IsValid() )
{
NewSurvey->Pages.Add( Page.ToSharedRef() );
}
}
//.........这里部分代码省略.........