Browse Source

Refactor text classes to subclass on `BaseText`

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
1e62edfc93
  1. 14
      sources/Aliases/AliasSource.uc
  2. 8
      sources/Aliases/Aliases.uc
  3. 8
      sources/Aliases/AliasesAPI.uc
  4. 2
      sources/Avarice/AvariceAPI.uc
  5. 11
      sources/Avarice/AvariceLink.uc
  6. 4
      sources/Avarice/AvariceTcpStream.uc
  7. 2
      sources/Chat/ChatAPI.uc
  8. 5
      sources/Chat/Events/ChatAPI_OnMessageFor_Signal.uc
  9. 2
      sources/Chat/Events/ChatAPI_OnMessageFor_Slot.uc
  10. 6
      sources/Color/ColorAPI.uc
  11. 2
      sources/Commands/BuiltInCommands/ACommandHelp.uc
  12. 10
      sources/Commands/Command.uc
  13. 94
      sources/Commands/CommandDataBuilder.uc
  14. 8
      sources/Commands/CommandParser.uc
  15. 2
      sources/Commands/Commands.uc
  16. 2
      sources/Commands/Commands_Feature.uc
  17. 10
      sources/Commands/PlayersParser.uc
  18. 12
      sources/Config/AcediaConfig.uc
  19. 21
      sources/Console/ConsoleBuffer.uc
  20. 8
      sources/Console/ConsoleWriter.uc
  21. 2
      sources/Data/Collections/AssociativeArray.uc
  22. 18
      sources/Data/Collections/Collection.uc
  23. 2
      sources/Data/Collections/DynamicArray.uc
  24. 14
      sources/Data/Database/DBAPI.uc
  25. 6
      sources/Data/Database/Local/DBRecord.uc
  26. 4
      sources/Data/Database/Local/LocalDatabase.uc
  27. 2
      sources/Data/Database/Tests/TEST_LocalDatabase.uc
  28. 15
      sources/Features/Feature.uc
  29. 2
      sources/Features/FeatureConfig.uc
  30. 4
      sources/Gameplay/BaseClasses/Frontend/Templates/ATemplatesComponent.uc
  31. 2
      sources/Gameplay/BaseClasses/KillingFloor/Frontend/KFFrontend.uc
  32. 2
      sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ATradingComponent.uc
  33. 2
      sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ETrader.uc
  34. 2
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFAmmo.uc
  35. 2
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFFlashlightAmmo.uc
  36. 16
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFInventory.uc
  37. 2
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFMedicAmmo.uc
  38. 2
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFSyringeAmmo.uc
  39. 2
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFUnknownItem.uc
  40. 2
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFWeapon.uc
  41. 2
      sources/Gameplay/KF1Frontend/KF1_Frontend.uc
  42. 4
      sources/Gameplay/KF1Frontend/Templates/KF1_TemplatesComponent.uc
  43. 4
      sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc
  44. 2
      sources/Gameplay/KF1Frontend/Trading/KF1_TradingComponent.uc
  45. 2
      sources/Logger/ConsoleLogger.uc
  46. 16
      sources/Logger/LogMessage.uc
  47. 4
      sources/Logger/Logger.uc
  48. 12
      sources/Logger/LoggerAPI.uc
  49. 6
      sources/Memory/MemoryAPI.uc
  50. 12
      sources/Players/EPlayer.uc
  51. 2
      sources/Players/Events/PlayerAPI_OnPlayerNameChanged_Signal.uc
  52. 2
      sources/Players/Events/PlayerAPI_OnPlayerNameChanged_Slot.uc
  53. 4
      sources/Players/Events/PlayerAPI_OnPlayerNameChanging_Signal.uc
  54. 2
      sources/Players/Events/PlayerAPI_OnPlayerNameChanging_Slot.uc
  55. 18
      sources/Players/Inventory/EInventory.uc
  56. 2
      sources/Players/Inventory/EItem.uc
  57. 6
      sources/Players/PlayersAPI.uc
  58. 1578
      sources/Text/BaseText.uc
  59. 2
      sources/Text/Codecs/Utf8Decoder.uc
  60. 2
      sources/Text/Codecs/Utf8Encoder.uc
  61. 8
      sources/Text/FormattedStrings/FormattingCommandsSequence.uc
  62. 4
      sources/Text/FormattedStrings/FormattingErrorsReport.uc
  63. 21
      sources/Text/FormattedStrings/FormattingStringParser.uc
  64. 31
      sources/Text/JSON/JSONAPI.uc
  65. 6
      sources/Text/JSON/JSONPointer.uc
  66. 95
      sources/Text/MutableText.uc
  67. 92
      sources/Text/Parser.uc
  68. 4
      sources/Text/Tests/TEST_FormattedStrings.uc
  69. BIN
      sources/Text/Tests/TEST_Parser.uc
  70. BIN
      sources/Text/Tests/TEST_Text.uc
  71. BIN
      sources/Text/Tests/TEST_TextAPI.uc
  72. BIN
      sources/Text/Tests/TEST_UTF8EncoderDecoder.uc
  73. 1475
      sources/Text/Text.uc
  74. 153
      sources/Text/TextAPI.uc
  75. 8
      sources/Users/User.uc
  76. 2
      sources/Users/UserAPI.uc
  77. 2
      sources/Users/UserDatabase.uc
  78. 4
      sources/Users/UserID.uc

14
sources/Aliases/AliasSource.uc

@ -123,7 +123,7 @@ private final function HashValidAliasesFromPerObjectConfig()
// they already exist.
// Takes care of lower case conversion to store aliases in `aliasHash`
// in a case-insensitive way.
private final function InsertAlias(Text alias, Text value)
private final function InsertAlias(BaseText alias, BaseText value)
{
local Text aliasLowerCaseCopy;
local AssociativeArray.Entry hashEntry;
@ -145,7 +145,7 @@ private final function InsertAlias(Text alias, Text value)
* @param alias Alias to check, case-insensitive.
* @return `true` if present, `false` otherwise.
*/
public function bool HasAlias(Text alias)
public function bool HasAlias(BaseText alias)
{
local bool result;
local Text lowerCaseAlias;
@ -174,7 +174,7 @@ public function bool HasAlias(Text alias)
* and `copyOnFailure == true` means method will return `alias.Copy()`.
* If `alias == none` method always returns `none`.
*/
public function Text Resolve(Text alias, optional bool copyOnFailure)
public function Text Resolve(BaseText alias, optional bool copyOnFailure)
{
local Text result;
local Text lowerCaseAlias;
@ -273,7 +273,7 @@ public final function bool AddAlias(
*
* @param aliasToRemove Alias that you want to remove from caller source.
*/
public final function RemoveAlias(Text aliasToRemove)
public final function RemoveAlias(BaseText aliasToRemove)
{
local int i;
local bool isMatchingRecord;
@ -308,7 +308,9 @@ public final function RemoveAlias(Text aliasToRemove)
}
}
private final function LogDuplicateAliasWarning(Text alias, Text existingValue)
private final function LogDuplicateAliasWarning(
BaseText alias,
BaseText existingValue)
{
_.logger.Auto(warnDuplicateAlias)
.ArgClass(class)
@ -319,7 +321,7 @@ private final function LogDuplicateAliasWarning(Text alias, Text existingValue)
// Tries to find a loaded `Aliases` config object that stores aliases for
// the given value. If such object does not exists - creates a new one.
// Assumes `value != none`.
private final function Aliases GetAliasesObjectWithValue(Text value)
private final function Aliases GetAliasesObjectWithValue(BaseText value)
{
local int i;
local Text nextValue;

8
sources/Aliases/Aliases.uc

@ -48,7 +48,7 @@ var protected config array<string> alias;
// we need methods to convert between "storage" (`string`)
// and "actual" (`Text`) value version.
// `ToStorageVersion()` and `ToActualVersion()` do that.
private final static function string ToStorageVersion(Text actualValue)
private final static function string ToStorageVersion(BaseText actualValue)
{
return Repl(actualValue.ToString(), ".", ":");
}
@ -98,7 +98,7 @@ private static final function Aliases LoadObjectByName(string objectName)
* correspond to.
* @return Instance of `Aliases` object with a given name.
*/
public static final function Aliases LoadObject(Text aliasesValue)
public static final function Aliases LoadObject(BaseText aliasesValue)
{
if (aliasesValue != none) {
return LoadObjectByName(ToStorageVersion(aliasesValue));
@ -141,7 +141,7 @@ public final function array<Text> GetAliases()
* @param aliasToAdd Alias to add to caller `Aliases` object.
* If `none`, method will do nothing.
*/
public final function AddAlias(Text aliasToAdd)
public final function AddAlias(BaseText aliasToAdd)
{
local int i;
if (aliasToAdd == none) return;
@ -165,7 +165,7 @@ public final function AddAlias(Text aliasToAdd)
*
* @param aliasToRemove Alias to remove from caller `Aliases` object.
*/
public final function RemoveAlias(Text aliasToRemove)
public final function RemoveAlias(BaseText aliasToRemove)
{
local int i;
local bool removedAlias;

8
sources/Aliases/AliasesAPI.uc

@ -155,7 +155,7 @@ public final function AliasSource GetFeatureSource()
* If `alias == none` method always returns `none`.
*/
public final function Text ResolveWeapon(
Text alias,
BaseText alias,
optional bool copyOnFailure)
{
local AliasSource source;
@ -187,7 +187,9 @@ public final function Text ResolveWeapon(
* and `copyOnFailure == true` means method will return `alias.Copy()`.
* If `alias == none` method always returns `none`.
*/
public final function Text ResolveColor(Text alias, optional bool copyOnFailure)
public final function Text ResolveColor(
BaseText alias,
optional bool copyOnFailure)
{
local AliasSource source;
source = GetColorSource();
@ -219,7 +221,7 @@ public final function Text ResolveColor(Text alias, optional bool copyOnFailure)
* If `alias == none` method always returns `none`.
*/
public final function Text ResolveFeature(
Text alias,
BaseText alias,
optional bool copyOnFailure)
{
local AliasSource source;

2
sources/Avarice/AvariceAPI.uc

@ -47,7 +47,7 @@ public final function array<AvariceLink> GetAllLinks()
* If `linkName == none` or `AvariceLink` with such name does not exist -
* returns `none`.
*/
public final function AvariceLink GetLink(Text linkName)
public final function AvariceLink GetLink(BaseText linkName)
{
local int i;
local Text nextName;

11
sources/Avarice/AvariceLink.uc

@ -123,7 +123,7 @@ protected function Finalizer()
* @param name Port used by the Avarice instance that caller `AvariceLink`
* is connecting to.
*/
public final function Initialize(Text name, Text host, int port)
public final function Initialize(BaseText name, BaseText host, int port)
{
if (tcpStream != none) return;
if (name == none) return;
@ -198,12 +198,13 @@ public final function SimpleSlot OnDeath(AcediaObject receiver)
/* SIGNAL */
public final function Avarice_OnMessage_Slot OnMessage(
AcediaObject receiver,
Text service)
BaseText service)
{
return Avarice_OnMessage_Slot(GetServiceSignal(service).NewSlot(receiver));
}
private final function Avarice_OnMessage_Signal GetServiceSignal(Text service)
private final function Avarice_OnMessage_Signal GetServiceSignal(
BaseText service)
{
local Avarice_OnMessage_Signal result;
if (service != none) {
@ -370,8 +371,8 @@ public final function int GetPort()
* addressing make a reply.
*/
public final function bool SendMessage(
Text service,
Text type,
BaseText service,
BaseText type,
AcediaObject parameters)
{
local Mutabletext parametesAsJSON;

4
sources/Avarice/AvariceTcpStream.uc

@ -269,7 +269,7 @@ private final function HandleIncomingData()
_.memory.FreeMany(receivedMessages);
}
public final function SendMessage(Text textMessage)
public final function SendMessage(BaseText textMessage)
{
local int i;
local int nextByte;
@ -331,7 +331,7 @@ private final function SendReceived(int received)
SendBinary(3, buffer);
}
private final function AvariceMessage MessageFromText(Text message)
private final function AvariceMessage MessageFromText(BaseText message)
{
local Parser parser;
local AvariceMessage result;

2
sources/Chat/ChatAPI.uc

@ -80,7 +80,7 @@ public function ChatAPI_OnMessage_Slot OnMessage(
* also be interrupted.
*
* [Signature]
* bool <slot>(EPlayer receiver, EPlayer sender, Text message)
* bool <slot>(EPlayer receiver, EPlayer sender, BaseText message)
*
* @param receiver `EPlayer` that will receive the message.
* @param sender `EPlayer` that has sent the message.

5
sources/Chat/Events/ChatAPI_OnMessageFor_Signal.uc

@ -19,7 +19,10 @@
*/
class ChatAPI_OnMessageFor_Signal extends Signal;
public final function bool Emit(EPlayer receiver, EPlayer sender, Text message)
public final function bool Emit(
EPlayer receiver,
EPlayer sender,
BaseText message)
{
local Slot nextSlot;
local bool nextReply;

2
sources/Chat/Events/ChatAPI_OnMessageFor_Slot.uc

@ -19,7 +19,7 @@
*/
class ChatAPI_OnMessageFor_Slot extends Slot;
delegate bool connect(EPlayer receiver, EPlayer sender, Text message)
delegate bool connect(EPlayer receiver, EPlayer sender, BaseText message)
{
DummyCall();
return true;

6
sources/Color/ColorAPI.uc

@ -1026,7 +1026,7 @@ public final function bool ParseString(
* @return `true` if parsing was successful and false otherwise.
*/
public final function bool Parse(
Text textWithColor,
BaseText textWithColor,
out Color resultingColor)
{
local bool successfullyParsed;
@ -1051,8 +1051,8 @@ public final function bool Parse(
* @return `true` if resolving was successful and false otherwise.
*/
public final function bool ResolveShortTagColor(
Text.Character shortTag,
out Color resultingColor)
BaseText.Character shortTag,
out Color resultingColor)
{
local int i;
if (shortTag.codePoint <= 0) {

2
sources/Commands/BuiltInCommands/ACommandHelp.uc

@ -157,7 +157,7 @@ private final function PrintCommands(ConsoleWriter cout, Command.Data data)
private final function PrintSubCommand(
ConsoleWriter cout,
SubCommand subCommand,
Text commandName)
BaseText commandName)
{
// Command + parameters
// Command name + sub command name

10
sources/Commands/Command.uc

@ -24,7 +24,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class Command extends AcediaObject
dependson(Text);
dependson(BaseText);
/**
* Possible errors that can arise when parsing command parameters from
@ -149,7 +149,7 @@ struct SubCommand
// Options are independent from sub-commands.
struct Option
{
var Text.Character shortName;
var BaseText.Character shortName;
var Text longName;
var Text description;
// Option can also have their own parameters
@ -550,12 +550,12 @@ private final function array<EPlayer> ParseTargets(
return targetPlayers;
}
// TODO: This is a hack to insert new line symbol,
// this needs to be redone in a better way
private final function Text.Character GetNewLine(Text.Formatting formatting)
private final function BaseText.Character GetNewLine(
BaseText.Formatting formatting)
{
local Text.Character newLine;
local BaseText.Character newLine;
newLine.codePoint = 10;
newLine.formatting = formatting;
return newLine;

94
sources/Commands/CommandDataBuilder.uc

@ -95,7 +95,7 @@ protected function Finalizer()
// Find index of sub-command with a given name `name` in `subcommands`.
// `-1` if there's not sub-command with such name.
// Case-sensitive.
private final function int FindSubCommandIndex(Text name)
private final function int FindSubCommandIndex(BaseText name)
{
local int i;
if (name == none) {
@ -113,7 +113,7 @@ private final function int FindSubCommandIndex(Text name)
// Find index of option with a given name `name` in `options`.
// `-1` if there's not sub-command with such name.
// Case-sensitive.
private final function int FindOptionIndex(Text longName)
private final function int FindOptionIndex(BaseText longName)
{
local int i;
if (longName == none) {
@ -132,7 +132,7 @@ private final function int FindOptionIndex(Text longName)
// name (long name) `name`.
// Doe not check whether subcommand/option with that name already exists.
// Copies passed `name`, assumes that it is not `none`.
private final function MakeEmptySelection(Text name, bool selectedOption)
private final function MakeEmptySelection(BaseText name, bool selectedOption)
{
selectedItemIsOption = selectedOption;
selectedItemName = name.Copy();
@ -146,7 +146,7 @@ private final function MakeEmptySelection(Text name, bool selectedOption)
// creates new record in selection, otherwise copies previously saved data.
// Automatically saves previously selected data into prepared data.
// Copies `name` if it has to create new record.
private final function SelectSubCommand(Text name)
private final function SelectSubCommand(BaseText name)
{
local int subcommandIndex;
if (name == none) return;
@ -181,7 +181,7 @@ private final function SelectSubCommand(Text name)
// creates new record in selection, otherwise copies previously saved data.
// Automatically saves previously selected data into prepared data.
// Copies `name` if it has to create new record.
private final function SelectOption(Text longName)
private final function SelectOption(BaseText longName)
{
local int optionIndex;
if (longName == none) return;
@ -293,7 +293,7 @@ private final function RecordSelectedOption()
* @return Returns the caller `CommandDataBuilder` to allow for
* method chaining.
*/
public final function CommandDataBuilder SubCommand(Text name)
public final function CommandDataBuilder SubCommand(BaseText name)
{
SelectSubCommand(name);
return self;
@ -309,9 +309,9 @@ public final function CommandDataBuilder SubCommand(Text name)
// the option altogether.
// Returns `none` if validation failed and chosen short name otherwise
// (if `shortName` was used for it - it's value will be copied).
private final function Text.Character GetValidShortName(
Text longName,
Text shortName)
private final function BaseText.Character GetValidShortName(
BaseText longName,
BaseText shortName)
{
// Validate `longName`
if (longName == none) {
@ -341,8 +341,8 @@ private final function Text.Character GetValidShortName(
// i.e. we cannot have several options with identical names:
// (--silent, -s) and (--sick, -s).
private final function bool VerifyNoOptionNamingConflict(
Text longName,
Text.Character shortName)
BaseText longName,
BaseText.Character shortName)
{
local int i;
// To make sure we will search through the up-to-date `options`,
@ -397,11 +397,11 @@ private final function bool VerifyNoOptionNamingConflict(
* method chaining.
*/
public final function CommandDataBuilder Option(
Text longName,
optional Text shortName)
BaseText longName,
optional BaseText shortName)
{
local int optionIndex;
local Text.Character shortNameAsCharacter;
local int optionIndex;
local BaseText.Character shortNameAsCharacter;
// Unlike for `SubCommand()`, we need to ensure that option naming is
// correct and does not conflict with existing options
// (user might attempt to add two options with same long names and
@ -440,7 +440,7 @@ public final function CommandDataBuilder Option(
* @return Returns the caller `CommandDataBuilder` to allow for
* method chaining.
*/
public final function CommandDataBuilder Describe(Text description)
public final function CommandDataBuilder Describe(BaseText description)
{
if (selectedDescription == description) {
return self;
@ -459,7 +459,7 @@ public final function CommandDataBuilder Describe(Text description)
* @return Returns the caller `CommandDataBuilder` to allow for
* method chaining.
*/
public final function CommandDataBuilder Name(Text newName)
public final function CommandDataBuilder Name(BaseText newName)
{
if (newName != none && newName == commandName) {
return self;
@ -481,7 +481,7 @@ public final function CommandDataBuilder Name(Text newName)
* @return Returns the caller `CommandDataBuilder` to allow for
* method chaining.
*/
public final function CommandDataBuilder Summary(Text newSummary)
public final function CommandDataBuilder Summary(BaseText newSummary)
{
if (newSummary != none && newSummary == commandSummary) {
return self;
@ -561,10 +561,10 @@ private final function PushParameter(Command.Parameter newParameter)
// Fills `Command.ParameterType` struct with given values
// (except boolean format). Assumes `displayName != none`.
private final function Command.Parameter NewParameter(
Text displayName,
BaseText displayName,
Command.ParameterType parameterType,
bool isListParameter,
optional Text variableName)
optional BaseText variableName)
{
local Command.Parameter newParameter;
newParameter.displayName = displayName.Copy();
@ -574,7 +574,7 @@ private final function Command.Parameter NewParameter(
newParameter.variableName = variableName.Copy();
}
else {
newParameter.variableName = displayName;
newParameter.variableName = displayName.Copy();
}
return newParameter;
}
@ -601,9 +601,9 @@ private final function Command.Parameter NewParameter(
* method chaining.
*/
public final function CommandDataBuilder ParamBoolean(
Text name,
BaseText name,
optional Command.PreferredBooleanFormat format,
optional Text variableName)
optional BaseText variableName)
{
local Command.Parameter newParam;
if (name == none) {
@ -636,9 +636,9 @@ public final function CommandDataBuilder ParamBoolean(
* method chaining.
*/
public final function CommandDataBuilder ParamBooleanList(
Text name,
BaseText name,
optional Command.PreferredBooleanFormat format,
optional Text variableName)
optional BaseText variableName)
{
local Command.Parameter newParam;
if (name == none) {
@ -667,8 +667,8 @@ public final function CommandDataBuilder ParamBooleanList(
* method chaining.
*/
public final function CommandDataBuilder ParamInteger(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -694,8 +694,8 @@ public final function CommandDataBuilder ParamInteger(
* method chaining.
*/
public final function CommandDataBuilder ParamIntegerList(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -721,8 +721,8 @@ public final function CommandDataBuilder ParamIntegerList(
* method chaining.
*/
public final function CommandDataBuilder ParamNumber(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -748,8 +748,8 @@ public final function CommandDataBuilder ParamNumber(
* method chaining.
*/
public final function CommandDataBuilder ParamNumberList(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -775,8 +775,8 @@ public final function CommandDataBuilder ParamNumberList(
* method chaining.
*/
public final function CommandDataBuilder ParamText(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -802,8 +802,8 @@ public final function CommandDataBuilder ParamText(
* method chaining.
*/
public final function CommandDataBuilder ParamTextList(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -829,8 +829,8 @@ public final function CommandDataBuilder ParamTextList(
* method chaining.
*/
public final function CommandDataBuilder ParamRemainder(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -856,8 +856,8 @@ public final function CommandDataBuilder ParamRemainder(
* method chaining.
*/
public final function CommandDataBuilder ParamObject(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -883,8 +883,8 @@ public final function CommandDataBuilder ParamObject(
* method chaining.
*/
public final function CommandDataBuilder ParamObjectList(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -910,8 +910,8 @@ public final function CommandDataBuilder ParamObjectList(
* method chaining.
*/
public final function CommandDataBuilder ParamArray(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;
@ -937,8 +937,8 @@ public final function CommandDataBuilder ParamArray(
* method chaining.
*/
public final function CommandDataBuilder ParamArrayList(
Text name,
optional Text variableName)
BaseText name,
optional BaseText variableName)
{
if (name == none) {
return self;

8
sources/Commands/CommandParser.uc

@ -141,7 +141,7 @@ private final function Reset()
// Auxiliary method for recording errors
private final function DeclareError(
Command.ErrorType type,
optional Text cause)
optional BaseText cause)
{
nextResult.parsingError = type;
if (cause != none) {
@ -764,9 +764,9 @@ private final function bool ParseShortOption()
// `nextError.DeclareError()` call, so you can use `nextResult.IsSuccessful()`
// to check if method has failed.
private final function bool AddOptionByCharacter(
Text.Character optionCharacter,
Text optionSourceList,
bool forbidOptionWithParameters)
BaseText.Character optionCharacter,
BaseText optionSourceList,
bool forbidOptionWithParameters)
{
local int i;
local bool optionHasParameters;

2
sources/Commands/Commands.uc

@ -44,7 +44,7 @@ protected function FromData(AssociativeArray source)
}
useChatInput = source.GetBool(P("useChatInput"));
useMutateInput = source.GetBool(P("useMutateInput"));
newChatPrefix = source.GetText(P("chatCommandPrefix"));
newChatPrefix = source.GetText(P("chatCommandPrefix"));
chatCommandPrefix = "!";
if (newChatPrefix != none) {
chatCommandPrefix = newChatPrefix.ToString();

2
sources/Commands/Commands_Feature.uc

@ -185,7 +185,7 @@ public final function RemoveCommand(class<Command> commandClass)
* @return Command, registered with a given name `commandName`.
* If no command with such name was registered - returns `none`.
*/
public final function Command GetCommand(Text commandName)
public final function Command GetCommand(BaseText commandName)
{
local Text commandNameLowerCase;
local Command commandInstance;

10
sources/Commands/PlayersParser.uc

@ -153,7 +153,7 @@ private final function RemoveByKey(int key)
}
// Adds all the players with specified name (`name`) to the current selection.
private final function AddByName(Text name)
private final function AddByName(BaseText name)
{
local int i;
local Text nextPlayerName;
@ -170,7 +170,7 @@ private final function AddByName(Text name)
// Removes all the players with specified name (`name`) from
// the current selection.
private final function RemoveByName(Text name)
private final function RemoveByName(BaseText name)
{
local int i;
local Text nextPlayerName;
@ -216,7 +216,7 @@ private final function RemoveAdmins()
// Add all the players specified by `macroText` (from macro "@<macroText>").
// Does nothing if there is no such macro.
private final function AddByMacro(Text macroText)
private final function AddByMacro(BaseText macroText)
{
if (macroText.Compare(T(TADMIN), SCASE_INSENSITIVE))
{
@ -239,7 +239,7 @@ private final function AddByMacro(Text macroText)
// Removes all the players specified by `macroText`
// (from macro "@<macroText>").
// Does nothing if there is no such macro.
private final function RemoveByMacro(Text macroText)
private final function RemoveByMacro(BaseText macroText)
{
local int i;
if (macroText.Compare(T(TADMIN), SCASE_INSENSITIVE))
@ -478,7 +478,7 @@ private final function Reset()
* @param toParse `Text` from which to parse player list.
* @return `true` if parsing was successful and `false` otherwise.
*/
public final function bool Parse(Text toParse)
public final function bool Parse(BaseText toParse)
{
local bool wasSuccessful;
local Parser parser;

12
sources/Config/AcediaConfig.uc

@ -153,7 +153,7 @@ private static function string NameToActualVersion(string configObjectName)
* @return `false` iff config object name `name` already existed
* or `name` is invalid for config object.
*/
public final static function bool NewConfig(Text name)
public final static function bool NewConfig(BaseText name)
{
local AcediaConfig newConfig;
if (name == none) return false;
@ -186,7 +186,7 @@ public final static function bool NewConfig(Text name)
* and dot ('.') character.
* @return `true` iff new config object was created.
*/
public final static function bool Exists(Text name)
public final static function bool Exists(BaseText name)
{
local bool result;
if (name == none) return false;
@ -214,7 +214,7 @@ public final static function bool Exists(Text name)
* Case-insensitive, must contain only ASCII latin letters, digits
* and dot ('.') character.
*/
public final static function DeleteConfig(Text name)
public final static function DeleteConfig(BaseText name)
{
local AssociativeArray.Entry entry;
if (default.existingConfigs == none) {
@ -250,7 +250,7 @@ public static function array<Text> AvailableConfigs()
* digits and dot ('.') character.
* @return `AcediaConfig` of caller class with name `name`.
*/
public final static function AcediaConfig GetConfigInstance(Text name)
public final static function AcediaConfig GetConfigInstance(BaseText name)
{
local AssociativeArray.Entry configEntry;
if (name == none) return none;
@ -286,7 +286,7 @@ public final static function AcediaConfig GetConfigInstance(Text name)
* For correctly implemented config objects should only return `none` if
* their class was not yet initialized (see `self.Initialize()` method).
*/
public final static function AssociativeArray LoadData(Text name)
public final static function AssociativeArray LoadData(BaseText name)
{
local AssociativeArray result;
local AcediaConfig requiredConfig;
@ -311,7 +311,7 @@ public final static function AssociativeArray LoadData(Text name)
* allows for JSON deserialization (see `JSONAPI.IsCompatible()` for
* details).
*/
public final static function SaveData(Text name, AssociativeArray data)
public final static function SaveData(BaseText name, AssociativeArray data)
{
local AcediaConfig requiredConfig;
requiredConfig = GetConfigInstance(name);

21
sources/Console/ConsoleBuffer.uc

@ -21,7 +21,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class ConsoleBuffer extends AcediaObject
dependson(Text)
dependson(BaseText)
dependson(ConsoleAPI);
/**
@ -177,10 +177,10 @@ public final function ConsoleBuffer Clear()
* @param inputType How to treat given `string` regarding coloring.
* @return Returns caller `ConsoleBuffer` to allow method chaining.
*/
public final function ConsoleBuffer Insert(Text input)
public final function ConsoleBuffer Insert(BaseText input)
{
local int inputConsumed;
local Text.Character nextCharacter;
local int inputConsumed;
local BaseText.Character nextCharacter;
if (input == none) {
return self;
}
@ -249,11 +249,11 @@ public final function ConsoleBuffer Flush()
// It is assumed that passed characters are not whitespace, -
// responsibility to check is on the one calling this method.
private final function InsertIntoWordBuffer(Text.Character newCharacter)
private final function InsertIntoWordBuffer(BaseText.Character newCharacter)
{
local int newCharacterIndex;
local Text.Formatting newFormatting;
local Color oldColor, newColor;
local int newCharacterIndex;
local BaseText.Formatting newFormatting;
local Color oldColor, newColor;
// Fix text color in the buffer to remember default color, if we use it.
newFormatting = _.text.GetCharacterFormatting(newCharacter);
newFormatting.color =
@ -336,7 +336,7 @@ private final function bool CanAppendWhitespaceIntoLine()
}
private final function bool CanAppendNonWhitespaceIntoLine(
Text.Character nextCharacter)
BaseText.Character nextCharacter)
{
// We always allow to insert at least something into empty line,
// otherwise we can never insert it anywhere
@ -357,7 +357,8 @@ private final function bool CanAppendNonWhitespaceIntoLine(
// For performance reasons assumes that passed character is a whitespace,
// the burden of checking is on the caller.
private final function AppendWhitespaceToCurrentLine(Text.Character whitespace)
private final function AppendWhitespaceToCurrentLine(
BaseText.Character whitespace)
{
if (_.text.IsCodePoint(whitespace, CODEPOINT_NEWLINE)) {
BreakLine(false);

8
sources/Console/ConsoleWriter.uc

@ -505,7 +505,7 @@ public final function ConsoleWriter Flush()
* @param message `Text` to output.
* @return Returns caller `ConsoleWriter` to allow for method chaining.
*/
public final function ConsoleWriter Write(optional Text message)
public final function ConsoleWriter Write(optional BaseText message)
{
outputBuffer.Insert(message);
if (needToResetColor) {
@ -521,7 +521,7 @@ public final function ConsoleWriter Write(optional Text message)
* @param message `Text` to output.
* @return Returns caller `ConsoleWriter` to allow for method chaining.
*/
public final function ConsoleWriter WriteLine(optional Text message)
public final function ConsoleWriter WriteLine(optional BaseText message)
{
return Write(message).Flush();
}
@ -538,7 +538,7 @@ public final function ConsoleWriter WriteLine(optional Text message)
* @param message `Text` to output.
* @return Returns caller `ConsoleWriter` to allow for method chaining.
*/
public final function ConsoleWriter WriteBlock(optional Text message)
public final function ConsoleWriter WriteBlock(optional BaseText message)
{
outputBuffer.Insert(message).Flush();
SendBuffer(true);
@ -558,7 +558,7 @@ public final function ConsoleWriter WriteBlock(optional Text message)
* @param message `Text` to output.
* @return Returns caller `ConsoleWriter` to allow for method chaining.
*/
public final function ConsoleWriter Say(optional Text message)
public final function ConsoleWriter Say(optional BaseText message)
{
outputBuffer.Insert(message).Flush();
SendBuffer(, true);

2
sources/Data/Collections/AssociativeArray.uc

@ -669,7 +669,7 @@ public final function Entry GetEntryByIndex(Index index)
return hashTable[index.bucketIndex].entries[index.entryIndex];
}
protected function AcediaObject GetByText(Text key)
protected function AcediaObject GetByText(BaseText key)
{
return GetItem(key);
}

18
sources/Data/Collections/Collection.uc

@ -36,7 +36,7 @@ var protected class<Iter> iteratorClass;
* this method (i.e. `AssociativeArray` only lets you access values with
* `Text` keys).
*/
protected function AcediaObject GetByText(Text key);
protected function AcediaObject GetByText(BaseText key);
/**
* Creates an `Iterator` instance to iterate over stored items.
@ -166,7 +166,7 @@ public final function AcediaObject GetItemByJSON(JSONPointer jsonPointer)
* @return An item `jsonPointerAsText` is referring to (according to the above
* stated rules). `none` if such item does not exist.
*/
public final function AcediaObject GetItemBy(Text jsonPointerAsText)
public final function AcediaObject GetItemBy(BaseText jsonPointerAsText)
{
local AcediaObject result;
local JSONPointer jsonPointer;
@ -196,7 +196,7 @@ public final function AcediaObject GetItemBy(Text jsonPointerAsText)
* is missing or has a different type.
*/
public final function bool GetBoolBy(
Text jsonPointerAsText,
BaseText jsonPointerAsText,
optional bool defaultValue)
{
local AcediaObject result;
@ -234,7 +234,7 @@ public final function bool GetBoolBy(
* is missing or has a different type.
*/
public final function byte GetByteBy(
Text jsonPointerAsText,
BaseText jsonPointerAsText,
optional byte defaultValue)
{
local AcediaObject result;
@ -272,7 +272,7 @@ public final function byte GetByteBy(
* is missing or has a different type.
*/
public final function int GetIntBy(
Text jsonPointerAsText,
BaseText jsonPointerAsText,
optional int defaultValue)
{
local AcediaObject result;
@ -310,7 +310,7 @@ public final function int GetIntBy(
* is missing or has a different type.
*/
public final function float GetFloatBy(
Text jsonPointerAsText,
BaseText jsonPointerAsText,
optional float defaultValue)
{
local AcediaObject result;
@ -344,7 +344,7 @@ public final function float GetFloatBy(
* @return `Text` value, stored at `jsonPointerAsText` or `none` if it
* is missing or has a different type.
*/
public final function Text GetTextBy(Text jsonPointerAsText)
public final function Text GetTextBy(BaseText jsonPointerAsText)
{
return Text(GetItemBy(jsonPointerAsText));
}
@ -364,7 +364,7 @@ public final function Text GetTextBy(Text jsonPointerAsText)
* `none` if it is missing or has a different type.
*/
public final function AssociativeArray GetAssociativeArrayBy(
Text jsonPointerAsText)
BaseText jsonPointerAsText)
{
return AssociativeArray(GetItemBy(jsonPointerAsText));
}
@ -383,7 +383,7 @@ public final function AssociativeArray GetAssociativeArrayBy(
* @return `DynamicArray` value, stored at `jsonPointerAsText` or
* `none` if it is missing or has a different type.
*/
public final function DynamicArray GetDynamicArrayBy(Text jsonPointerAsText)
public final function DynamicArray GetDynamicArrayBy(BaseText jsonPointerAsText)
{
return DynamicArray(GetItemBy(jsonPointerAsText));
}

2
sources/Data/Collections/DynamicArray.uc

@ -479,7 +479,7 @@ public final function int Find(AcediaObject item)
return -1;
}
protected function AcediaObject GetByText(Text key)
protected function AcediaObject GetByText(BaseText key)
{
local int index, consumed;
local Parser parser;

14
sources/Data/Database/DBAPI.uc

@ -51,7 +51,7 @@ private final function CreateLocalDBMapIfMissing()
* @param databaseLink Link from which to extract database's name.
* @return Database named "<db_name>" of type "<type>" from the `databaseLink`.
*/
public final function Database Load(Text databaseLink)
public final function Database Load(BaseText databaseLink)
{
local Parser parser;
local Database result;
@ -94,7 +94,7 @@ public final function Database Load(Text databaseLink)
* Guaranteed to not be `none` if provided argument `databaseLink`
* is not `none`.
*/
public final function JSONPointer GetPointer(Text databaseLink)
public final function JSONPointer GetPointer(BaseText databaseLink)
{
local int slashIndex;
local Text textPointer;
@ -122,7 +122,7 @@ public final function JSONPointer GetPointer(Text databaseLink)
* @param databaseName Name for the new database.
* @return Reference to created database. Returns `none` iff method failed.
*/
public final function LocalDatabaseInstance NewLocal(Text databaseName)
public final function LocalDatabaseInstance NewLocal(BaseText databaseName)
{
local DBRecord rootRecord;
local Text rootRecordName;
@ -158,7 +158,7 @@ public final function LocalDatabaseInstance NewLocal(Text databaseName)
* @param databaseName Name of the database to load.
* @return Loaded local database. `none` if it does not exist.
*/
public final function LocalDatabaseInstance LoadLocal(Text databaseName)
public final function LocalDatabaseInstance LoadLocal(BaseText databaseName)
{
local DBRecord rootRecord;
local Text rootRecordName;
@ -209,7 +209,7 @@ public final function LocalDatabaseInstance LoadLocal(Text databaseName)
* @param databaseName Name of the database to check.
* @return `true` if database with specified name exists and `false` otherwise.
*/
public final function bool ExistsLocal(Text databaseName)
public final function bool ExistsLocal(BaseText databaseName)
{
return LoadLocal(databaseName) != none;
}
@ -221,7 +221,7 @@ public final function bool ExistsLocal(Text databaseName)
* @return `true` if database with specified name existed and was deleted and
* `false` otherwise.
*/
public final function bool DeleteLocal(Text databaseName)
public final function bool DeleteLocal(BaseText databaseName)
{
local LocalDatabase localDatabaseConfig;
local LocalDatabaseInstance localDatabase;
@ -250,7 +250,7 @@ public final function bool DeleteLocal(Text databaseName)
return false;
}
private function EraseAllPackageData(Text packageToErase)
private function EraseAllPackageData(BaseText packageToErase)
{
local int i;
local string packageName;

6
sources/Data/Database/Local/DBRecord.uc

@ -266,7 +266,7 @@ public static final function Global __()
* @return New `DBRecord`, created in specified package.
* `none` iff `dbPackageName == none`.
*/
public final static function DBRecord NewRecord(Text dbPackageName)
public final static function DBRecord NewRecord(BaseText dbPackageName)
{
if (dbPackageName == none) {
return none;
@ -303,8 +303,8 @@ private final static function DBRecord NewRecordFor(string dbPackageName)
}
public final static function DBRecord LoadRecord(
Text recordName,
Text dbPackageName)
BaseText recordName,
BaseText dbPackageName)
{
if (dbPackageName == none) return none;
if (recordName == none) return none;

4
sources/Data/Database/Local/LocalDatabase.uc

@ -48,7 +48,7 @@ public final function Text GetRootName()
*
* Only makes changes if root is not already defined.
*/
public final function SetRootName(Text rootName)
public final function SetRootName(BaseText rootName)
{
if (HasDefinedRoot()) {
return;
@ -61,7 +61,7 @@ public final function SetRootName(Text rootName)
}
}
public final static function LocalDatabase Load(Text databaseName)
public final static function LocalDatabase Load(BaseText databaseName)
{
if (!__().text.IsEmpty(databaseName)) {
return new(none, databaseName.ToString()) class'LocalDatabase';

2
sources/Data/Database/Tests/TEST_LocalDatabase.uc

@ -1000,7 +1000,7 @@ protected static function SubTest_IncrementString(LocalDatabaseInstance db)
TEST_ExpectTrue(
Text(default.resultObject).ToString() == "simpleValue!");
task = db.IncrementData(__().json.Pointer(P("/A")),
__().text.FromStringM("?"));
__().text.FromString("?"));
task.connect = DBIncrementHandler;
task.TryCompleting();
TEST_ExpectTrue(default.resultType == DBR_Success);

15
sources/Features/Feature.uc

@ -138,8 +138,9 @@ protected function Finalizer()
*
* @param newConfigName Name of the config to apply to the caller `Feature`.
*/
private final function ApplyConfig(Text newConfigName)
private final function ApplyConfig(BaseText newConfigName)
{
local Text configNameCopy;
local FeatureConfig newConfig;
if (newConfigName == none) {
return;
@ -150,17 +151,17 @@ private final function ApplyConfig(Text newConfigName)
{
_.logger.Auto(errorBadConfigData).ArgClass(class);
// Fallback to "default" config
newConfigName = _.text.FromString(defaultConfigName);
configClass.static.NewConfig(newConfigName);
configNameCopy = _.text.FromString(defaultConfigName);
configClass.static.NewConfig(configNameCopy);
newConfig =
FeatureConfig(configClass.static.GetConfigInstance(newConfigName));
FeatureConfig(configClass.static.GetConfigInstance(configNameCopy));
}
else {
newConfigName = newConfigName.Copy();
configNameCopy = newConfigName.Copy();
}
SwapConfig(newConfig);
_.memory.Free(currentConfigName);
currentConfigName = newConfigName;
currentConfigName = configNameCopy;
}
/**
@ -258,7 +259,7 @@ public static final function bool IsEnabled()
* Passing `none` will make caller `Feature` use "default" config.
* @return Active instance of the caller `Feature` class.
*/
public static final function Feature EnableMe(Text configName)
public static final function Feature EnableMe(BaseText configName)
{
local Feature myInstance;
if (configName == none) {

2
sources/Features/FeatureConfig.uc

@ -97,7 +97,7 @@ public static function Text GetAutoEnabledConfig()
* @return `true` iff some config was set to be used when it's `Feature` is
* auto-enabled, even if the same config was already configured to be used.
*/
public static function bool SetAutoEnabledConfig(Text autoEnabledConfigName)
public static function bool SetAutoEnabledConfig(BaseText autoEnabledConfigName)
{
local int i;
local array<Text> names;

4
sources/Gameplay/BaseClasses/Frontend/Templates/ATemplatesComponent.uc

@ -31,7 +31,7 @@ class ATemplatesComponent extends AcediaObject
* @return `true` if list named `listName` exists and `false` otherwise.
* Always returns `false` if `listName` equals `none`.
*/
public function bool ItemListExists(Text listName)
public function bool ItemListExists(BaseText listName)
{
return false;
}
@ -54,7 +54,7 @@ public function bool ItemListExists(Text listName)
* When incorrect `listName` is specified - empty array is returned
* (which can also happen if specified list is empty).
*/
public function array<Text> GetItemList(Text listName)
public function array<Text> GetItemList(BaseText listName)
{
local array<Text> emptyArray;
return emptyArray;

2
sources/Gameplay/BaseClasses/KillingFloor/Frontend/KFFrontend.uc

@ -46,7 +46,7 @@ protected function Finalizer()
* `none` if item template with given name does not exist or passed
* `templateName` is equal to `none`.
*/
public function EItemTemplateInfo GetItemTemplateInfo(Text templateName)
public function EItemTemplateInfo GetItemTemplateInfo(BaseText templateName)
{
return none;
}

2
sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ATradingComponent.uc

@ -100,7 +100,7 @@ public function array<ETrader> GetTraders();
* @return `ETrader` with a given `traderName`. `none` if either `traderName`
* is `none` or there is no trader with such a name.
*/
public function ETrader GetTrader(Text traderName);
public function ETrader GetTrader(BaseText traderName);
/**
* Checks whether trading is currently active.

2
sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ETrader.uc

@ -60,7 +60,7 @@ public function Text GetName();
* @param newName New name of the caller trader.
* @return `true` if trader is currently enabled and `false` otherwise.
*/
public function ETrader SetName(Text newName);
public function ETrader SetName(BaseText newName);
/**
* Checks if caller trader is currently enabled.

2
sources/Gameplay/KF1Frontend/BaseImplementation/EKFAmmo.uc

@ -121,7 +121,7 @@ public function array<Text> GetTags()
return tagArray;
}
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
if (tagToCheck == none) return false;
if (tagToCheck.Compare(P("ammo"))) return true;

2
sources/Gameplay/KF1Frontend/BaseImplementation/EKFFlashlightAmmo.uc

@ -121,7 +121,7 @@ public function array<Text> GetTags()
return tagArray;
}
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
if (tagToCheck == none) return false;
if (tagToCheck.Compare(P("ammo"))) return true;

16
sources/Gameplay/KF1Frontend/BaseImplementation/EKFInventory.uc

@ -310,7 +310,7 @@ public function EItem Add(EItem newItem, optional bool forceAddition)
* and can fail adding an item even if `CanAddTemplate()` succeeded.
*/
public function EItem AddTemplate(
Text newItemTemplate,
BaseText newItemTemplate,
optional bool forceAddition)
{
local Pawn pawn;
@ -399,7 +399,7 @@ public function Text CanAddExplain(
* and can raise "faulty implementation" error in case it cannot.
*/
public function Text CanAddTemplateExplain(
Text itemTemplateToCheck,
BaseText itemTemplateToCheck,
optional bool forceAddition)
{
local class<Inventory> inventoryClass;
@ -614,7 +614,7 @@ public function bool Remove(
* added by other mods) items.
*/
public function bool RemoveTemplate(
Text template,
BaseText template,
optional bool keepItem,
optional bool forceRemoval,
optional bool removeAll)
@ -962,7 +962,7 @@ public function bool Contains(EItem itemToCheck)
return false;
}
public function bool ContainsTemplate(Text itemTemplateToCheck)
public function bool ContainsTemplate(BaseText itemTemplateToCheck)
{
local bool success;
local EItem templateItem;
@ -1100,7 +1100,7 @@ public function array<EItem> GetItemsSupporting(class<EItem> interfaceClass)
return GetItemsByFlags(getWeapon, getAmmo, false);
}
public function array<EItem> GetTagItems(Text tag)
public function array<EItem> GetTagItems(BaseText tag)
{
local array<EItem> emptyArray;
local bool getWeapon, getAmmo;
@ -1112,7 +1112,7 @@ public function array<EItem> GetTagItems(Text tag)
return GetItemsByFlags(getWeapon, getAmmo, false);
}
public function EItem GetTagItem(Text tag)
public function EItem GetTagItem(BaseText tag)
{
local bool getWeapon, getAmmo;
if (tag == none) {
@ -1123,7 +1123,7 @@ public function EItem GetTagItem(Text tag)
return GetItemByFlags(getWeapon, getAmmo, false);
}
public function array<EItem> GetTemplateItems(Text template)
public function array<EItem> GetTemplateItems(BaseText template)
{
local Pawn pawn;
local bool getBuiltInAmmo;
@ -1173,7 +1173,7 @@ public function array<EItem> GetTemplateItems(Text template)
return result;
}
public function EItem GetTemplateItem(Text template)
public function EItem GetTemplateItem(BaseText template)
{
local Pawn pawn;
local bool getBuiltInAmmo;

2
sources/Gameplay/KF1Frontend/BaseImplementation/EKFMedicAmmo.uc

@ -120,7 +120,7 @@ public function array<Text> GetTags()
return tagArray;
}
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
if (tagToCheck == none) return false;
if (tagToCheck.Compare(P("ammo"))) return true;

2
sources/Gameplay/KF1Frontend/BaseImplementation/EKFSyringeAmmo.uc

@ -120,7 +120,7 @@ public function array<Text> GetTags()
return tagArray;
}
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
if (tagToCheck == none) return false;
if (tagToCheck.Compare(P("ammo"))) return true;

2
sources/Gameplay/KF1Frontend/BaseImplementation/EKFUnknownItem.uc

@ -111,7 +111,7 @@ public function array<Text> GetTags()
return emptyArray;
}
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
return false;
}

2
sources/Gameplay/KF1Frontend/BaseImplementation/EKFWeapon.uc

@ -118,7 +118,7 @@ public function array<Text> GetTags()
return tagArray;
}
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
if (tagToCheck == none) return false;
if (tagToCheck.Compare(P("weapon"))) return true;

2
sources/Gameplay/KF1Frontend/KF1_Frontend.uc

@ -21,7 +21,7 @@
*/
class KF1_Frontend extends KFFrontend;
public function EItemTemplateInfo GetItemTemplateInfo(Text templateName)
public function EItemTemplateInfo GetItemTemplateInfo(BaseText templateName)
{
local class<Inventory> inventoryClass;
inventoryClass = class<Inventory>(_.memory.LoadClass(templateName));

4
sources/Gameplay/KF1Frontend/Templates/KF1_TemplatesComponent.uc

@ -150,7 +150,7 @@ private function array<Text> CopyList(array<Text> inputList)
return outputList;
}
public function bool ItemListExists(Text listName)
public function bool ItemListExists(BaseText listName)
{
local string listNameAsString;
if (listName == none) return false;
@ -171,7 +171,7 @@ public function bool ItemListExists(Text listName)
return false;
}
public function array<Text> GetItemList(Text listName)
public function array<Text> GetItemList(BaseText listName)
{
local string listNameAsString;
local array<Text> emptyArray;

4
sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc

@ -138,13 +138,13 @@ public final /* unreal */ function ShopVolume GetShopVolume()
public function Text GetName()
{
if (myName == none) {
return _.text.Empty();
return P("");
}
return myName.Copy();
}
// TODO: it is broken, needs fixing
public function ETrader SetName(Text newName)
public function ETrader SetName(BaseText newName)
{
if (newName == none) return self;
if (newName.IsEmpty()) return self;

2
sources/Gameplay/KF1Frontend/Trading/KF1_TradingComponent.uc

@ -84,7 +84,7 @@ public function array<ETrader> GetTraders()
return result;
}
public function ETrader GetTrader(Text traderName)
public function ETrader GetTrader(BaseText traderName)
{
local int i;
local Text nextTraderName;

2
sources/Logger/ConsoleLogger.uc

@ -24,7 +24,7 @@ class ConsoleLogger extends Logger
config(AcediaSystem)
dependson(LoggerAPI);
public function Write(Text message, LoggerAPI.LogLevel messageLevel)
public function Write(BaseText message, LoggerAPI.LogLevel messageLevel)
{
local MutableText builder;
if (message != none)

16
sources/Logger/LogMessage.uc

@ -79,7 +79,7 @@ var private array<int> normalizedArguments;
// amounts of trash objects, since only one of them can "make a mess".
var private LogMessage dirtyLogMessage;
// Arguments, collected so far by the `Arg*()` calls
var private array<Text> collectedArguments;
var private array<BaseText> collectedArguments;
protected function Finalizer()
{
@ -105,11 +105,11 @@ protected function Finalizer()
*/
public final function Initialize(LoggerAPI.Definition logMessageDefinition)
{
local int nextArgument;
local Parser parser;
local MutableText nextLogPart, nextChunk;
local Text.Character percentCharacter;
local array<int> parsedArguments;
local int nextArgument;
local Parser parser;
local MutableText nextLogPart, nextChunk;
local BaseText.Character percentCharacter;
local array<int> parsedArguments;
if (isInitialized) {
return;
}
@ -208,7 +208,7 @@ private final function NormalizeArguments(array<int> argumentsOrder)
* returned by `P()`, `C()` or `F()` calls.
* @return Caller `LogMessage` to allow for method chaining.
*/
public final function LogMessage Arg(Text argument)
public final function LogMessage Arg(/*take*/ BaseText argument)
{
if (IsArgumentListFull()) {
return self;
@ -335,7 +335,7 @@ public final function Text Collect()
{
local int i, argumentIndex;
local Text result;
local Text nextArgument;
local BaseText nextArgument;
local MutableText builder;
if (logParts.length == 0) {
return P("").Copy();

4
sources/Logger/Logger.uc

@ -60,7 +60,7 @@ protected static function StaticFinalizer()
* unless it is deallocated.
* @return Logger with object name `loggerName`.
*/
public final static function Logger GetLogger(Text loggerName)
public final static function Logger GetLogger(BaseText loggerName)
{
local Logger loggerInstance;
local Text loggerKey;
@ -136,7 +136,7 @@ protected function MutableText GetPrefix(LoggerAPI.LogLevel messageLevel)
* @param message Message to output.
* @param messageLevel Level, at which message must be output.
*/
public function Write(Text message, LoggerAPI.LogLevel messageLevel){}
public function Write(BaseText message, LoggerAPI.LogLevel messageLevel){}
defaultproperties
{

12
sources/Logger/LoggerAPI.uc

@ -245,7 +245,7 @@ public final function LogMessage Auto(out Definition definition)
* @param message Message to log.
* @param messageLevel Level at which to log message.
*/
public final function LogAtLevel(Text message, LogLevel messageLevel)
public final function LogAtLevel(BaseText message, LogLevel messageLevel)
{
switch (messageLevel)
{
@ -274,7 +274,7 @@ public final function LogAtLevel(Text message, LogLevel messageLevel)
*
* @param message Message to log.
*/
public final function Debug(Text message)
public final function Debug(BaseText message)
{
local int i;
for (i = 0; i < debugLoggerInstances.length; i += 1) {
@ -288,7 +288,7 @@ public final function Debug(Text message)
*
* @param message Message to log.
*/
public final function Info(Text message)
public final function Info(BaseText message)
{
local int i;
for (i = 0; i < infoLoggerInstances.length; i += 1) {
@ -302,7 +302,7 @@ public final function Info(Text message)
*
* @param message Message to log.
*/
public final function Warning(Text message)
public final function Warning(BaseText message)
{
local int i;
for (i = 0; i < warningLoggerInstances.length; i += 1) {
@ -316,7 +316,7 @@ public final function Warning(Text message)
*
* @param message Message to log.
*/
public final function Error(Text message)
public final function Error(BaseText message)
{
local int i;
for (i = 0; i < errorLoggerInstances.length; i += 1) {
@ -330,7 +330,7 @@ public final function Error(Text message)
*
* @param message Message to log.
*/
public final function Fatal(Text message)
public final function Fatal(BaseText message)
{
local int i;
for (i = 0; i < fatalLoggerInstances.length; i += 1) {

6
sources/Memory/MemoryAPI.uc

@ -30,7 +30,7 @@ class MemoryAPI extends AcediaObject;
* @param classReference Text representation of the class to return.
* @return Loaded class, corresponding to its name from `classReference`.
*/
public final function class<Object> LoadClass(Text classReference)
public final function class<Object> LoadClass(BaseText classReference)
{
if (classReference == none) {
return none;
@ -139,7 +139,7 @@ public final function Object Allocate(
* guarantees to return last pooled object (in a LIFO queue),
* unless `forceNewInstance == true`.
*
* @param refToClassToAllocate `Text` representation of the class of
* @param refToClassToAllocate `BaseText` representation of the class of
* the `Object` / `Actor` that this method must create.
* @param forceNewInstance Set this to `true` if you require this method to
* create a new instance, bypassing any object pools.
@ -147,7 +147,7 @@ public final function Object Allocate(
* `none` if creation has failed (only possible for actors).
*/
public final function Object AllocateByReference(
Text refToClassToAllocate,
BaseText refToClassToAllocate,
optional bool forceNewInstance)
{
return Allocate(LoadClass(refToClassToAllocate), forceNewInstance);

12
sources/Players/EPlayer.uc

@ -256,7 +256,7 @@ public final function Text GetName()
* @param newPlayerName New name of the caller `EPlayer`. This value will
* be copied. Passing `none` will result in an empty name.
*/
public final function SetName(Text newPlayerName)
public final function SetName(BaseText newPlayerName)
{
local Text oldPlayerName;
local PlayerReplicationInfo replicationInfo;
@ -270,10 +270,10 @@ public final function SetName(Text newPlayerName)
}
// Converts `Text` nickname into a suitable `string` representation.
private final function string ConvertTextNameIntoString(Text playerName)
private final function string ConvertTextNameIntoString(BaseText playerName)
{
local string newPlayerNameAsString;
local Text.Formatting endingFormatting;
local string newPlayerNameAsString;
local BaseText.Formatting endingFormatting;
if (playerName == none) {
return "";
}
@ -301,8 +301,8 @@ private final function string ConvertTextNameIntoString(Text playerName)
// Calls appropriate events to let them modify / "censor" player's new name.
private final function string CensorPlayerName(
Text oldPlayerName,
Text newPlayerName)
BaseText oldPlayerName,
BaseText newPlayerName)
{
local string result;
local Text censoredName;

2
sources/Players/Events/PlayerAPI_OnPlayerNameChanged_Signal.uc

@ -19,7 +19,7 @@
*/
class PlayerAPI_OnPlayerNameChanged_Signal extends Signal;
public final function Emit(EPlayer player, Text oldName, Text newName)
public final function Emit(EPlayer player, BaseText oldName, BaseText newName)
{
local Slot nextSlot;
StartIterating();

2
sources/Players/Events/PlayerAPI_OnPlayerNameChanged_Slot.uc

@ -19,7 +19,7 @@
*/
class PlayerAPI_OnPlayerNameChanged_Slot extends Slot;
delegate connect(EPlayer player, Text oldName, Text newName)
delegate connect(EPlayer player, BaseText oldName, BaseText newName)
{
DummyCall();
}

4
sources/Players/Events/PlayerAPI_OnPlayerNameChanging_Signal.uc

@ -19,7 +19,9 @@
*/
class PlayerAPI_OnPlayerNameChanging_Signal extends Signal;
public final function Emit(EPlayer player, Text oldName, MutableText newName)
public final function Emit(EPlayer player,
BaseText oldName,
MutableText newName)
{
local Slot nextSlot;
StartIterating();

2
sources/Players/Events/PlayerAPI_OnPlayerNameChanging_Slot.uc

@ -19,7 +19,7 @@
*/
class PlayerAPI_OnPlayerNameChanging_Slot extends Slot;
delegate connect(EPlayer player, Text oldName, MutableText newName)
delegate connect(EPlayer player, BaseText oldName, MutableText newName)
{
DummyCall();
}

18
sources/Players/Inventory/EInventory.uc

@ -82,7 +82,7 @@ public function EItem Add(EItem newItem, optional bool forceAddition)
* `none` iff adding item has failed.
*/
public function EItem AddTemplate(
Text newItemTemplate,
BaseText newItemTemplate,
optional bool forceAddition)
{
return none;
@ -130,7 +130,7 @@ public final function bool CanAdd(
* `false` otherwise.
*/
public function bool CanAddTemplate(
Text itemTemplateToCheck,
BaseText itemTemplateToCheck,
optional bool forceAddition)
{
local bool success;
@ -181,7 +181,7 @@ public function Text CanAddExplain(
* description of reason why not otherwise.
*/
public function Text CanAddTemplateExplain(
Text itemTemplateToCheck,
BaseText itemTemplateToCheck,
optional bool forceAddition)
{
return none;
@ -243,7 +243,7 @@ public function bool Remove(
* caller `EInventory` in the first place).
*/
public function bool RemoveTemplate(
Text itemTemplateToRemove,
BaseText itemTemplateToRemove,
optional bool keepItem,
optional bool forceRemoval,
optional bool removeAll)
@ -307,7 +307,7 @@ public function bool Contains(EItem itemToCheck)
* @result `true` if item with a given template does belong to the inventory
* and `false` otherwise.
*/
public function bool ContainsTemplate(Text itemTemplateToCheck)
public function bool ContainsTemplate(BaseText itemTemplateToCheck)
{
return false;
}
@ -348,7 +348,7 @@ public function array<EItem> GetItemsSupporting(class<EItem> interfaceClass)
* Guaranteed to not contain `none` references of interfaces to
* inexistent entities.
*/
public function array<EItem> GetTagItems(Text tag)
public function array<EItem> GetTagItems(BaseText tag)
{
local array<EItem> emptyArray;
return emptyArray;
@ -368,7 +368,7 @@ public function array<EItem> GetTagItems(Text tag)
* the specified tag `tag`.
* Guaranteed to not be `none` or refer to non-existent entity.
*/
public function EItem GetTagItem(Text tag) { return none; }
public function EItem GetTagItem(BaseText tag) { return none; }
/**
* Returns array with all `EItem`s contained inside the caller `EInventory`
@ -380,7 +380,7 @@ public function EItem GetTagItem(Text tag) { return none; }
* Guaranteed to not contain `none` references or interfaces to
* inexistent entities.
*/
public function array<EItem> GetTemplateItems(Text template)
public function array<EItem> GetTemplateItems(BaseText template)
{
local array<EItem> emptyArray;
return emptyArray;
@ -400,7 +400,7 @@ public function array<EItem> GetTemplateItems(Text template)
* from the specified template `template`.
* Guaranteed to not be `none` or refer to non-existent entity.
*/
public function EItem GetTemplateItem(Text template) { return none; }
public function EItem GetTemplateItem(BaseText template) { return none; }
/**
* Returns array of caller `EInventory`'s items that are currently equipped by

2
sources/Players/Inventory/EItem.uc

@ -64,7 +64,7 @@ public function array<Text> GetTags()
}
// TODO: document this
public function bool HasTag(Text tagToCheck)
public function bool HasTag(BaseText tagToCheck)
{
return false;
}

6
sources/Players/PlayersAPI.uc

@ -19,7 +19,7 @@
*/
class PlayersAPI extends AcediaObject
dependson(ConnectionService)
dependson(Text)
dependson(BaseText)
dependson(EPlayer);
// Writer that can be used to write into this player's console
@ -108,7 +108,7 @@ public function PlayerAPI_OnLostPlayer_Slot OnLostPlayer(
* use `OnPlayerNameChanged` instead.
*
* [Signature]
* void <slot>(EPlayer affectedPlayer, Text oldName, MutableText newName)
* void <slot>(EPlayer affectedPlayer, BaseText oldName, MutableText newName)
*
* @param affectedPlayer Player, whos name got changed.
* @param oldName Player's old name.
@ -130,7 +130,7 @@ public function PlayerAPI_OnPlayerNameChanging_Slot OnPlayerNameChanging(
* after change caused by someone else, use `OnPlayerNameChanging` instead.
*
* [Signature]
* void <slot>(EPlayer affectedPlayer, Text oldName, Text newName)
* void <slot>(EPlayer affectedPlayer, BaseText oldName, BaseText newName)
*
* @param affectedPlayer Player, whos name got changed.
* @param oldName Player's old name.

1578
sources/Text/BaseText.uc

File diff suppressed because it is too large Load Diff

2
sources/Text/Codecs/Utf8Decoder.uc

@ -141,7 +141,7 @@ private final function bool PushInnerByte(byte nextByte)
private final function AppendCodePoint(int codePoint)
{
local Text.Character nextCharacter;
local BaseText.Character nextCharacter;
nextCharacter.codePoint = codePoint;
builtText.AppendCharacter(nextCharacter);
}

2
sources/Text/Codecs/Utf8Encoder.uc

@ -44,7 +44,7 @@ var private int lastSixBits;
* `none` iff `text == none` or `text` contains invalid Unicode
* code points.
*/
public final function ByteArrayRef Encode(Text text)
public final function ByteArrayRef Encode(BaseText text)
{
local int i, nextCodepoint, textLength;
local ByteArrayRef buffer;

8
sources/Text/FormattedStrings/FormattingCommandsSequence.uc

@ -24,7 +24,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class FormattingCommandsSequence extends AcediaObject
dependson(Text);
dependson(BaseText);
enum FormattingCommandType
{
@ -48,7 +48,7 @@ struct FormattingCommand
// Formatting character for the "^"-type tag
// This parameter is only used for `FST_StackSwap` command type.
var Text.Character charTag;
var BaseText.Character charTag;
// Rest of the parameters are only used for `FST_StackPush`
// command type.
@ -149,7 +149,7 @@ protected function Finalizer()
* direct access to formatting commands defined in `input`.
*/
public final static function FormattingCommandsSequence FromText(
Text input,
BaseText input,
optional FormattingErrorsReport errorsReporter)
{
local FormattingCommandsSequence newSequence;
@ -205,7 +205,7 @@ public final function FormattingCommand GetCommand(int commandIndex)
private final function BuildSelf()
{
local Text.Character nextCharacter;
local BaseText.Character nextCharacter;
while (!parser.HasFinished())
{
parser.MCharacter(nextCharacter);

4
sources/Text/FormattedStrings/FormattingErrorsReport.uc

@ -95,7 +95,9 @@ protected function Finalizer()
* do nothing.
* Parameter is unused for other types of errors.
*/
public final function Report(FormattedStringErrorType type, optional Text cause)
public final function Report(
FormattedStringErrorType type,
optional BaseText cause)
{
switch (type)
{

21
sources/Text/FormattedStrings/FormattingStringParser.uc

@ -22,7 +22,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class FormattingStringParser extends AcediaObject
dependson(Text)
dependson(BaseText)
dependson(FormattingErrorsReport)
dependson(FormattingCommandsSequence);
@ -121,7 +121,7 @@ var private MutableText borrowedTarget;
var private FormattingErrorsReport borrowedErrors;
// Keep this as an easy access to separator of gradient colors ':'
var private Text.Character separatorCharacter;
var private BaseText.Character separatorCharacter;
var private const int TOPENING_BRACKET, TCLOSING_BRACKET, TPERCENT;
@ -165,7 +165,7 @@ protected function Finalizer()
*/
public static final function array<FormattingErrorsReport.FormattedStringError>
ParseFormatted(
Text source,
BaseText source,
optional MutableText target,
optional bool doReportErrors)
{
@ -207,7 +207,7 @@ public static final function array<FormattingErrorsReport.FormattedStringError>
private final function DoAppend()
{
local int i;
local Text.Formatting emptyFormatting;
local BaseText.Formatting emptyFormatting;
local FormattingCommandsSequence.FormattingCommand nextCommand;
SetupFormattingStack(emptyFormatting);
// First element of color stack is special and has no color information;
@ -262,7 +262,7 @@ private final function AppendToTarget(array<Text.Character> contents)
private final function Report(
FormattingErrorsReport.FormattedStringErrorType type,
optional Text cause)
optional BaseText cause)
{
if (borrowedErrors == none) {
return;
@ -278,9 +278,9 @@ private final function bool IsCurrentFormattingGradient()
return formattingStackHead.gradient;
}
private final function Text.Formatting GetFormattingFor(int index)
private final function BaseText.Formatting GetFormattingFor(int index)
{
local Text.Formatting emptyFormatting;
local BaseText.Formatting emptyFormatting;
if (formattingStack.length <= 0) return emptyFormatting;
if (!formattingStackHead.colored) return emptyFormatting;
@ -319,7 +319,7 @@ private final function Color GetColorFor(int index)
return targetColor;
}
private final function FormattingInfo ParseFormattingInfo(Text colorTag)
private final function FormattingInfo ParseFormattingInfo(BaseText colorTag)
{
local int i;
local Parser colorParser;
@ -477,7 +477,8 @@ private final function array<float> NormalizePoints(array<float> points)
// that will be used when we pop all the other elements.
// It is necessary to deal with possible folded formatting definitions in
// formatted strings.
private final function SetupFormattingStack(Text.Formatting defaultFormatting)
private final function SetupFormattingStack(
BaseText.Formatting defaultFormatting)
{
local FormattingInfo defaultFormattingInfo;
defaultFormattingInfo.colored = defaultFormatting.isColored;
@ -499,7 +500,7 @@ private final function PushIntoFormattingStack(
formattingStack[formattingStack.length] = formattingStackHead;
}
private final function SwapFormattingStack(Text.Character tagCharacter)
private final function SwapFormattingStack(BaseText.Character tagCharacter)
{
local FormattingInfo updatedFormatting;
if (formattingStack.length > 0) {

31
sources/Text/JSON/JSONAPI.uc

@ -28,8 +28,9 @@ class JSONAPI extends AcediaObject
var private bool formattingInitialized;
// Variables used in json pretty printing for defining used colors;
// Colors are taken from `ColorAPI`.
var private Text.Formatting jPropertyName, jObjectBraces, jArrayBraces, jComma;
var private Text.Formatting jColon, jNumber, jBoolean, jString, jNull;
var private BaseText.Formatting jPropertyName, jObjectBraces, jArrayBraces;
var private BaseText.Formatting jComma, jColon, jNumber, jBoolean, jString;
var private BaseText.Formatting jNull;
var const int TNULL, TTRUE, TFALSE, TDOT, TEXPONENT;
var const int TOPEN_BRACKET, TCLOSE_BRACKET, TOPEN_BRACE, TCLOSE_BRACE;
@ -79,7 +80,7 @@ private final function InitFormatting()
* an incorrect JSON pointer or `none`, - empty `JSONPointer` will be
* returned.
*/
public final function JSONPointer Pointer(optional Text pointerAsText)
public final function JSONPointer Pointer(optional BaseText pointerAsText)
{
return JSONPointer(_.memory.Allocate(class'JSONPointer'))
.Set(pointerAsText);
@ -147,7 +148,7 @@ public final function TryNullWith(Parser parser)
* @param source `Text` instance to parse JSON null value from.
* @return `true` if parsing succeeded and `false` otherwise.
*/
public final function bool IsNull(Text source)
public final function bool IsNull(BaseText source)
{
local bool parsingSucceeded;
local Parser parser;
@ -258,7 +259,7 @@ public final function AcediaObject ParseBooleanWith(
* Returns `none` iff parsing has failed.
*/
public final function AcediaObject ParseBoolean(
Text source,
BaseText source,
optional bool parseAsMutable)
{
local bool result;
@ -476,7 +477,7 @@ public final function AcediaObject ParseNumberWith(
* Returns `none` iff parsing has failed.
*/
public final function AcediaObject ParseNumber(
Text source,
BaseText source,
optional bool parseAsMutable)
{
local int integerResult;
@ -534,7 +535,7 @@ public final function AcediaObject ParseNumber(
* `none` otherwise. To check for parsing success check the state of
* the `parser`.
*/
public final function Text ParseStringWith(
public final function BaseText ParseStringWith(
Parser parser,
optional bool parseAsMutable)
{
@ -572,8 +573,8 @@ public final function Text ParseStringWith(
* `none` otherwise. To check for parsing success check the state of
* the `parser`.
*/
public final function Text ParseString(
Text source,
public final function BaseText ParseString(
BaseText source,
optional bool parseAsMutable)
{
local bool parsingSuccessful;
@ -1250,7 +1251,7 @@ private final function MutableText PrettyPrintObjectWithIndent(
// initialized.
private final function PrettyPrintKeyValue(
MutableText builder,
Text nextKey,
BaseText nextKey,
AcediaObject nextValue,
MutableText accumulatedIndent)
{
@ -1276,12 +1277,12 @@ private final function PrettyPrintKeyValue(
// representation.
// We can't just dump `original`'s contents into JSON output as is,
// since we have to replace several special characters with escaped sequences.
private final function MutableText DisplayText(Text original)
private final function MutableText DisplayText(BaseText original)
{
local int i, length;
local MutableText result;
local Text.Character nextCharacter;
local Text.Character reverseSolidus;
local int i, length;
local MutableText result;
local BaseText.Character nextCharacter;
local BaseText.Character reverseSolidus;
reverseSolidus = _.text.CharacterFromCodePoint(CODEPOINT_REVERSE_SOLIDUS);
result = T(TQUOTE).MutableCopy();
length = original.GetLength();

6
sources/Text/JSON/JSONPointer.uc

@ -90,7 +90,7 @@ public final function JSONPointer Empty()
* @param pointerAsText `Text` representation of the JSON pointer.
* @return Reference to the caller `JSONPointer` to allow for method chaining.
*/
public final function JSONPointer Set(Text pointerAsText)
public final function JSONPointer Set(BaseText pointerAsText)
{
local int i;
local bool hasEscapedSequences;
@ -144,7 +144,7 @@ public final function JSONPointer Set(Text pointerAsText)
* no changes will be made at all.
* @return Reference to the caller `JSONPointer` to allow for method chaining.
*/
public final function JSONPointer Push(Text newComponent)
public final function JSONPointer Push(BaseText newComponent)
{
local Component newComponentRecord;
if (newComponent == none) {
@ -199,7 +199,7 @@ public final function Text Pop(optional bool doNotRemove)
lastIndex = components.length - 1;
// Do not use `GetComponent()` to avoid unnecessary `Text` copying
if (components[lastIndex].asText == none) {
result = _.text.FromIntM(components[lastIndex].asNumber);
result = _.text.FromInt(components[lastIndex].asNumber);
}
else {
result = components[lastIndex].asText.Copy();

95
sources/Text/MutableText.uc

@ -1,5 +1,5 @@
/**
* Mutable version of Acedia's `Text`
* Mutable version of Acedia's `BaseText`.
* Copyright 2020 - 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
@ -17,10 +17,23 @@
* You should have received a copy of the GNU General Public License
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class MutableText extends Text;
class MutableText extends BaseText;
var private int CODEPOINT_NEWLINE;
public function Text IntoText()
{
local Text immutableVersion;
immutableVersion = Copy();
FreeSelf();
return immutableVersion;
}
public function MutableText IntoMutableText()
{
return self;
}
/**
* Clears all current data from the caller `MutableText` instance.
*
@ -44,7 +57,7 @@ public final function MutableText Clear()
* @return Caller `MutableText` to allow for method chaining.
*/
public final function MutableText AppendRawCharacter(
Text.Character newCharacter,
BaseText.Character newCharacter,
optional Formatting characterFormatting)
{
if (!_.text.IsValidCharacter(newCharacter)) {
@ -70,8 +83,8 @@ public final function MutableText AppendRawCharacter(
* @return Caller `MutableText` to allow for method chaining.
*/
public final function MutableText AppendManyRawCharacters(
array<Text.Character> newCharacters,
optional Formatting charactersFormatting)
array<BaseText.Character> newCharacters,
optional Formatting charactersFormatting)
{
local int i;
SetFormatting(charactersFormatting);
@ -88,7 +101,8 @@ public final function MutableText AppendManyRawCharacters(
* Only valid characters will be added.
* @return Caller `MutableText` to allow for method chaining.
*/
public final function MutableText AppendCharacter(Text.Character newCharacter)
public final function MutableText AppendCharacter(
BaseText.Character newCharacter)
{
if (!_.text.IsValidCharacter(newCharacter)) {
return self;
@ -105,7 +119,7 @@ public final function MutableText AppendCharacter(Text.Character newCharacter)
* @return Caller `MutableText` to allow for method chaining.
*/
public final function MutableText AppendManyCharacters(
array<Text.Character> newCharacters)
array<BaseText.Character> newCharacters)
{
local int i;
for (i = 0; i < newCharacters.length; i += 1) {
@ -153,10 +167,10 @@ public final function MutableText AppendLineBreak()
}
/**
* Appends contents of another `Text` to the caller `MutableText`.
* Appends contents of another `BaseText` to the caller `MutableText`.
*
* @param other Instance of `Text`, which content method must
* append. Appends nothing if passed value is `none`.
* @param other Instance of `BaseText`, which content method
* will append. Appends nothing if passed value is `none`.
* @param defaultFormatting Formatting to apply to `other`'s character that
* do not have it specified. For example, `defaultFormatting.isColored`,
* but some of `other`'s characters do not have a color defined -
@ -164,7 +178,7 @@ public final function MutableText AppendLineBreak()
* @return Caller `MutableText` to allow for method chaining.
*/
public final function MutableText Append(
Text other,
BaseText other,
optional Formatting defaultFormatting)
{
local int i;
@ -255,7 +269,7 @@ public final function MutableText AppendColoredString(
{
if (i + 3 >= sourceLength) break;
newFormatting.isColored = true;
newFormatting.color = _.color.RGB(sourceAsIntegers[i + 1],
newFormatting.color = _.color.RGB( sourceAsIntegers[i + 1],
sourceAsIntegers[i + 2],
sourceAsIntegers[i + 3]);
i += 4;
@ -271,14 +285,14 @@ public final function MutableText AppendColoredString(
}
/**
* Appends contents of the formatted `Text` to the caller `MutableText`.
* Appends contents of the formatted `BaseText` to the caller `MutableText`.
*
* @param source `Text` (with formatted string contents) to be
* @param source `BaseText` (with formatted string contents) to be
* appended to the caller `MutableText`.
* @return Caller `MutableText` to allow for method chaining.
*/
public final function MutableText AppendFormatted(
Text source,
BaseText source,
optional Formatting defaultFormatting)
{
class'FormattingStringParser'.static.ParseFormatted(source, self);
@ -296,8 +310,8 @@ public final function MutableText AppendFormattedString(
string source,
optional Formatting defaultFormatting)
{
local Text sourceAsText;
sourceAsText = _.text.FromString(source);
local MutableText sourceAsText;
sourceAsText = _.text.FromStringM(source);
AppendFormatted(sourceAsText);
_.memory.Free(sourceAsText);
return self;
@ -316,10 +330,11 @@ protected function int CalculateHashCode()
}
/**
* Replaces every occurrence of the string `before` with the string `after`.
* Replaces every occurrence of the `Text` object `before` with
* the `Text` object `after`.
*
* @param before `Text` contents to match and then replace.
* @param after `Text` contents to replace `before` with.
* @param before `BaseText` contents to match and then replace.
* @param after `BaseText` contents to replace `before` with.
* @param caseSensitivity Defines whether `before` should be matched
* in a case-sensitive manner. By default it will be.
* @param formatSensitivity Defines whether `before` should be matched
@ -327,15 +342,15 @@ protected function int CalculateHashCode()
* @return Returns caller `MutableText`, to allow for method chaining.
*/
public final function MutableText Replace(
Text before,
Text after,
BaseText before,
BaseText after,
optional CaseSensitivity caseSensitivity,
optional FormatSensitivity formatSensitivity)
{
local int index;
local bool needToInsertReplacer;
local int nextReplacementIndex;
local Text selfCopy;
local int index;
local bool needToInsertReplacer;
local int nextReplacementIndex;
local BaseText selfCopy;
if (before == none) return self;
if (before.IsEmpty()) return self;
@ -372,10 +387,34 @@ public final function MutableText Replace(
}
/**
* Sets `newFormatting` for every non-formatted character in the caller `Text`.
* Replaces every occurrence of the string `before` with the string `after`.
*
* @param before `string` contents to match and then replace.
* @param after `string` contents to replace `before` with.
* @param caseSensitivity Defines whether `before` should be matched
* in a case-sensitive manner. By default it will be.
* @return Returns caller `MutableText`, to allow for method chaining.
*/
public final function MutableText ReplaceS(
string before,
string after,
optional CaseSensitivity caseSensitivity)
{
local MutableText beforeText, afterText;
beforeText = _.text.FromStringM(before);
afterText = _.text.FromStringM(after);
Replace(beforeText, afterText, caseSensitivity);
_.memory.Free(beforeText);
_.memory.Free(afterText);
return self;
}
/**
* Sets `newFormatting` for every non-formatted character in
* the caller `MutableText`.
*
* @param newFormatting Formatting to use for all non-formatted character in
* the caller `Text`. If `newFormatting` is not colored itself -
* the caller `MutableText`. If `newFormatting` is not colored itself -
* method does nothing.
* @return Returns caller `MutableText`, to allow for method chaining.
*/

92
sources/Text/Parser.uc

@ -19,7 +19,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class Parser extends AcediaObject
dependson(Text)
dependson(BaseText)
dependson(UnicodeData);
// Max value of a byte
@ -75,7 +75,7 @@ enum ParsedSign
// Common logic for parser initialization.
// Uses `source` as is, without copying, so public initialization method
// must do it itself.
private final function Parser _initialize(Text source)
private final function Parser _initialize(/*take*/ Text source)
{
if (source == none) return self;
@ -98,7 +98,7 @@ private final function Parser _initialize(Text source)
* If `none` is passed - parser won't be initialized.
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser Initialize(Text source)
public final function Parser Initialize(BaseText source)
{
if (source == none) {
return self;
@ -304,10 +304,10 @@ protected final function Parser ShiftPointer(optional int shift)
* invalid character if caller `Parser` was not initialized,
* its contents are empty or it has already consumed all input.
*/
protected final function Text.Character GetCharacter(optional int shift)
protected final function BaseText.Character GetCharacter(optional int shift)
{
local Text.Character invalidCharacter;
local int absoluteAddress;
local BaseText.Character invalidCharacter;
local int absoluteAddress;
if (content == none) return _.text.GetInvalidCharacter();
absoluteAddress = currentState.pointer + Max(0, shift);
@ -377,11 +377,12 @@ public final function bool HasFinished()
}
/**
* Returns still unparsed part of caller `Parser`'s source as `Text`.
* Returns still unparsed part of caller `Parser`'s source as `MutableText`.
*
* @return Unparsed part of caller `Parser`'s source as `Text`.
* @return Unparsed part of caller `Parser`'s source as `MutableText`.
* Guaranteed to be not-`none`.
*/
public final function Text GetRemainder()
public final function MutableText GetRemainderM()
{
local int i;
local MutableText result;
@ -392,6 +393,17 @@ public final function Text GetRemainder()
return result;
}
/**
* Returns still unparsed part of caller `Parser`'s source as `Text`.
*
* @return Unparsed part of caller `Parser`'s source as `Text`.
* Guaranteed to be not-`none`.
*/
public final function Text GetRemainder()
{
return GetRemainderM().IntoText();
}
/**
* Returns still unparsed part of caller `Parser`'s source as a plain `string`.
*
@ -475,8 +487,8 @@ public final function Parser Skip(optional out int whitespacesAmount)
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser Match(
Text word,
optional Text.CaseSensitivity caseSensitivity)
BaseText word,
optional BaseText.CaseSensitivity caseSensitivity)
{
local int i;
local int wordLength;
@ -513,8 +525,8 @@ public final function Parser Match(
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser MatchS(
string word,
optional Text.CaseSensitivity caseSensitivity)
string word,
optional BaseText.CaseSensitivity caseSensitivity)
{
local Text wrapper;
wrapper = _.text.FromString(word);
@ -639,7 +651,7 @@ protected final function int SafeIntegerCombination(
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser MEscapedSequence(
out Text.Character denotedCharacter)
out BaseText.Character denotedCharacter)
{
local int i;
if (!Ok()) return self;
@ -686,8 +698,8 @@ public final function Parser MEscapedSequence(
*/
public final function Parser MName(out MutableText result)
{
local TextAPI api;
local Text.Character nextCharacter;
local TextAPI api;
local BaseText.Character nextCharacter;
ResetResultText(result);
if (!Ok()) return self;
if (GetRemainingLength() <= 0) return Fail();
@ -753,10 +765,10 @@ public final function Parser MNameS(out string result)
*/
public final function Parser MStringLiteral(out MutableText result)
{
local TextAPI api;
local Text.Character nextCharacter;
local Text.Character usedQuotationMark;
local Text.Character escapedCharacter;
local TextAPI api;
local BaseText.Character nextCharacter;
local BaseText.Character usedQuotationMark;
local BaseText.Character escapedCharacter;
ResetResultText(result);
if (!Ok()) return self;
usedQuotationMark = GetCharacter();
@ -843,13 +855,13 @@ public final function Parser MStringLiteralS(out string result)
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser MUntil(
out MutableText result,
optional Text.Character characterBreak,
optional bool whitespacesBreak,
optional bool quotesBreak)
out MutableText result,
optional BaseText.Character characterBreak,
optional bool whitespacesBreak,
optional bool quotesBreak)
{
local Text.Character nextCharacter;
local TextAPI api;
local BaseText.Character nextCharacter;
local TextAPI api;
ResetResultText(result);
if (!Ok()) return self;
@ -889,10 +901,10 @@ public final function Parser MUntil(
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser MUntilS(
out string result,
optional Text.Character characterBreak,
optional bool whitespacesBreak,
optional bool quotesBreak)
out string result,
optional BaseText.Character characterBreak,
optional bool whitespacesBreak,
optional bool quotesBreak)
{
local MutableText wrapper;
if (!Ok()) return self;
@ -929,14 +941,14 @@ public final function Parser MUntilS(
*/
public final function Parser MUntilMany(
out MutableText result,
array<Text> separators,
array<BaseText> separators,
optional bool whitespacesBreak,
optional bool quotesBreak)
{
local bool foundEnd;
local int i, pointerShift;
local array<int> completions;
local Text.Character nextCharacter, separatorCharacter;
local bool foundEnd;
local int i, pointerShift;
local array<int> completions;
local BaseText.Character nextCharacter, separatorCharacter;
ResetResultText(result);
if (!Ok()) return self;
@ -1002,7 +1014,7 @@ public final function Parser MUntilMany(
*/
public final function Parser MUntilManyS(
out string result,
array<Text> separators,
array<BaseText> separators,
optional bool whitespacesBreak,
optional bool quotesBreak)
{
@ -1093,8 +1105,8 @@ public final function Parser MStringS(out string result)
*/
public final function Parser MWhitespaces(out MutableText result)
{
local Text.Character nextCharacter;
local TextAPI api;
local BaseText.Character nextCharacter;
local TextAPI api;
if (!Ok()) return self;
api = _.text;
@ -1148,7 +1160,7 @@ public final function Parser MWhitespacesS(out string result)
* Any passed value is discarded.
* @return Returns the caller `Parser`, to allow for function chaining.
*/
public final function Parser MCharacter(out Text.Character result)
public final function Parser MCharacter(out BaseText.Character result)
{
if (!Ok()) return self;
if (HasFinished()) return Fail();
@ -1170,7 +1182,7 @@ public final function Parser MCharacter(out Text.Character result)
*/
public final function Parser MByte(out byte result)
{
local Text.Character character;
local BaseText.Character character;
if (!Ok()) return self;
if (!MCharacter(character).Ok())

4
sources/Text/Tests/TEST_FormattedStrings.uc

@ -212,7 +212,7 @@ protected static function SubTest_TestGradientTwoColors()
TEST_ExpectTrue(currentColor.b == 56);
}
protected static function CheckRedDecrease(Text sample, int from, int to)
protected static function CheckRedDecrease(BaseText sample, int from, int to)
{
local int i;
local Color previousColor, currentColor;
@ -227,7 +227,7 @@ protected static function CheckRedDecrease(Text sample, int from, int to)
}
}
protected static function CheckRedIncrease(Text sample, int from, int to)
protected static function CheckRedIncrease(BaseText sample, int from, int to)
{
local int i;
local Color previousColor, currentColor;

BIN
sources/Text/Tests/TEST_Parser.uc

Binary file not shown.

BIN
sources/Text/Tests/TEST_Text.uc

Binary file not shown.

BIN
sources/Text/Tests/TEST_TextAPI.uc

Binary file not shown.

BIN
sources/Text/Tests/TEST_UTF8EncoderDecoder.uc

Binary file not shown.

1475
sources/Text/Text.uc

File diff suppressed because it is too large Load Diff

153
sources/Text/TextAPI.uc

@ -1,6 +1,6 @@
/**
* API that provides functions for working with characters and for creating
* `Text` and `Parser` instances.
* `Text`, `MutableText` and `Parser` instances.
* Copyright 2020 - 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
@ -19,7 +19,7 @@
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class TextAPI extends AcediaObject
dependson(Text);
dependson(BaseText);
/**
* Creates a new `Formatting` structure that defines a default,
@ -29,9 +29,9 @@ class TextAPI extends AcediaObject
*
* @return Empty formatting object.
*/
public final function Text.Formatting EmptyFormatting()
public final function BaseText.Formatting EmptyFormatting()
{
local Text.Formatting emptyFormatting;
local BaseText.Formatting emptyFormatting;
return emptyFormatting;
}
@ -43,9 +43,9 @@ public final function Text.Formatting EmptyFormatting()
* @param color Color that formatting must have.
* @return Formatting object that describes text colored with `color`.
*/
public final function Text.Formatting FormattingFromColor(Color color)
public final function BaseText.Formatting FormattingFromColor(Color color)
{
local Text.Formatting coloredFormatting;
local BaseText.Formatting coloredFormatting;
coloredFormatting.isColored = true;
coloredFormatting.color = color;
return coloredFormatting;
@ -62,8 +62,8 @@ public final function Text.Formatting FormattingFromColor(Color color)
* @return `true` if formattings are equal and `false` otherwise.
*/
public final function bool IsFormattingEqual(
Text.Formatting formatting1,
Text.Formatting formatting2)
BaseText.Formatting formatting1,
BaseText.Formatting formatting2)
{
if (formatting1.isColored != formatting2.isColored) {
return false;
@ -85,7 +85,7 @@ public final function bool IsFormattingEqual(
* @param character Character to test for lower case.
* @return `true` if given character is lower case.
*/
public final function bool IsLower(Text.Character character)
public final function bool IsLower(BaseText.Character character)
{
// Small Latin letters
if (character.codePoint >= 97 && character.codePoint <= 122) {
@ -113,7 +113,7 @@ public final function bool IsLower(Text.Character character)
* @param character Character to test for upper case.
* @return `true` if given character is upper case.
*/
public final function bool IsUpper(Text.Character character)
public final function bool IsUpper(BaseText.Character character)
{
// Capital Latin letters
if (character.codePoint >= 65 && character.codePoint <= 90) {
@ -136,7 +136,7 @@ public final function bool IsUpper(Text.Character character)
* @param codePoint Unicode code point to check for being a digit.
* @return `true` if given Unicode code point is a digit, `false` otherwise.
*/
public final function bool IsDigit(Text.Character character)
public final function bool IsDigit(BaseText.Character character)
{
if (character.codePoint >= 48 && character.codePoint <= 57) {
return true;
@ -152,7 +152,7 @@ public final function bool IsDigit(Text.Character character)
* @return `true` if given Unicode code point belongs to a latin alphabet,
* `false` otherwise.
*/
public final function bool IsAlpha(Text.Character character)
public final function bool IsAlpha(BaseText.Character character)
{
// Capital Latin letters
if (character.codePoint >= 65 && character.codePoint <= 90) {
@ -171,7 +171,7 @@ public final function bool IsAlpha(Text.Character character)
* @param character Character to check for being from ASCII.
* @return `true` if given character is a digit, `false` otherwise.
*/
public final function bool IsASCII(Text.Character character)
public final function bool IsASCII(BaseText.Character character)
{
if (character.codePoint >= 0 && character.codePoint <= 127) {
return true;
@ -189,7 +189,7 @@ public final function bool IsASCII(Text.Character character)
* @param character Character to check for being a whitespace.
* @return `true` if given character is a whitespace, `false` otherwise.
*/
public final function bool IsWhitespace(Text.Character character)
public final function bool IsWhitespace(BaseText.Character character)
{
switch (character.codePoint)
{
@ -232,7 +232,7 @@ public final function bool IsWhitespace(Text.Character character)
* @return `true` if given Unicode code point denotes one of the recognized
* quote symbols, `false` otherwise.
*/
public final function bool IsQuotationMark(Text.Character character)
public final function bool IsQuotationMark(BaseText.Character character)
{
if (character.codePoint == 0x0022) return true;
if (character.codePoint == 0x0027) return true;
@ -252,11 +252,11 @@ public final function bool IsQuotationMark(Text.Character character)
* `formatting`.
*/
// TODO: Validity checks fro non-negative input code points
public final function Text.Character CharacterFromCodePoint(
int codePoint,
optional Text.Formatting formatting)
public final function BaseText.Character CharacterFromCodePoint(
int codePoint,
optional BaseText.Formatting formatting)
{
local Text.Character result;
local BaseText.Character result;
result.codePoint = codePoint;
result.formatting = formatting;
return result;
@ -266,7 +266,7 @@ public final function Text.Character CharacterFromCodePoint(
* Extracts a character at position `position` from a given plain `string`.
*
* For extracting multiple character or character from colored/formatted
* `string` we advice to convert `string` into `Text` instead.
* `string` we advice to convert `string` into `BaseText` instead.
*
* @param source `string`, from which to extract the character.
* @param position Position of the character to extract, starts from `0`.
@ -274,11 +274,11 @@ public final function Text.Character CharacterFromCodePoint(
* If specified position is invalid (`< 0` or `>= Len(source)`),
* returns invalid character.
*/
public final function Text.Character GetCharacter(
public final function BaseText.Character GetCharacter(
string source,
optional int position)
{
local Text.Character result;
local BaseText.Character result;
if (position < 0) return GetInvalidCharacter();
if (position >= Len(source)) return GetInvalidCharacter();
@ -287,34 +287,34 @@ public final function Text.Character GetCharacter(
}
/**
* Auxiliary method for checking whether `Text` object defines an "empty"
* Auxiliary method for checking whether `BaseText` object defines an "empty"
* `string`. That is, if it's either `none` or has empty contents.
*
* It is added, since it allows to replace two common checks
* `text == none || text.IsEmpty()` with a nicer looking one:
* `_.text.IsEmpty(text)`.
*
* @param text `Text` to check for emptiness.
* @param text `BaseText` to check for emptiness.
* @return `true` iff either passed `text == none` or `text.IsEmpty()`.
*/
public final function bool IsEmpty(Text text)
public final function bool IsEmpty(BaseText text)
{
return (text == none || text.IsEmpty());
}
/**
* Converts given `Text` into a plain `string`, returns it's value and
* deallocates passed `Text`.
* Converts given `BaseText` into a plain `string`, returns it's value and
* deallocates passed `BaseText`.
*
* Method introduced to simplify a common use-case of converting returned copy
* of `Text` into a `string`, which required additional variable to store and
* later deallocate `Text` reference.
* of `BaseText` into a `string`, which required additional variable to store
* and later deallocate `BaseText` reference.
*
* @param toConvert `Text` to convert.
* @return `string` representation of passed `Text` as a plain `string`.
* @param toConvert `BaseText` to convert.
* @return `string` representation of passed `BaseText` as a plain string.
* Empty `string`, if `toConvert == none`.
*/
public final function string ToString(Text toConvert)
public final function string ToString(/*take*/ BaseText toConvert)
{
local string result;
if (toConvert != none) {
@ -325,18 +325,18 @@ public final function string ToString(Text toConvert)
}
/**
* Converts given `Text` into a colored `string`, returns it's value and
* deallocates passed `Text`.
* Converts given `BaseText` into a colored `string`, returns it's value and
* deallocates passed `BaseText`.
*
* Method introduced to simplify a common use-case of converting returned copy
* of `Text` into a `string`, which required additional variable to store and
* later deallocate `Text` reference.
* of `BaseText` into a `string`, which required additional variable to store
* and later deallocate `BaseText` reference.
*
* @param toConvert `Text` to convert.
* @return `string` representation of passed `Text` as a colored `string`.
* @param toConvert `BaseText` to convert.
* @return `string` representation of passed `BaseText` as a colored `string`.
* Empty `string`, if `toConvert == none`.
*/
public final function string ToColoredString(Text toConvert)
public final function string ToColoredString(/*take*/ Text toConvert)
{
local string result;
if (toConvert != none) {
@ -347,18 +347,18 @@ public final function string ToColoredString(Text toConvert)
}
/**
* Converts given `Text` into a formatted `string`, returns it's value and
* deallocates passed `Text`.
* Converts given `BaseText` into a formatted `string`, returns it's value and
* deallocates passed `BaseText`.
*
* Method introduced to simplify a common use-case of converting returned copy
* of `Text` into a `string`, which required additional variable to store and
* later deallocate `Text` reference.
* of `BaseText` into a `string`, which required additional variable to store
* and later deallocate `BaseText` reference.
*
* @param toConvert `Text` to convert.
* @return `string` representation of passed `Text` as a formatted `string`.
* @param toConvert `BaseText` to convert.
* @return `string` representation of passed `BaseText` as a formatted `string`.
* Empty `string`, if `toConvert == none`.
*/
public final function string ToFormattedString(Text toConvert)
public final function string ToFormattedString(/*take*/ BaseText toConvert)
{
local string result;
if (toConvert != none) {
@ -375,7 +375,7 @@ public final function string ToFormattedString(Text toConvert)
* @return `string` that consists only of a given character,
* if given character is valid. Empty `string` otherwise.
*/
public final function string CharacterToString(Text.Character character)
public final function string CharacterToString(BaseText.Character character)
{
if (!IsValidCharacter(character)) {
return "";
@ -404,7 +404,7 @@ public final function string CharacterToString(Text.Character character)
* `-1` if given character does not represent anything in the given base.
*/
public final function int CharacterToInt(
Text.Character character,
BaseText.Character character,
optional int base
)
{
@ -439,7 +439,9 @@ public final function int CharacterToInt(
* @return `true` if given character can be represented by a given code point
* and `false` otherwise.
*/
public final function bool IsCodePoint(Text.Character character, int codePoint)
public final function bool IsCodePoint(
BaseText.Character character,
int codePoint)
{
return (character.codePoint == codePoint);
}
@ -451,10 +453,10 @@ public final function bool IsCodePoint(Text.Character character, int codePoint)
* @return Returns formatting of the given character.
* Always returns 'null' (not colored) formatting for invalid characters.
*/
public final function Text.Formatting GetCharacterFormatting(
Text.Character character)
public final function BaseText.Formatting GetCharacterFormatting(
BaseText.Character character)
{
local Text.Formatting emptyFormatting;
local BaseText.Formatting emptyFormatting;
if(IsValidCharacter(character)) {
return character.formatting;
}
@ -469,9 +471,9 @@ public final function Text.Formatting GetCharacterFormatting(
* @return Same character as `character`, but with new formatting.
* Invalid characters are not altered.
*/
public final function Text.Character SetFormatting(
Text.Character character,
Text.Formatting newFormatting)
public final function BaseText.Character SetFormatting(
BaseText.Character character,
BaseText.Formatting newFormatting)
{
if(!IsValidCharacter(character)) {
return character;
@ -492,8 +494,8 @@ public final function Text.Character SetFormatting(
* `defaultColor`.
*/
public final function Color GetCharacterColor(
Text.Character character,
optional Color defaultColor)
BaseText.Character character,
optional Color defaultColor)
{
if (character.formatting.isColored) {
return character.formatting.color;
@ -508,9 +510,9 @@ public final function Color GetCharacterColor(
*
* @return Invalid character instance.
*/
public final function Text.Character GetInvalidCharacter()
public final function BaseText.Character GetInvalidCharacter()
{
local Text.Character result;
local BaseText.Character result;
result.codePoint = -1;
return result;
}
@ -521,7 +523,7 @@ public final function Text.Character GetInvalidCharacter()
* @param character Character to check.
* @return `true` if passed character is valid and `false` otherwise.
*/
public final function bool IsValidCharacter(Text.Character character)
public final function bool IsValidCharacter(BaseText.Character character)
{
return (character.codePoint >= 0);
}
@ -548,10 +550,10 @@ public final function bool IsValidCharacter(Text.Character character)
* `false` otherwise.
*/
public final function bool AreEqual(
Text.Character character1,
Text.Character character2,
optional Text.CaseSensitivity caseSensitivity,
optional Text.FormatSensitivity formatSensitivity
BaseText.Character character1,
BaseText.Character character2,
optional BaseText.CaseSensitivity caseSensitivity,
optional BaseText.FormatSensitivity formatSensitivity
)
{
// These handle checks with invalid characters
@ -572,7 +574,7 @@ public final function bool AreEqual(
}
/**
* Converts Unicode code point into it's lower case folding,
* Converts Unicode code point into its lower case folding,
* as defined by Unicode standard.
*
* @param codePoint Code point to convert into lower case.
@ -580,7 +582,7 @@ public final function bool AreEqual(
* not define any lower case folding (like "&" or "!") for given code point, -
* function returns given code point unchanged.
*/
public final function Text.Character ToLower(Text.Character character)
public final function BaseText.Character ToLower(BaseText.Character character)
{
local int newCodePoint;
newCodePoint =
@ -600,7 +602,7 @@ public final function Text.Character ToLower(Text.Character character)
* not define any upper case version (like "&" or "!") for given code point, -
* function returns given code point unchanged.
*/
public final function Text.Character ToUpper(Text.Character character)
public final function BaseText.Character ToUpper(BaseText.Character character)
{
local int newCodePoint;
newCodePoint =
@ -612,21 +614,21 @@ public final function Text.Character ToUpper(Text.Character character)
}
/**
* Prepares an array of parts from a given single `Text`.
* Prepares an array of parts from a given single `BaseText`.
* First character is treated as a separator with which the rest of
* the given `Text` is split into parts:
* the given `BaseText` is split into parts:
* ~ "/ab/c/d" => ["ab", "c", "d"]
* ~ "zWordzomgzz" => ["Word", "omg", "", ""]
*
* This method is useful to easily prepare array of words for `Parser`'s
* methods.
*
* @param source `Text` that contains separator with parts to
* @param source `BaseText` that contains separator with parts to
* separate and extract.
* @return Separated words. Empty array if passed `source` was empty,
* otherwise contains at least one element.
*/
public final function array<MutableText> Parts(Text source)
public final function array<MutableText> Parts(BaseText source)
{
local array<MutableText> result;
if (source == none) return result;
@ -757,16 +759,17 @@ public final function Parser NewParser()
}
/**
* Method for creating a new parser, initialized with contents of given `Text`.
* Method for creating a new parser, initialized with contents of given
* `BaseText`.
*
* @param source Returned `Parser` will be setup to parse the contents of
* the passed `Text`.
* the passed `BaseText`.
* If `none` value is passed, - parser won't be initialized.
* @return Guaranteed to be not `none` and contain a valid `Parser`.
* If passed argument also is not `none`, - guaranteed to be
* initialized with it's content.
*/
public final function Parser Parse(Text source)
public final function Parser Parse(BaseText source)
{
local Parser parser;
parser = NewParser();
@ -798,7 +801,7 @@ public final function Parser ParseString(string source)
* if given character is valid. Empty `Text` otherwise.
* Guaranteed to be not `none`.
*/
public final function Text FromCharacter(Text.Character character)
public final function Text FromCharacter(BaseText.Character character)
{
return _.text.FromString(CharacterToString(character));
}

8
sources/Users/User.uc

@ -88,8 +88,8 @@ public final function int GetKey()
* `_.users.PersistentStorageExists() == true`.
*/
public final function DBReadTask ReadPersistentData(
Text groupName,
Text dataName)
BaseText groupName,
BaseText dataName)
{
local DBReadTask task;
if (groupName == none) return none;
@ -123,8 +123,8 @@ public final function DBReadTask ReadPersistentData(
* `_.users.PersistentStorageExists() == true`.
*/
public final function DBWriteTask WritePersistentData(
Text groupName,
Text dataName,
BaseText groupName,
BaseText dataName,
AcediaObject data)
{
local DBWriteTask task;

2
sources/Users/UserAPI.uc

@ -53,7 +53,7 @@ public final function User Fetch(UserID userID)
* @return Corresponding `User` object. Guaranteed to be a valid non-`none`
* reference.
*/
public final function User FetchByIDHash(Text idHash)
public final function User FetchByIDHash(BaseText idHash)
{
local UserID userID;
local UserDatabase userDB;

2
sources/Users/UserDatabase.uc

@ -66,7 +66,7 @@ public final static function UserDatabase GetInstance()
* correctly initialized with given `idHash` (guaranteed not to happen for
* any valid id hashes).
*/
public final function UserID FetchUserID(Text idHash)
public final function UserID FetchUserID(BaseText idHash)
{
local int i;
local UserID.SteamID steamID;

4
sources/Users/UserID.uc

@ -129,7 +129,7 @@ private final function string GetSteamAccountTypeCharacter()
* @param steamID64 Steam64 ID's decimal representation.
* @return `SteamID` generated from a given Steam64 ID `steamID64`.
*/
public static final function SteamID GetSteamIDFromIDHash(Text steamID64)
public static final function SteamID GetSteamIDFromIDHash(BaseText steamID64)
{
local int i;
local SteamID newSteamID;
@ -170,7 +170,7 @@ public static final function SteamID GetSteamIDFromIDHash(Text steamID64)
* (can happen if caller `UserID` was already initialized
* or `steamID64 == none`).
*/
public final function bool Initialize(Text steamID64)
public final function bool Initialize(BaseText steamID64)
{
if (initialized) return false;
if (steamID64 == none) return false;

Loading…
Cancel
Save