You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system. A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization. UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path. An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName #rb david.bromberg, ludovic.chabant, Max.Chen [CL 29714989 by andrew rodham in ue5-main branch]
81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreTypes.h"
|
|
#include "Containers/StringView.h"
|
|
#include "Misc/EnumClassFlags.h"
|
|
#include "Internationalization/Text.h"
|
|
|
|
namespace UE::UniversalObjectLocator
|
|
{
|
|
|
|
enum class EParseStringFlags : uint8
|
|
{
|
|
None = 0,
|
|
|
|
/** Whether the user desires error messages to be emited */
|
|
ErrorMessaging = 1 << 0,
|
|
};
|
|
ENUM_CLASS_FLAGS(EParseStringFlags)
|
|
|
|
/**
|
|
* String parameter structure specifying additional information required for a string to be parsed
|
|
*/
|
|
struct FParseStringParams
|
|
{
|
|
/** Parse flags */
|
|
EParseStringFlags Flags;
|
|
|
|
bool NeedsErrorMessaging() const
|
|
{
|
|
return EnumHasAnyFlags(Flags, EParseStringFlags::ErrorMessaging);
|
|
}
|
|
};
|
|
|
|
#define UE_UOL_PARSE_ERROR(InParams, ...) InParams.NeedsErrorMessaging() ? (__VA_ARGS__) : FText()
|
|
|
|
/**
|
|
* String parse result structure, specfying success/failure, number of characters that were parsed, and
|
|
* any error information.
|
|
*/
|
|
struct FParseStringResult
|
|
{
|
|
/** Optional error message, only populated when FParseStringParams::bWantsErrorMessaging is true */
|
|
FText ErrorMessage;
|
|
|
|
/** The number of characters that were parsed.
|
|
* On Success this indicates the last character that resulted in the successful parse,
|
|
* on failure, this may be 0, or the point at which parsing finished */
|
|
int32 NumCharsParsed = 0;
|
|
|
|
/** Whether parsing was successful or not */
|
|
bool bSuccess = false;
|
|
|
|
explicit operator bool() const
|
|
{
|
|
return bSuccess;
|
|
}
|
|
|
|
FParseStringResult& Success(int32 AdditionalNumCharsParsed = 0)
|
|
{
|
|
NumCharsParsed += AdditionalNumCharsParsed;
|
|
bSuccess = true;
|
|
return *this;
|
|
}
|
|
|
|
FParseStringResult& Failure(const FText& InFailureText)
|
|
{
|
|
if (!InFailureText.IsEmpty())
|
|
{
|
|
// Only overwrite the error message if it's supplied
|
|
ErrorMessage = InFailureText;
|
|
}
|
|
bSuccess = false;
|
|
return *this;
|
|
}
|
|
|
|
UNIVERSALOBJECTLOCATOR_API FStringView Progress(FStringView CurrentString, int32 NumToProgress);
|
|
};
|
|
|
|
} // namespace UE::UniversalObjectLocator
|