本文整理汇总了C++中JsonWriter::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonWriter::Close方法的具体用法?C++ JsonWriter::Close怎么用?C++ JsonWriter::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonWriter
的用法示例。
在下文中一共展示了JsonWriter::Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveCookedPackageAssetRegistry
//.........这里部分代码省略.........
if ( shouldRead )
{
TArray<TSharedPtr<FJsonValue>> PackageList = JsonObject->GetArrayField(TEXT("Packages"));
for (auto PackageListIt = PackageList.CreateConstIterator(); PackageListIt && shouldRead; ++PackageListIt)
{
const TSharedPtr<FJsonValue>& JsonValue = *PackageListIt;
shouldRead = JsonValue->Type == EJson::Object;
if ( shouldRead )
{
const TSharedPtr<FJsonObject>& JsonPackage = JsonValue->AsObject();
// get the package name and see if we have already written it out this run
FString CookedPackageName;
verify( JsonPackage->TryGetStringField(TEXT("SourcePackageName"), CookedPackageName) );
const FName CookedPackageFName(*CookedPackageName);
if ( CookedPackages.Contains(CookedPackageFName))
{
// don't need to process this package
continue;
}
// check that the on disk version is still valid
FString SourcePackageName;
check( JsonPackage->TryGetStringField( TEXT("SourcePackageName"), SourcePackageName) );
// if our timestamp is different then don't copy the information over
FDateTime CurrentTimeStamp = IFileManager::Get().GetTimeStamp( *CookedPackageName );
FString SavedTimeString;
check( JsonPackage->TryGetStringField(TEXT("CookedPackageTimeStamp"), SavedTimeString) );
FDateTime SavedTimeStamp;
FDateTime::Parse(SavedTimeString, SavedTimeStamp);
if ( SavedTimeStamp != CurrentTimeStamp )
{
continue;
}
CopyJsonValueToWriter(Json, FString(), JsonValue);
// read in all the other stuff and copy it over to the new registry
/*Json->WriteObjectStart(); // open package
// copy all the values over
for ( const auto& JsonPackageValue : JsonPackage->Values)
{
CopyJsonValueToWriter(Json, JsonPackageValue.Key, JsonPackageValue.Value);
}
Json->WriteObjectEnd();*/
}
}
}
else
{
UE_LOG(LogChunkManifestGenerator, Warning, TEXT("Unable to read or json is invalid format %s"), *CookedAssetRegistryFilename);
}
}
}
Json->WriteArrayEnd();
Json->WriteObjectEnd();
if (Json->Close())
{
FArchive* ItemTemplatesFile = IFileManager::Get().CreateFileWriter(*CookedAssetRegistryFilename);
if (ItemTemplatesFile)
{
// serialize the file contents
TStringConversion<FTCHARToUTF8_Convert> Convert(*JsonOutString);
ItemTemplatesFile->Serialize(const_cast<ANSICHAR*>(Convert.Get()), Convert.Length());
ItemTemplatesFile->Close();
if ( !ItemTemplatesFile->IsError() )
{
bSuccess = true;
}
else
{
UE_LOG(LogChunkManifestGenerator, Error, TEXT("Unable to write to %s"), *CookedAssetRegistryFilename);
}
delete ItemTemplatesFile;
}
else
{
UE_LOG(LogChunkManifestGenerator, Error, TEXT("Unable to open %s for writing."), *CookedAssetRegistryFilename);
}
}
else
{
UE_LOG(LogChunkManifestGenerator, Error, TEXT("Error closing Json Writer"));
}
}
return bSuccess;
}