Class ParsingUtility
- Namespace
- TMPEffects.TextProcessing
- Assembly
- TMPEffects.dll
Utility methods for text processing and parsing.
public static class ParsingUtility
- Inheritance
-
ParsingUtility
- Inherited Members
Fields
ColorKeyWords
public static readonly ReadOnlyDictionary<string, Color> ColorKeyWords
Field Value
- ReadOnlyDictionary<string, Color>
Methods
GetNextTag(string, int, ref TagInfo, TagType)
Get the next tag in text
, starting from startIndex
.
public static bool GetNextTag(string text, int startIndex, ref ParsingUtility.TagInfo tag, ParsingUtility.TagType type = TagType.Open | TagType.Close)
Parameters
text
stringThe full string.
startIndex
intThe index to start the search from.
tag
ParsingUtility.TagInfoReference to a ParsingUtility.TagInfo. Will be set to the parsed tag if one is found.
type
ParsingUtility.TagTypeThe type of tag to get. Leave at default for either type.
Returns
- bool
true if a next tag was found; false otherwise.
GetTagParametersDict(string)
public static Dictionary<string, string> GetTagParametersDict(string tag)
Parameters
tag
string
Returns
IsTag(string, int, int, TagType)
Checks if the given string contains a substring starting at startIndex
, going up to maxIndex
, that is a well formed tag.
public static bool IsTag(string text, int startIndex, int maxIndex = -1, ParsingUtility.TagType type = TagType.Open | TagType.Close)
Parameters
text
stringThe string to check.
startIndex
intThe start index of the substring.
maxIndex
intThe end index of the substring. Leave at default to set to length of
text
.type
ParsingUtility.TagType
Returns
- bool
true if the given string contains a substring starting at
startIndex
, going up tomaxIndex
, that is a well formed tag; otherwise false.
IsTag(string, TagType)
Checks if the given string is a well formed tag (of the given type, if supplied).
public static bool IsTag(string tag, ParsingUtility.TagType type = TagType.Open | TagType.Close)
Parameters
tag
stringThe string to check.
type
ParsingUtility.TagTypeThe type of tag to check for. Leave default for either type.
Returns
- bool
true if the the given string is a tag (of the given type, if supplied); otherwise false.
StringToAnchor(string, out Vector2, IDictionary<string, Vector2>, IDictionary<string, Vector2>)
public static bool StringToAnchor(string str, out Vector2 result, IDictionary<string, Vector2> anchorKeywords = null, IDictionary<string, Vector2> vectorKeywords = null)
Parameters
str
stringresult
Vector2anchorKeywords
IDictionary<string, Vector2>vectorKeywords
IDictionary<string, Vector2>
Returns
StringToAnimationCurve(string, out AnimationCurve, IDictionary<string, AnimationCurve>)
public static bool StringToAnimationCurve(string str, out AnimationCurve result, IDictionary<string, AnimationCurve> keywords = null)
Parameters
str
stringresult
AnimationCurvekeywords
IDictionary<string, AnimationCurve>
Returns
StringToBool(string, out bool, IDictionary<string, bool>)
public static bool StringToBool(string str, out bool result, IDictionary<string, bool> keywords = null)
Parameters
str
stringresult
boolkeywords
IDictionary<string, bool>
Returns
StringToColor(string, out Color, IDictionary<string, Color>)
public static bool StringToColor(string str, out Color result, IDictionary<string, Color> keywords = null)
Parameters
str
stringresult
Colorkeywords
IDictionary<string, Color>
Returns
StringToFloat(string, out float, IDictionary<string, float>)
public static bool StringToFloat(string str, out float result, IDictionary<string, float> keywords = null)
Parameters
str
stringresult
floatkeywords
IDictionary<string, float>
Returns
StringToInt(string, out int, IDictionary<string, int>)
public static bool StringToInt(string str, out int result, IDictionary<string, int> keywords = null)
Parameters
str
stringresult
intkeywords
IDictionary<string, int>
Returns
StringToVector2(string, out Vector2, IDictionary<string, Vector2>)
public static bool StringToVector2(string str, out Vector2 result, IDictionary<string, Vector2> keywords = null)
Parameters
str
stringresult
Vector2keywords
IDictionary<string, Vector2>
Returns
StringToVector2Offset(string, out Vector2, IDictionary<string, Vector2>)
public static bool StringToVector2Offset(string str, out Vector2 result, IDictionary<string, Vector2> keywords = null)
Parameters
str
stringresult
Vector2keywords
IDictionary<string, Vector2>
Returns
StringToVector3(string, out Vector3, IDictionary<string, Vector3>)
public static bool StringToVector3(string str, out Vector3 result, IDictionary<string, Vector3> keywords = null)
Parameters
str
stringresult
Vector3keywords
IDictionary<string, Vector3>
Returns
StringToVector3Offset(string, out Vector3, IDictionary<string, Vector3>)
public static bool StringToVector3Offset(string str, out Vector3 result, IDictionary<string, Vector3> keywords = null)
Parameters
str
stringresult
Vector3keywords
IDictionary<string, Vector3>
Returns
StringToWaveOffsetType(string, out WaveOffsetType, IDictionary<string, WaveOffsetType>)
public static bool StringToWaveOffsetType(string str, out AnimationUtility.WaveOffsetType result, IDictionary<string, AnimationUtility.WaveOffsetType> keywords = null)
Parameters
str
stringresult
AnimationUtility.WaveOffsetTypekeywords
IDictionary<string, AnimationUtility.WaveOffsetType>
Returns
TryParseTag(string, int, int, ref TagInfo, TagType)
Attempt to parse a tag from the substring of text
given by startIndex
and endIndex
.
public static bool TryParseTag(string text, int startIndex, int endIndex, ref ParsingUtility.TagInfo tag, ParsingUtility.TagType type = TagType.Open | TagType.Close)
Parameters
text
stringThe full string.
startIndex
intStart index of the substring.
endIndex
intEnd index of the substring.
tag
ParsingUtility.TagInfoReference to a ParsingUtility.TagInfo. Will be set to the parsed tag if successful.
type
ParsingUtility.TagTypeThe type of tag to check for. Leave at default for either type.
Returns
- bool
true if a tag was successfully parsed from the substring; false otherwise.