Module StringBuilder

An object class used for efficiently converting a table to a string.

Lua is more efficient at building strings using an intermediate sequential table of elements that are later concatenated together. This object class is provided for this purpose.

Type StringBuilder

StringBuilder.ID

Contains the name of the object type (StringBuilder)

StringBuilder.Writer(anyObj)

Efficiently convert any object that has a WriteUsing method into a string.

StringBuilder:__tostring()

Constructs the concatenated string representing all of the added elements.

StringBuilder:add(...)

Adds one or more items to the end of the StringBuilder list.

StringBuilder.new(...)

Constructs a new StringBuilder object.

StringBuilder:prepend(...)

Adds one or more items to the beginining of the StringBuilder list.

StringBuilder:reset()

Empties the StringBuilder contents.

Type StringBuilder

Field(s)

#string StringBuilder.ID

Contains the name of the object type (StringBuilder)

StringBuilder.Writer(anyObj)

Efficiently convert any object that has a WriteUsing method into a string.

This is a static function that can be used to quickly convert any object into its string representation. The object must have its own WriteUsing method that handles the technical details of the conversion to string.

Parameter

  • anyObj : Any object that supports the WriteUsing method call.

Return value

#string: A single string representing the provided object.

StringBuilder:__tostring()

Constructs the concatenated string representing all of the added elements.

Return value

#string: A single string with all added elements concatenated together.

StringBuilder:add(...)

Adds one or more items to the end of the StringBuilder list.

Parameter

  • ... : A list of items to add.

StringBuilder.new(...)

Constructs a new StringBuilder object.

Parameter

  • ... : A series of items that will be included in the initial StringBuilder list.

Return value

#StringBuilder: A new StringBuilder object.

StringBuilder:prepend(...)

Adds one or more items to the beginining of the StringBuilder list.

Parameter

  • ... : A list of items to add.

StringBuilder:reset()

Empties the StringBuilder contents.

Copyright © 2020 NoteWorthy Software™, Inc.
All Rights Reserved.