本文整理汇总了C++中TArray::Emplace方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::Emplace方法的具体用法?C++ TArray::Emplace怎么用?C++ TArray::Emplace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::Emplace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TokenizeString
void FICUCamelCaseBreakIterator::TokenizeString(TArray<FToken>& OutTokens)
{
OutTokens.Empty(String.Len());
FICUTextCharacterIterator CharIter(String);
for(CharIter.setToStart(); CharIter.current32() != FICUTextCharacterIterator::DONE; CharIter.next32PostInc())
{
const UChar32 CurrentChar = CharIter.current32();
ETokenType TokenType = ETokenType::Other;
if(u_isULowercase(CurrentChar))
{
TokenType = ETokenType::Lowercase;
}
else if(u_isUUppercase(CurrentChar))
{
TokenType = ETokenType::Uppercase;
}
else if(u_isdigit(CurrentChar))
{
TokenType = ETokenType::Digit;
}
const int32 CharIndex = CharIter.InternalIndexToSourceIndex(CharIter.getIndex());
OutTokens.Emplace(FToken(TokenType, CharIndex));
}
OutTokens.Emplace(FToken(ETokenType::Null, String.Len()));
// There should always be at least one token for the end of the string
check(OutTokens.Num());
}
示例2: FireEvent_FlushChatStats
virtual void FireEvent_FlushChatStats() override
{
if (AnalyticsProvider.IsValid())
{
IOnlineIdentityPtr OnlineIdentity = Online::GetIdentityInterface(TEXT("MCP"));
if (OnlineIdentity.IsValid())
{
TSharedPtr<const FUniqueNetId> UserId = OnlineIdentity->GetUniquePlayerId(0);
if (UserId.IsValid())
{
auto RecordSocialChatCountsEvents = [=](const TMap<FString, int32>& ChatCounts, const FString& ChatType)
{
if (ChatCounts.Num())
{
TArray<FAnalyticsEventAttribute> Attributes;
for (const auto& Pair : ChatCounts)
{
Attributes.Empty(3);
Attributes.Emplace(TEXT("Name"), Pair.Key);
Attributes.Emplace(TEXT("Type"), ChatType);
Attributes.Emplace(TEXT("Count"), Pair.Value);
AnalyticsProvider->RecordEvent("Social.Chat.Counts.2", Attributes);
}
}
};
RecordSocialChatCountsEvents(ChannelChatCounts, TEXT("Channel"));
RecordSocialChatCountsEvents(PrivateChatCounts, TEXT("Private"));
}
}
}
ChannelChatCounts.Empty();
PrivateChatCounts.Empty();
}
示例3: OnExit
void FAssetEditorManager::OnExit()
{
SaveOpenAssetEditors(true);
TGuardValue<bool> GuardOnShutdown(bSavingOnShutdown, true);
CloseAllAssetEditors();
// Don't attempt to report usage stats if analytics isn't available
if (FEngineAnalytics::IsAvailable())
{
TArray<FAnalyticsEventAttribute> EditorUsageAttribs;
EditorUsageAttribs.Empty(2);
for (auto Iter = EditorUsageAnalytics.CreateConstIterator(); Iter; ++Iter)
{
const FAssetEditorAnalyticInfo& Data = Iter.Value();
EditorUsageAttribs.Reset();
EditorUsageAttribs.Emplace(TEXT("TotalDuration.Seconds"), FString::Printf(TEXT("%.1f"), Data.SumDuration.GetTotalSeconds()));
EditorUsageAttribs.Emplace(TEXT("OpenedInstances.Count"), FString::Printf(TEXT("%d"), Data.NumTimesOpened));
const FString EventName = FString::Printf(TEXT("Editor.Usage.%s"), *Iter.Key().ToString());
FEngineAnalytics::GetProvider().RecordEvent(EventName, EditorUsageAttribs);
}
}
}
示例4: TokenizeString
void FLegacyCamelCaseBreakIterator::TokenizeString(TArray<FToken>& OutTokens)
{
OutTokens.Empty(String.Len());
for(int32 CurrentCharIndex = 0; CurrentCharIndex < String.Len(); ++CurrentCharIndex)
{
const TCHAR CurrentChar = String[CurrentCharIndex];
ETokenType TokenType = ETokenType::Other;
if(FChar::IsLower(CurrentChar))
{
TokenType = ETokenType::Lowercase;
}
else if(FChar::IsUpper(CurrentChar))
{
TokenType = ETokenType::Uppercase;
}
else if(FChar::IsDigit(CurrentChar))
{
TokenType = ETokenType::Digit;
}
OutTokens.Emplace(FToken(TokenType, CurrentCharIndex));
}
OutTokens.Emplace(FToken(ETokenType::Null, String.Len()));
// There should always be at least one token for the end of the string
check(OutTokens.Num());
}
示例5: MakeShareable
TSharedRef< FRichTextSyntaxHighlighterTextLayoutMarshaller > FRichTextSyntaxHighlighterTextLayoutMarshaller::Create(const FSyntaxTextStyle& InSyntaxTextStyle)
{
TArray<FSyntaxTokenizer::FRule> TokenizerRules;
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(TEXT("</>")));
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(TEXT("<")));
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(TEXT(">")));
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(TEXT("=")));
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(TEXT("\"")));
return MakeShareable(new FRichTextSyntaxHighlighterTextLayoutMarshaller(FSyntaxTokenizer::Create(TokenizerRules), InSyntaxTextStyle));
}
示例6: Tick
bool FHttpServiceTracker::Tick(float DeltaTime)
{
// flush events at the specified interval.
if (FPlatformTime::Seconds() > NextFlushTime)
{
if (AnalyticsProvider.IsValid())
{
TArray<FAnalyticsEventAttribute> Attrs;
Attrs.Reserve(10);
// one event per endpoint.
for (const auto& MetricsMapPair : EndpointMetricsMap)
{
Attrs.Reset();
Attrs.Emplace(TEXT("DomainName"), MetricsMapPair.Value.LastAnalyticsName);
Attrs.Emplace(TEXT("FailCount"), MetricsMapPair.Value.FailCount);
Attrs.Emplace(TEXT("SuccessCount"), MetricsMapPair.Value.SuccessCount);
// We may have had no successful requests, so these values would be undefined.
if (MetricsMapPair.Value.SuccessCount > 0)
{
Attrs.Emplace(TEXT("DownloadBytesSuccessTotal"), MetricsMapPair.Value.DownloadBytesSuccessTotal);
Attrs.Emplace(TEXT("ElapsedTimeSuccessTotal"), MetricsMapPair.Value.ElapsedTimeSuccessTotal);
Attrs.Emplace(TEXT("ElapsedTimeSuccessMin"), MetricsMapPair.Value.ElapsedTimeSuccessMin);
Attrs.Emplace(TEXT("ElapsedTimeSuccessMax"), MetricsMapPair.Value.ElapsedTimeSuccessMax);
}
if (MetricsMapPair.Value.FailCount > 0)
{
Attrs.Emplace(TEXT("DownloadBytesFailTotal"), MetricsMapPair.Value.DownloadBytesFailTotal);
Attrs.Emplace(TEXT("ElapsedTimeFailTotal"), MetricsMapPair.Value.ElapsedTimeFailTotal);
Attrs.Emplace(TEXT("ElapsedTimeFailMin"), MetricsMapPair.Value.ElapsedTimeFailMin);
Attrs.Emplace(TEXT("ElapsedTimeFailMax"), MetricsMapPair.Value.ElapsedTimeFailMax);
}
// one attribute per response code.
for (const auto& ResponseCodeMapPair : MetricsMapPair.Value.ResponseCodes)
{
Attrs.Emplace(FString(TEXT("Code-")) + LexicalConversion::ToString(ResponseCodeMapPair.Key), ResponseCodeMapPair.Value);
}
AnalyticsProvider->RecordEvent(MetricsMapPair.Key.ToString(), Attrs);
}
// force an immediate flush always. We already summarized.
AnalyticsProvider->FlushEvents();
}
EndpointMetricsMap.Reset();
NextFlushTime += FlushIntervalSec;
}
return true;
}
示例7:
TArray<FPathAndMountPoint> FAutoReimportManager::GetMonitoredDirectories() const
{
TArray<FPathAndMountPoint> Dirs;
for (const auto& Monitor : DirectoryMonitors)
{
Dirs.Emplace(Monitor.GetDirectory(), Monitor.GetMountPoint());
}
return Dirs;
}
示例8: ExecuteFixUp
void FAssetFixUpRedirectors::ExecuteFixUp(TArray<TWeakObjectPtr<UObjectRedirector>> Objects) const
{
TArray<FRedirectorRefs> RedirectorRefsList;
for (auto Object : Objects)
{
auto ObjectRedirector = Object.Get();
if (ObjectRedirector)
{
RedirectorRefsList.Emplace(ObjectRedirector);
}
}
if ( RedirectorRefsList.Num() > 0 )
{
// Gather all referencing packages for all redirectors that are being fixed.
PopulateRedirectorReferencers(RedirectorRefsList);
// Update Package Status for all selected redirectors if SCC is enabled
if ( UpdatePackageStatus(RedirectorRefsList) )
{
// Load all referencing packages.
TArray<UPackage*> ReferencingPackagesToSave;
LoadReferencingPackages(RedirectorRefsList, ReferencingPackagesToSave);
// Prompt to check out all referencing packages, leave redirectors for assets referenced by packages that are not checked out and remove those packages from the save list.
const bool bUserAcceptedCheckout = CheckOutReferencingPackages(RedirectorRefsList, ReferencingPackagesToSave);
if ( bUserAcceptedCheckout )
{
// If any referencing packages are left read-only, the checkout failed or SCC was not enabled. Trim them from the save list and leave redirectors.
DetectReadOnlyPackages(RedirectorRefsList, ReferencingPackagesToSave);
// Fix up referencing FStringAssetReferences
FixUpStringAssetReferences(RedirectorRefsList, ReferencingPackagesToSave);
// Save all packages that were referencing any of the assets that were moved without redirectors
TArray<UPackage*> FailedToSave;
SaveReferencingPackages(ReferencingPackagesToSave, FailedToSave);
// Save any collections that were referencing any of the redirectors
SaveReferencingCollections(RedirectorRefsList);
// Wait for package referencers to be updated
UpdateAssetReferencers(RedirectorRefsList);
// Delete any redirectors that are no longer referenced
DeleteRedirectors(RedirectorRefsList, FailedToSave);
// Finally, report any failures that happened during the rename
ReportFailures(RedirectorRefsList);
}
}
}
}
示例9: SetUpDirectoryMonitors
void FAutoReimportManager::SetUpDirectoryMonitors()
{
struct FParsedSettings
{
FString SourceDirectory;
FString MountPoint;
FMatchRules Rules;
};
TArray<FParsedSettings> FinalArray;
auto SupportedExtensions = GetAllFactoryExtensions();
for (const auto& Setting : GetDefault<UEditorLoadingSavingSettings>()->AutoReimportDirectorySettings)
{
FParsedSettings NewMapping;
NewMapping.SourceDirectory = Setting.SourceDirectory;
NewMapping.MountPoint = Setting.MountPoint;
if (!FAutoReimportDirectoryConfig::ParseSourceDirectoryAndMountPoint(NewMapping.SourceDirectory, NewMapping.MountPoint))
{
continue;
}
// Only include extensions that match a factory
NewMapping.Rules.SetApplicableExtensions(SupportedExtensions);
for (const auto& WildcardConfig : Setting.Wildcards)
{
NewMapping.Rules.AddWildcardRule(WildcardConfig.Wildcard, WildcardConfig.bInclude);
}
FinalArray.Add(NewMapping);
}
for (int32 Index = 0; Index < FinalArray.Num(); ++Index)
{
const auto& Mapping = FinalArray[Index];
// We only create a directory monitor if there are no other's watching parent directories of this one
for (int32 OtherIndex = Index + 1; OtherIndex < FinalArray.Num(); ++OtherIndex)
{
if (FinalArray[Index].SourceDirectory.StartsWith(FinalArray[OtherIndex].SourceDirectory))
{
UE_LOG(LogAutoReimportManager, Warning, TEXT("Unable to watch directory %s as it will conflict with another watching %s."), *FinalArray[Index].SourceDirectory, *FinalArray[OtherIndex].SourceDirectory);
goto next;
}
}
DirectoryMonitors.Emplace(Mapping.SourceDirectory, Mapping.Rules, Mapping.MountPoint);
next:
continue;
}
}
示例10: CalculateLineRanges
void FRichTextMarkupProcessing::CalculateLineRanges(const FString& Input, TArray<FTextRange>& LineRanges) const
{
// Iterate over each line break candidate, adding ranges from after the end of the last line added to before the newline or end of string.
FLineBreakIterator LBI(Input);
int32 RangeBegin = LBI.GetCurrentPosition();
for(;;)
{
const int32 BreakIndex = LBI.MoveToNext();
// If beginning or potential end is invalid, cease.
if(RangeBegin == INDEX_NONE || BreakIndex == INDEX_NONE)
{
break;
}
const int32 BreakingCharacterIndex = BreakIndex - 1;
if(BreakingCharacterIndex >= RangeBegin) // Valid index check.
{
const TCHAR BreakingCharacter = Input[BreakingCharacterIndex];
// If line break candidate is after a newline, add the range as a new line.
if(FChar::IsLinebreak(BreakingCharacter))
{
LineRanges.Emplace( FTextRange(RangeBegin, BreakingCharacterIndex) );
}
// If the line break candidate is the end of the string, add the range as a new line.
else if(BreakIndex == Input.Len())
{
LineRanges.Emplace( FTextRange(RangeBegin, BreakIndex) );
}
else
{
continue;
}
RangeBegin = BreakIndex; // The next line begins after the end of the current line.
}
}
}
示例11: MakeShareable
TSharedRef< FCPPRichTextSyntaxHighlighterTextLayoutMarshaller > FCPPRichTextSyntaxHighlighterTextLayoutMarshaller::Create(const FSyntaxTextStyle& InSyntaxTextStyle)
{
TArray<FSyntaxTokenizer::FRule> TokenizerRules;
// operators
for(const auto& Operator : Operators)
{
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(Operator));
}
// keywords
for(const auto& Keyword : Keywords)
{
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(Keyword));
}
// Pre-processor Keywords
for(const auto& PreProcessorKeyword : PreProcessorKeywords)
{
TokenizerRules.Emplace(FSyntaxTokenizer::FRule(PreProcessorKeyword));
}
return MakeShareable(new FCPPRichTextSyntaxHighlighterTextLayoutMarshaller(FSyntaxTokenizer::Create(TokenizerRules), InSyntaxTextStyle));
}
示例12: BeginPlay
// Called when the game starts or when spawned
void ABot::BeginPlay()
{
progression = new FParagonProgression();
TArray<Goal*> goals;
Goal *g1 = new Goal_Exp(((FParagonProgression*)progression)->getExpForNextLevel());
Goal *g2 = new Goal_Gold(((FParagonProgression*)progression)->gold);
goals.Emplace(g1);
goals.Emplace(g2);
worldModel = WorldModel(goals);
planner = new ActionPlanner();
Super::BeginPlay();
}
示例13: SetText
void FPlainTextLayoutMarshaller::SetText(const FString& SourceString, FTextLayout& TargetTextLayout)
{
const FTextBlockStyle& DefaultTextStyle = static_cast<FSlateTextLayout&>(TargetTextLayout).GetDefaultTextStyle();
TArray<FTextRange> LineRanges;
FTextRange::CalculateLineRangesFromString(SourceString, LineRanges);
TArray<FTextLayout::FNewLineData> LinesToAdd;
LinesToAdd.Reserve(LineRanges.Num());
TArray<FTextLineHighlight> LineHighlightsToAdd;
TSharedPtr<FSlateTextUnderlineLineHighlighter> UnderlineLineHighlighter;
if (!DefaultTextStyle.UnderlineBrush.GetResourceName().IsNone())
{
UnderlineLineHighlighter = FSlateTextUnderlineLineHighlighter::Create(DefaultTextStyle.UnderlineBrush, DefaultTextStyle.Font, DefaultTextStyle.ColorAndOpacity, DefaultTextStyle.ShadowOffset, DefaultTextStyle.ShadowColorAndOpacity);
}
const bool bUsePasswordRun = bIsPassword.Get(false);
for (int32 LineIndex = 0; LineIndex < LineRanges.Num(); ++LineIndex)
{
const FTextRange& LineRange = LineRanges[LineIndex];
TSharedRef<FString> LineText = MakeShareable(new FString(SourceString.Mid(LineRange.BeginIndex, LineRange.Len())));
TArray<TSharedRef<IRun>> Runs;
if (bUsePasswordRun)
{
Runs.Add(FSlatePasswordRun::Create(FRunInfo(), LineText, DefaultTextStyle));
}
else
{
Runs.Add(FSlateTextRun::Create(FRunInfo(), LineText, DefaultTextStyle));
}
if (UnderlineLineHighlighter.IsValid())
{
LineHighlightsToAdd.Add(FTextLineHighlight(LineIndex, FTextRange(0, LineRange.Len()), FSlateTextUnderlineLineHighlighter::DefaultZIndex, UnderlineLineHighlighter.ToSharedRef()));
}
LinesToAdd.Emplace(MoveTemp(LineText), MoveTemp(Runs));
}
TargetTextLayout.AddLines(LinesToAdd);
TargetTextLayout.SetLineHighlights(LineHighlightsToAdd);
}
示例14: CoefficientTotal
TArray<FLayoutGeometry> SSplitter2x2::ArrangeChildrenForLayout( const FGeometry& AllottedGeometry ) const
{
check( Children.Num() == 4 );
TArray<FLayoutGeometry> Result;
Result.Empty(Children.Num());
int32 NumNonCollapsedChildren = 0;
FVector2D CoefficientTotal(0,0);
// The allotted space for our children is our geometry minus a little space to show splitter handles
const FVector2D SpaceAllottedForChildren = AllottedGeometry.Size - FVector2D(SplitterHandleSize,SplitterHandleSize);
// The current offset that the next child should be positioned at.
FVector2D Offset(0,0);
for (int32 ChildIndex=0; ChildIndex < Children.Num(); ++ChildIndex)
{
const FSlot& CurSlot = Children[ChildIndex];
// Calculate the amount of space that this child should take up.
// It is based on the current percentage of space it should take up which is defined by a user moving the splitters
const FVector2D ChildSpace = SpaceAllottedForChildren * CurSlot.PercentageAttribute.Get();
// put them in their spot
Result.Emplace(FSlateLayoutTransform(Offset), ChildSpace);
// Advance to the next slot. If the child is collapsed, it takes up no room and does not need a splitter
if( ChildIndex == 1 )
{
// ChildIndex of 1 means we are starting the next column so reset the Y offset.
Offset.Y = 0.0f;
Offset += FVector2D( ChildSpace.X + SplitterHandleSize, 0);
}
else
{
Offset += FVector2D( 0, ChildSpace.Y + SplitterHandleSize );
}
}
return Result;
}
示例15: ExtractAssetImportInfo
TArray<FAssetData> FAssetSourceFilenameCache::GetAssetsPertainingToFile(const IAssetRegistry& Registry, const FString& AbsoluteFilename) const
{
TArray<FAssetData> Assets;
if (const auto* ObjectPaths = SourceFileToObjectPathCache.Find(FPaths::GetCleanFilename(AbsoluteFilename)))
{
for (const FName& Path : *ObjectPaths)
{
FAssetData Asset = Registry.GetAssetByObjectPath(Path);
TOptional<FAssetImportInfo> ImportInfo = ExtractAssetImportInfo(Asset.TagsAndValues);
if (ImportInfo.IsSet())
{
auto AssetPackagePath = FPackageName::LongPackageNameToFilename(Asset.PackagePath.ToString() / TEXT(""));
// Attempt to find the matching source filename in the list of imported sorce files (generally there are only one of these)
const bool bWasImportedFromFile = ImportInfo->SourceFiles.ContainsByPredicate([&](const FAssetImportInfo::FSourceFile& File){
if (AbsoluteFilename == FPaths::ConvertRelativePathToFull(AssetPackagePath / File.RelativeFilename) ||
AbsoluteFilename == FPaths::ConvertRelativePathToFull(File.RelativeFilename))
{
return true;
}
return false;
});
if (bWasImportedFromFile)
{
Assets.Emplace();
Swap(Asset, Assets[Assets.Num() - 1]);
}
}
}
}
return Assets;
}