本文整理汇总了C++中TSharedRef::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::Close方法的具体用法?C++ TSharedRef::Close怎么用?C++ TSharedRef::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedRef
的用法示例。
在下文中一共展示了TSharedRef::Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SavePluginDescriptor
bool FPluginHelpers::SavePluginDescriptor(const FString& NewProjectFilename, const FPluginDescriptor& PluginDescriptor)
{
FString Text;
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&Text);
Writer->WriteObjectStart();
// Write all the simple fields
Writer->WriteValue(TEXT("FileVersion"), PluginDescriptor.FileVersion);
Writer->WriteValue(TEXT("FriendlyName"), PluginDescriptor.FriendlyName);
Writer->WriteValue(TEXT("Version"), PluginDescriptor.Version);
Writer->WriteValue(TEXT("VersionName"), PluginDescriptor.VersionName);
Writer->WriteValue(TEXT("CreatedBy"), PluginDescriptor.CreatedBy);
Writer->WriteValue(TEXT("CreatedByURL"), PluginDescriptor.CreatedByURL);
Writer->WriteValue(TEXT("Category"), PluginDescriptor.Category);
Writer->WriteValue(TEXT("Description"), PluginDescriptor.Description);
Writer->WriteValue(TEXT("EnabledByDefault"), PluginDescriptor.bEnabledByDefault);
// Write the module list
FModuleDescriptor::WriteArray(Writer.Get(), TEXT("Modules"), PluginDescriptor.Modules);
Writer->WriteObjectEnd();
Writer->Close();
return FFileHelper::SaveStringToFile(Text, *NewProjectFilename);
}
示例2: SaveCustomizedBlocks
void FMultiBoxCustomizationData::SaveCustomizedBlocks()
{
FString SaveData;
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create( &SaveData );
Writer->WriteObjectStart();
Writer->WriteArrayStart(TEXT("CustomBlocks"));
for (TArray<FCustomBlockTransaction>::TConstIterator It(Transactions); It; ++It)
{
const FCustomBlockTransaction& Transaction = *It;
if( Transaction.Command.IsValid() )
{
const FUICommandInfo& Command = *Transaction.Command.Pin();
Writer->WriteObjectStart();
Writer->WriteValue(TEXT("CommandName"), Command.GetCommandName().ToString() );
Writer->WriteValue(TEXT("Context"), Command.GetBindingContext().ToString() );
Writer->WriteValue(TEXT("Index"), (float)Transaction.BlockIndex );
Writer->WriteValue(TEXT("TransactionType"), (float)Transaction.TransactionType );
Writer->WriteObjectEnd();
}
}
Writer->WriteArrayEnd();
Writer->WriteObjectEnd();
Writer->Close();
GConfig->SetString( *GetConfigSectionName(), *CustomizationName.ToString(), *FRemoteConfig::ReplaceIniCharWithSpecialChar(SaveData).ReplaceCharWithEscapedChar(), GEditorPerProjectIni );
}
示例3: SaveGame
bool UFlareSaveGameSystem::SaveGame(const FString SaveName, UFlareSaveGame* SaveData)
{
bool ret = false;
SaveLock.Lock();
FLOGV("UFlareSaveGameSystem::SaveGame SaveName=%s", *SaveName);
UFlareSaveWriter* SaveWriter = NewObject<UFlareSaveWriter>(this, UFlareSaveWriter::StaticClass());
TSharedRef<FJsonObject> JsonObject = SaveWriter->SaveGame(SaveData);
// Save the json object
FString FileContents;
//TSharedRef< TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR>> > JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&FileContents);
TSharedRef< TJsonWriter<> > JsonWriter = TJsonWriterFactory<>::Create(&FileContents);
if (FJsonSerializer::Serialize(JsonObject, JsonWriter))
{
JsonWriter->Close();
ret = FFileHelper::SaveStringToFile(FileContents, *GetSaveGamePath(SaveName));
FLOG("UFlareSaveGameSystem::SaveGame : Save done");
}
else
{
FLOGV("Fail to serialize save %s", *SaveName);
ret = false;
}
SaveLock.Unlock();
return ret;
}
示例4: UStructToJsonObjectStringInternal
bool UStructToJsonObjectStringInternal(const TSharedRef<FJsonObject>& JsonObject, FString& OutJsonString, int32 Indent)
{
TSharedRef<TJsonWriter<CharType, PrintPolicy> > JsonWriter = TJsonWriterFactory<CharType, PrintPolicy>::Create(&OutJsonString, Indent);
bool bSuccess = FJsonSerializer::Serialize(JsonObject, JsonWriter);
JsonWriter->Close();
return bSuccess;
}
示例5: TouchStopped
void AHttpRequestCharacter::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location)
{
if (FingerIndex == ETouchIndex::Touch1)
{
/* Added for HTTP requests */
// Create a writer and hold it in this FString
FString JsonStr;
TSharedRef< TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR> > > JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR> >::Create(&JsonStr);
JsonWriter->WriteObjectStart();
JsonWriter->WriteValue(TEXT("user"), TEXT("StormUnited"));
JsonWriter->WriteObjectEnd();
// Close the writer and finalize the output such that JsonStr has what we want
JsonWriter->Close();
TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8"));
HttpRequest->SetURL(TEXT("http://localhost/configuration"));
HttpRequest->SetVerb(TEXT("POST"));
HttpRequest->SetContentAsString(JsonStr);
HttpRequest->OnProcessRequestComplete().BindUObject(this, HttpCompleteCallback);
HttpRequest->ProcessRequest();
/* Added for HTTP requests */
StopJumping();
}
}
示例6: UserRequestJson
FORCEINLINE FString UserRequestJson()
{
FString JsonStr;
TSharedRef< TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR> > > JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR> >::Create(&JsonStr);
JsonWriter->WriteObjectStart();
JsonWriter->WriteValue(TEXT("devicetype"), TEXT("pc#ue4hue"));
JsonWriter->WriteObjectEnd();
JsonWriter->Close();
return JsonStr;
}
示例7: SetLightBrightnessByGroupID
void UPhilipsHueBridge::SetLightBrightnessByGroupID(const int32 GroupID, const float Brightness)
{
int32 Bri = (int32)(255.f*Brightness);
FString JsonStr;
TSharedRef< TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR> > > JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR> >::Create(&JsonStr);
JsonWriter->WriteObjectStart();
JsonWriter->WriteValue(TEXT("bri"), Bri);
JsonWriter->WriteObjectEnd();
JsonWriter->Close();
SetLightGroupActionByIDRaw(0, JsonStr);
}
示例8: SaveGame
bool UFlareSaveGameSystem::SaveGame(const FString SaveName, UFlareSaveGame* SaveData)
{
bool ret = false;
SaveLock.Lock();
FLOGV("UFlareSaveGameSystem::SaveGame SaveName=%s", *SaveName);
UFlareSaveWriter* SaveWriter = NewObject<UFlareSaveWriter>(this, UFlareSaveWriter::StaticClass());
TSharedRef<FJsonObject> JsonObject = SaveWriter->SaveGame(SaveData);
// Save the json object
FString FileContents;
//TSharedRef< TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR>> > JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&FileContents);
TSharedRef< TJsonWriter<> > JsonWriter = TJsonWriterFactory<>::Create(&FileContents);
if (FJsonSerializer::Serialize(JsonObject, JsonWriter))
{
JsonWriter->Close();
bool Compress = true;
if(Compress)
{
uint32 StrLength = FCStringAnsi::Strlen(TCHAR_TO_UTF8(*FileContents));
uint8* CompressedDataRaw = new uint8[StrLength];
int32 CompressedSize = StrLength;
const bool bResult = FCompression::CompressMemory((ECompressionFlags)(COMPRESS_GZIP), CompressedDataRaw, CompressedSize, TCHAR_TO_UTF8(*FileContents), StrLength);
if (bResult)
{
ret = FFileHelper::SaveArrayToFile(TArrayView<const uint8>(CompressedDataRaw, CompressedSize), *GetSaveGamePath(SaveName, true));
}
delete[] CompressedDataRaw;
}
else
{
ret = FFileHelper::SaveStringToFile(FileContents, *GetSaveGamePath(SaveName, false));
}
FLOG("UFlareSaveGameSystem::SaveGame : Save done");
}
else
{
FLOGV("Fail to serialize save %s", *SaveName);
ret = false;
}
SaveLock.Unlock();
SaveListLock.Lock();
SaveList.Remove(SaveData);
SaveListLock.Unlock();
return ret;
}
示例9: UStructToJsonObjectString
bool FJsonObjectConverter::UStructToJsonObjectString(const UStruct* StructDefinition, const void* Struct, FString& OutJsonString, int64 CheckFlags, int64 SkipFlags, int32 Indent)
{
TSharedRef<FJsonObject> JsonObject = MakeShareable( new FJsonObject() );
if (UStructToJsonObject(StructDefinition, Struct, JsonObject, CheckFlags, SkipFlags))
{
TSharedRef<TJsonWriter<> > JsonWriter = TJsonWriterFactory<>::Create(&OutJsonString, Indent);
if (FJsonSerializer::Serialize( JsonObject, JsonWriter ))
{
JsonWriter->Close();
return true;
}
else
{
UE_LOG(LogJson, Warning, TEXT("UStructToJsonObjectString - Unable to write out json"));
JsonWriter->Close();
}
}
return false;
}
示例10: SaveSimpleProfiles
void FLauncherProfileManager::SaveSimpleProfiles()
{
for (TArray<ILauncherSimpleProfilePtr>::TIterator It(SimpleProfiles); It; ++It)
{
FString SimpleProfileFileName = FLauncherProfile::GetProfileFolder() / (*It)->GetDeviceName() + TEXT(".uslp");
FString Text;
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&Text);
(*It)->Save(Writer.Get());
Writer->Close();
FFileHelper::SaveStringToFile(Text, *SimpleProfileFileName);
}
}
示例11: SaveJSONProfile
bool FLauncherProfileManager::SaveJSONProfile(const ILauncherProfileRef& Profile)
{
if (Profile->GetId().IsValid())
{
FString Text;
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&Text);
Profile->Save(Writer.Get());
Writer->Close();
return FFileHelper::SaveStringToFile(Text, *Profile->GetFilePath());
}
return false;
}
示例12: GetTableAsJSON
FString UCurveTable::GetTableAsJSON() const
{
// use the pretty print policy since these values are usually getting dumpped for check-in to P4 (or for inspection)
FString Result;
TSharedRef< TJsonWriter<TCHAR, TPrettyJsonPrintPolicy<TCHAR> > > JsonWriter = TJsonWriterFactory<TCHAR, TPrettyJsonPrintPolicy<TCHAR> >::Create(&Result);
if (!WriteTableAsJSON(JsonWriter))
{
return TEXT("No data in row curve!\n");
}
JsonWriter->Close();
return Result;
}
示例13: SetLightColorByLightID
void UPhilipsHueBridge::SetLightColorByLightID(const int32 LightID, const FLinearColor InColor)
{
FVector2D xy = ColorToxy(InColor);
FString JsonStr;
TSharedRef< TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR> > > JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR> >::Create(&JsonStr);
FString str = "[" + FString::SanitizeFloat(xy.X) + "," + FString::SanitizeFloat(xy.Y) + "]";
JsonWriter->WriteObjectStart();
JsonWriter->WriteRawJSONValue(TEXT("xy"), str);
JsonWriter->WriteObjectEnd();
JsonWriter->Close();
SetLightStateByLightIDRaw(LightID, JsonStr);
}
示例14: SerializeManifest
bool FInternationalizationManifestJsonSerializer::SerializeManifest( TSharedRef< const FInternationalizationManifest > Manifest, FString& Str )
{
TSharedRef< FJsonObject > JsonManifestObj = MakeShareable( new FJsonObject );
bool bExecSuccessful = SerializeInternal( Manifest, JsonManifestObj );
if(bExecSuccessful)
{
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create( &Str );
bExecSuccessful = FJsonSerializer::Serialize(JsonManifestObj, Writer);
Writer->Close();
}
return bExecSuccessful;
}
示例15: SerializeArchive
bool FJsonInternationalizationArchiveSerializer::SerializeArchive( TSharedRef< const FInternationalizationArchive > InternationalizationArchive, FString& Str )
{
TSharedRef< FJsonObject > JsonArchiveObj = MakeShareable( new FJsonObject );
bool bExecSuccessful = SerializeInternal( InternationalizationArchive, JsonArchiveObj );
if( bExecSuccessful )
{
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create( &Str );
bExecSuccessful = FJsonSerializer::Serialize( JsonArchiveObj, Writer );
Writer->Close();
}
return bExecSuccessful;
}