当前位置: 首页>>代码示例>>C++>>正文


C++ TSharedRef::GetEntriesBySourceTextIterator方法代码示例

本文整理汇总了C++中TSharedRef::GetEntriesBySourceTextIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::GetEntriesBySourceTextIterator方法的具体用法?C++ TSharedRef::GetEntriesBySourceTextIterator怎么用?C++ TSharedRef::GetEntriesBySourceTextIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSharedRef的用法示例。


在下文中一共展示了TSharedRef::GetEntriesBySourceTextIterator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenerateStructuredData

void FJsonInternationalizationArchiveSerializer::GenerateStructuredData( TSharedRef< const FInternationalizationArchive > InArchive, TSharedPtr<FStructuredArchiveEntry> RootElement )
{
	//Loop through all the unstructured archive entries and build up our structured hierarchy
	for(FArchiveEntryByStringContainer::TConstIterator It( InArchive->GetEntriesBySourceTextIterator() ); It; ++It)
	{
		const TSharedRef< FArchiveEntry > UnstructuredArchiveEntry = It.Value();

		TArray< FString > NamespaceTokens;

		// Tokenize the namespace by using '.' as a delimiter
		int32 NamespaceTokenCount = UnstructuredArchiveEntry->Namespace.ParseIntoArray( NamespaceTokens, *NAMESPACE_DELIMITER, true );

		TSharedPtr< FStructuredArchiveEntry > StructuredArchiveEntry = RootElement;
		//Loop through all the namespace tokens and find the appropriate structured entry, if it does not exist add it.  At the end StructuredArchiveEntry
		//  will point to the correct hierarchy entry for a given namespace
		for( int32 TokenIndex = 0; TokenIndex < NamespaceTokenCount; ++TokenIndex )
		{
			TSharedPtr<FStructuredArchiveEntry> FoundNamespaceEntry;
			for( int SubNamespaceIndex = 0; SubNamespaceIndex < StructuredArchiveEntry->SubNamespaces.Num(); SubNamespaceIndex++ )
			{
				if(  StructuredArchiveEntry->SubNamespaces[SubNamespaceIndex]->Namespace == NamespaceTokens[TokenIndex] )
				{
					FoundNamespaceEntry = StructuredArchiveEntry->SubNamespaces[SubNamespaceIndex];
					break;
				}
			}

			if( !FoundNamespaceEntry.IsValid() )
			{
				int32 index = StructuredArchiveEntry->SubNamespaces.Add( MakeShareable( new FStructuredArchiveEntry( NamespaceTokens[TokenIndex] ) ) );
				FoundNamespaceEntry = StructuredArchiveEntry->SubNamespaces[index];
			}
			StructuredArchiveEntry = FoundNamespaceEntry;
		}

		// We add the unstructured Archive entry to the hierarchy
		StructuredArchiveEntry->ArchiveEntries.AddUnique( UnstructuredArchiveEntry );
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:39,代码来源:JsonInternationalizationArchiveSerializer.cpp

示例2: DoExport


//.........这里部分代码省略.........
	}

	// Process the desired cultures
	for(int32 Culture = 0; Culture < CulturesToGenerate.Num(); Culture++)
	{
		// Load the archive
		const FString CultureName = CulturesToGenerate[Culture];
		const FString CulturePath = SourcePath / CultureName;
		FString ArchiveFileName = CulturePath / ArchiveName;
		TSharedPtr< FJsonObject > ArchiveJsonObject = NULL;

		if( FPaths::FileExists(ArchiveFileName) )
		{
			ArchiveJsonObject = ReadJSONTextFile( ArchiveFileName );

			FJsonInternationalizationArchiveSerializer ArchiveSerializer;
			TSharedRef< FInternationalizationArchive > InternationalizationArchive = MakeShareable( new FInternationalizationArchive );
			ArchiveSerializer.DeserializeArchive( ArchiveJsonObject.ToSharedRef(), InternationalizationArchive );

			{
				FPortableObjectFormatDOM PortableObj;

				FString LocLang;
				if( !PortableObj.SetLanguage( CultureName ) )
				{
					UE_LOG( LogInternationalizationExportCommandlet, Error, TEXT("Skipping export of loc language %s because it is not recognized."), *LocLang );
					continue;
				}

				PortableObj.SetProjectName( FPaths::GetBaseFilename( ManifestName ) );
				PortableObj.CreateNewHeader();

				{
					for(TManifestEntryBySourceTextContainer::TConstIterator ManifestIter = InternationalizationManifest->GetEntriesBySourceTextIterator(); ManifestIter; ++ManifestIter)
					{
						// Gather relevant info from manifest entry.
						const TSharedRef<FManifestEntry>& ManifestEntry = ManifestIter.Value();
						const FString& Namespace = ManifestEntry->Namespace;
						const FLocItem& Source = ManifestEntry->Source;

						for( auto ContextIter = ManifestEntry->Contexts.CreateConstIterator(); ContextIter; ++ContextIter )
						{
							{
								const TSharedPtr<FArchiveEntry> ArchiveEntry = InternationalizationArchive->FindEntryBySource( Namespace, Source, ContextIter->KeyMetadataObj );
							if( ArchiveEntry.IsValid() )
							{
								const FString ConditionedArchiveSource = ConditionArchiveStrForPo(ArchiveEntry->Source.Text);
								const FString ConditionedArchiveTranslation = ConditionArchiveStrForPo(ArchiveEntry->Translation.Text);

								TSharedRef<FPortableObjectEntry> PoEntry = MakeShareable( new FPortableObjectEntry );
								//@TODO: We support additional metadata entries that can be translated.  How do those fit in the PO file format?  Ex: isMature
								PoEntry->MsgId = ConditionedArchiveSource;
								//@TODO: Take into account optional entries and entries that differ by keymetadata.  Ex. Each optional entry needs a unique msgCtxt
								PoEntry->MsgCtxt = Namespace;
								PoEntry->MsgStr.Add( ConditionedArchiveTranslation );

								FString PORefString = ConvertSrcLocationToPORef( ContextIter->SourceLocation );
								PoEntry->AddReference( PORefString ); // Source location.
								PoEntry->AddExtractedComment( ContextIter->Key ); // "Notes from Programmer" in the form of the Key.
								PoEntry->AddExtractedComment( PORefString ); // "Notes from Programmer" in the form of the Source Location, since this comes in handy too and OneSky doesn't properly show references, only comments.
								PortableObj.AddEntry( PoEntry );
							}
						}

							if (CultureName != NativeCultureName)
							{
开发者ID:PickUpSU,项目名称:UnrealEngine4,代码行数:67,代码来源:InternationalizationExportCommandlet.cpp

示例3: DoExport


//.........这里部分代码省略.........
	}

	// Process the desired cultures
	for(int32 Culture = 0; Culture < CulturesToGenerate.Num(); Culture++)
	{
		// Load the archive
		const FString CultureName = CulturesToGenerate[Culture];
		const FString CulturePath = SourcePath / CultureName;
		FString ArchiveFileName = CulturePath / ArchiveName;
		TSharedPtr< FJsonObject > ArchiveJsonObject = NULL;

		if( FPaths::FileExists(ArchiveFileName) )
		{
			ArchiveJsonObject = ReadJSONTextFile( ArchiveFileName );

			FJsonInternationalizationArchiveSerializer ArchiveSerializer;
			TSharedRef< FInternationalizationArchive > InternationalizationArchive = MakeShareable( new FInternationalizationArchive );
			ArchiveSerializer.DeserializeArchive( ArchiveJsonObject.ToSharedRef(), InternationalizationArchive );

			{
				FPortableObjectFormatDOM NewPortableObject;

				FString LocLang;
				if( !NewPortableObject.SetLanguage( CultureName ) )
				{
					UE_LOG( LogInternationalizationExportCommandlet, Error, TEXT("Skipping export of loc language %s because it is not recognized."), *LocLang );
					continue;
				}

				NewPortableObject.SetProjectName( FPaths::GetBaseFilename( ManifestName ) );
				NewPortableObject.CreateNewHeader();

				{
					for(TManifestEntryBySourceTextContainer::TConstIterator ManifestIter = InternationalizationManifest->GetEntriesBySourceTextIterator(); ManifestIter; ++ManifestIter)
					{
						// Gather relevant info from manifest entry.
						const TSharedRef<FManifestEntry>& ManifestEntry = ManifestIter.Value();
						const FString& Namespace = ManifestEntry->Namespace;
						const FLocItem& Source = ManifestEntry->Source;

						// For each context, we may need to create a different or even multiple PO entries.
						for( auto ContextIter = ManifestEntry->Contexts.CreateConstIterator(); ContextIter; ++ContextIter )
						{
							const FContext& Context = *ContextIter;

							// Create the typical PO entry from the archive entry which matches the exact same namespace, source, and key metadata, if it exists.
							{
								const TSharedPtr<FArchiveEntry> ArchiveEntry = InternationalizationArchive->FindEntryBySource( Namespace, Source, Context.KeyMetadataObj );
								if( ArchiveEntry.IsValid() )
								{
									const FString ConditionedArchiveSource = ConditionArchiveStrForPo(ArchiveEntry->Source.Text);
									const FString ConditionedArchiveTranslation = ConditionArchiveStrForPo(ArchiveEntry->Translation.Text);

									TSharedRef<FPortableObjectEntry> PoEntry = MakeShareable( new FPortableObjectEntry );
									//@TODO: We support additional metadata entries that can be translated.  How do those fit in the PO file format?  Ex: isMature
									PoEntry->MsgId = ConditionedArchiveSource;
									PoEntry->MsgCtxt = ConditionIdentityForPOMsgCtxt(Namespace, Context.Key, Context.KeyMetadataObj);
									PoEntry->MsgStr.Add( ConditionedArchiveTranslation );

									const FString PORefString = ConvertSrcLocationToPORef( Context.SourceLocation );
									PoEntry->AddReference(PORefString); // Source location.

									PoEntry->AddExtractedComment( GetConditionedKeyForExtractedComment(Context.Key) ); // "Notes from Programmer" in the form of the Key.

									if (ShouldAddSourceLocationsAsComments)
									{
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:67,代码来源:InternationalizationExportCommandlet.cpp

示例4: RepairManifestAndArchives

void RepairManifestAndArchives(TSharedRef<FInternationalizationManifest> Manifest, TArray< TSharedRef<FInternationalizationArchive> > Archives)
{
	// Update source text if this manifest was saved before the escape sequence fixes.
	if (Manifest->GetFormatVersion() < FInternationalizationManifest::EFormatVersion::EscapeFixes)
	{
		TManifestEntryBySourceTextContainer::TConstIterator Iterator = Manifest->GetEntriesBySourceTextIterator();
		for(; Iterator; ++Iterator)
		{
			const FString& Source = Iterator.Key();
			const TSharedRef<FManifestEntry>& ManifestEntry = Iterator.Value();

			// Find double quotes and unescape them once.
			FLocItem UpdatedSource(ManifestEntry->Source);
			UpdatedSource.Text.ReplaceInline(TEXT("\\\""), TEXT("\""));

			TSharedRef<FManifestEntry> UpdatedManifestEntry = MakeShareable(new FManifestEntry(ManifestEntry->Namespace, UpdatedSource));
			UpdatedManifestEntry->Contexts = ManifestEntry->Contexts;

			Manifest->UpdateEntry(ManifestEntry, UpdatedManifestEntry);
		}
	}

	for (const TSharedRef<FInternationalizationArchive>& Archive : Archives)
	{
		// Update source text if this archive was saved before the escape sequence fixes.
		if (Archive->GetFormatVersion() < FInternationalizationArchive::EFormatVersion::EscapeFixes)
		{
			TArchiveEntryContainer::TConstIterator Iterator = Archive->GetEntryIterator();

			for (; Iterator; ++Iterator)
			{
				const FString& Source = Iterator.Key();
				const TSharedRef<FArchiveEntry>& ArchiveEntry = Iterator.Value();

				// Find double quotes and unescape them once.
				FLocItem UpdatedSource(ArchiveEntry->Source);
				UpdatedSource.Text.ReplaceInline(TEXT("\\\""), TEXT("\""));

				// Find double quotes and unescape them once.
				FLocItem UpdatedTranslation(ArchiveEntry->Translation);
				UpdatedTranslation.Text.ReplaceInline(TEXT("\\\""), TEXT("\""));

				TSharedRef<FArchiveEntry> UpdatedArchiveEntry = MakeShareable(new FArchiveEntry(ArchiveEntry->Namespace, UpdatedSource, UpdatedTranslation, ArchiveEntry->KeyMetadataObj, ArchiveEntry->bIsOptional));

				Archive->UpdateEntry(ArchiveEntry, UpdatedArchiveEntry);
			}
		}
	}

	const FRegexPattern Pattern(TEXT(".* - line \\d+"));

	TManifestEntryBySourceTextContainer::TConstIterator Iterator = Manifest->GetEntriesBySourceTextIterator();
	for(; Iterator; ++Iterator)
	{
		const FString& Source = Iterator.Key();
		const TSharedRef<FManifestEntry>& ManifestEntry = Iterator.Value();

		// Identify if this entry comes from source text only.
		bool AreAllContextsFromSource = ManifestEntry->Contexts.Num() > 0;
		for (const FContext& Context : ManifestEntry->Contexts)
		{
			FRegexMatcher Matcher(Pattern, Context.SourceLocation);
			AreAllContextsFromSource = Matcher.FindNext();

			if(!AreAllContextsFromSource)
			{
				break;
			}
		}

		// No updates needed for this entry if it isn't all from source.
		if(!AreAllContextsFromSource)
		{
			continue;
		}

		for (const TSharedRef<FInternationalizationArchive>& Archive : Archives)
		{
			// Update source text if this manifest was saved before the escape sequence fixes.
			if (Archive->GetFormatVersion() < FInternationalizationArchive::EFormatVersion::EscapeFixes)
			{
				const TSharedPtr<FArchiveEntry> ArchiveEntry = Archive->FindEntryBySource(ManifestEntry->Namespace, ManifestEntry->Source, /*KeyMetadataObj*/ nullptr);
				if (!ArchiveEntry.IsValid())
				{
					continue;
				}

				// Replace escape sequences with their associated character, once.
				FLocItem UpdatedSource(ArchiveEntry->Source);
				UpdatedSource.Text = UpdatedSource.Text.ReplaceEscapedCharWithChar();

				// Replace escape sequences with their associated character, once.
				FLocItem UpdatedTranslation(ArchiveEntry->Translation);
				UpdatedTranslation.Text = UpdatedTranslation.Text.ReplaceEscapedCharWithChar();

				TSharedRef<FArchiveEntry> UpdatedArchiveEntry = MakeShareable(new FArchiveEntry(ArchiveEntry->Namespace, UpdatedSource, UpdatedTranslation, ArchiveEntry->KeyMetadataObj, ArchiveEntry->bIsOptional));

				Archive->UpdateEntry(ArchiveEntry.ToSharedRef(), UpdatedArchiveEntry);
			}
		}
//.........这里部分代码省略.........
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:101,代码来源:RepairLocalizationDataCommandlet.cpp


注:本文中的TSharedRef::GetEntriesBySourceTextIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。