Hpl2:Resources:script modules:stringparsing

From Frictional Wiki
Jump to navigation Jump to search

String Parsing Functions

The following block of code is a set of String Parsing Functions arranged by Apjjm. Note: These functions will be set out best using the Improved Notepad++ HPS Support.


These functions allow the user to convert a string either to an array of integers, an array of floats, or a single unsigned integer. There is full support for exponents, decimals and signs.


Download the code here .


Installation requires pasting the code either into your .hps file or an external file and utilising a Script Pre-Processer.

Documentation

float[] parseStringToFloatArray(string &in asString)

Parses all floats out of a given string (The start of a new float is assumed when a non-numeric or unexpected character appears). Signed decimals (.) and exponents (E) are supported.


int[] parseStringToIntArray(string &in asString)

Parses all integers out of a given string (decimals are treated as an unexpected character, however a signs and an exponent (E) is supported).


uint parseStringUInt(string &in asString)

Ignores all non-digit characters when parsing the string to construct a single unsigned integer. E.g. "123ab45" would return 12345, as would "12.3e-45". This is much faster than the other two parsing routines.