Skip to content

Utilities

Functions

Base64 Decode

Converts the provided Base64 encoded string back to its original form. For example, “TWFu” will be converted to “Man”.

Parameters:

NameTypeDescription
inputStringBase64 encoded string to decode

Return Type: String

Signatures:

string base64_decode(const string &input)

Base64 Encode

Converts the provided string into its Base64 encoded representation. For example, “Man” will be converted to “TWFu”.

Parameters:

NameTypeDescription
inputStringString to encode

Return Type: String

Signatures:

string base64_encode(const string &input)

Bin To Dec

Converts the provided binary string into an unsigned integer. For example, “1010” will be converted to 10.

Parameters:

NameTypeDescription
binStringBinary string to convert

Return Type: Unsigned Integer

Signatures:

unsigned int bin_to_dec(const string &bin)

Bin To Hex

Converts the provided binary string into a hexadecimal string representation. For example, “1010” will be converted to “A”.

Parameters:

NameTypeDescription
bin_strStringBinary string to convert

Return Type: String

Signatures:

string bin_to_hex(const string &bin_str)

Bin To Oct

Converts the provided binary string into its octal string representation. For example, “1010” will be converted to “12”.

Parameters:

NameTypeDescription
bin_strStringBinary string to convert

Return Type: String

Signatures:

string bin_to_oct(const string &bin_str)

Calculate Square Root

Calculates the square root of the provided number using the Newton-Raphson method.

Parameters:

NameTypeDescription
numberIntegerNumber to calculate the square root of

Return Type: Double

Signatures:

double calculate_square_root(int number)

Contains

Returns true if the string contains the substring.

Parameters:

NameTypeDescription
textStringThe text to search
subtextStringThe substring to search for

Return Type: Boolean

Signatures:

bool contains(const string &text, const string &subtext)

Convert To Double

Convert the passed in string into a double. This can fail in an error if the value is not a number, consider using Is Number to check before converting a string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: Double

Usage:

Signatures:

double convert_to_double(const string &text)

Convert To Integer

Convert the passed in string into an integer. This can fail in an error if the value is not an integer, consider using Is Integer to check before converting a string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: Integer

Usage:

Signatures:

int convert_to_integer(const string &text)

Dec To Bin

Converts the provided unsigned integer into a binary string. For example, 10 will be converted to “1010”.

Parameters:

NameTypeDescription
decunsigned intDecimal (unsigned integer) to convert

Return Type: String

Signatures:

string dec_to_bin(unsigned int dec)

Dec To Oct

Converts the provided decimal value into its octal string representation. For example, 64 will be converted to “100”.

Parameters:

NameTypeDescription
decimal_valueunsigned intDecimal (unsigned integer) to convert

Return Type: String

Signatures:

string dec_to_oct(unsigned int decimal_value)

Greatest Common Divisor

The greatest common divisor (GCD) of two numbers is the largest positive integer that divides both numbers without a remainder.

Parameters:

NameTypeDescription
number1IntegerFirst number
number2IntegerSecond number

Return Type: Integer

Signatures:

int greatest_common_divisor(int number1, int number2)

Hex To Bin

Converts the provided hexadecimal string into its binary string representation. For example, “A” will be converted to “1010”.

Parameters:

NameTypeDescription
hex_strStringHexadecimal string to convert

Return Type: String

Signatures:

string hex_to_bin(const string &hex_str)

Hex To Oct

Converts the provided hexadecimal string into its octal string representation. For example, “A” will be converted to “12”.

Parameters:

NameTypeDescription
hex_strStringHexadecimal string to convert

Return Type: String

Signatures:

string hex_to_oct(const string &hex_str)

Index Of

Returns the index of the first occurrence of the substring in the text.

Parameters:

NameTypeDescription
textStringThe text to search
subtextStringThe substring to search for

Return Type: Integer

Signatures:

int index_of(const string &text, const string &subtext)

Is Binary

A binary string is a string that contains only ‘0’ and ‘1’ characters.

Parameters:

NameTypeDescription
bin_strStringBinary string to check

Return Type: Boolean

Signatures:

bool is_binary(const string &bin_str)

Is Double

Checks if a string contains a number.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Signatures:

bool is_double(const string &text)

Is Hex

A hexadecimal string is a string that contains only characters from ‘0’ to ‘9’ and ‘A’ to ‘F’ (or ‘a’ to ‘f’).

Parameters:

NameTypeDescription
hex_strStringHexadecimal string to check

Return Type: Boolean

Signatures:

bool is_hex(const string &hex_str)

Is Integer

Checks if a string contains an integer value.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Usage:

Signatures:

bool is_integer(const string &text)

Is Number

Checks if a string contains a number.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Usage:

Signatures:

bool is_number(const string &text)

Is Octal

An octal string is a string that contains only characters from ‘0’ to ‘7’.

Parameters:

NameTypeDescription
octal_strStringOctal string to check

Return Type: Boolean

Signatures:

bool is_octal(const string &octal_str)

Is Prime Number

A prime number is a number greater than 1 that has no positive divisors other than 1 and itself.

Parameters:

NameTypeDescription
numberIntegerNumber to check

Return Type: Boolean

Signatures:

bool is_prime_number(int number)

Least Common Multiple

The least common multiple (LCM) of two numbers is the smallest positive integer that is divisible by both numbers.

Parameters:

NameTypeDescription
number1IntegerFirst number
number2IntegerSecond number

Return Type: Integer

Signatures:

int least_common_multiple(int number1, int number2)

Length Of

Returns the length of a string in characters.

Parameters:

NameTypeDescription
textStringThe text to get the length of

Return Type: Integer

Usage:

See Example Code

Signatures:

int length_of(const string &text)

Oct To Bin

Converts the provided octal string into its binary string representation. For example, “12” will be converted to “1010”.

Parameters:

NameTypeDescription
octal_strStringOctal string to convert

Return Type: String

Signatures:

string oct_to_bin(const string &octal_str)

Oct To Dec

Converts the provided octal string into its decimal representation. For example, “100” will be converted to 64.

Parameters:

NameTypeDescription
octal_stringStringOctal string to convert

Return Type: Unsigned Integer

Signatures:

unsigned int oct_to_dec(const string &octal_string)

Oct To Hex

Converts the provided octal string into its hexadecimal string representation. For example, “12” will be converted to “A”.

Parameters:

NameTypeDescription
oct_strStringOctal string to convert

Return Type: String

Signatures:

string oct_to_hex(const string &oct_str)

Replace All

Replace all occurrences of a substring in a string with another string.

Parameters:

NameTypeDescription
textStringThe text to search
substrStringThe substring to find and replace
newTextStringThe string to replace the substring with

Return Type: String

Signatures:

string replace_all(const string &text, const string &substr, const string &newText)

Split

Split a string into an array of strings based on a delimiter.

Parameters:

NameTypeDescription
textStringThe text to split
delimiterCharThe character to split the text on

Return Type: Vector

Signatures:

vector<string> split(const string &text, char delimiter)

To Lowercase

Return a lowercase version of the passed in string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: String

Usage:

Signatures:

string to_lowercase(const string &text)

To Uppercase

Return a UPPERCASE version of the passed in string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: String

Usage:

Signatures:

string to_uppercase(const string &text)

Trim

Return a new string that removes the spaces from the start and end of the input string.

Parameters:

NameTypeDescription
textStringThe string to trim.

Return Type: String

Usage:

Signatures:

string trim(const string &text)

Rnd

Rnd

Generates a random number between ‘min’ and max, including ‘min’ and ‘max’.

Parameters:

NameTypeDescription
minIntegerthe Integer representing of minimum bound.
maxIntegerthe Integer representing of maximum bound.

Return Type: Integer

Signatures:

int rnd(int min, int max)

Rnd

Generates a random number between 0 and 1

Return Type: Float

Signatures:

float rnd()

Rnd

Generates a random number between 0 and ubound.

Parameters:

NameTypeDescription
uboundIntegerthe Integer representing the upper bound.

Return Type: Integer

Signatures:

int rnd(int ubound)

Current Ticks

Gets the number of milliseconds that have passed since the program was started.

Return Type: Unsigned Integer

Signatures:

unsigned int current_ticks()

Delay

Puts the program to sleep for a specified number of milliseconds. If this is larger than 1 second, SplashKit will check to see if the user tries to quit during the delay. If the user does quit, the delay function returns without waiting.

Parameters:

NameTypeDescription
millisecondsIntegerThe number of milliseconds to wait

Usage:

Signatures:

void delay(int milliseconds)

Display Dialog

Display a dialog to the screen with a message for the user.

Parameters:

NameTypeDescription
titleStringThe title of the dialog window.
msgStringThe message for the dialog window.
output_fontFontThe font for the dialog text
font_sizeIntegerThe size of the font for the dialog text

Signatures:

void display_dialog(const string &title, const string &msg, font output_font, int font_size)

File As String

Return a SplashKit resource of Resource Kind with name filename as a string.

Parameters:

NameTypeDescription
filenameStringThe filename of the resource.
kindResource KindThe kind of resource.

Return Type: String

Signatures:

string file_as_string(string filename, resource_kind kind)