The Fly standard library is organised in namespaces. Import a namespace with import, then call its functions using the Fly input/output parameter convention: const parameters are read-only inputs, plain parameters receive the result.


fly.str

String utilities. All transform functions allocate a new string on the heap — the caller is responsible for freeing it.

import fly.str

Conversion

convert

public convert(const int src, string out)

Converts an integer to its decimal string representation.

ParameterDirectionDescription
srcinputinteger to convert
outoutputresulting string (heap-allocated)
string s
str.convert(42, s)   // s = "42"

Query

len

public len(const string src, int out)

Writes the number of characters in src into out.

isEmpty

public isEmpty(const string src, bool out)

Writes true into out if src has zero length.

contains

public contains(const string src, const string sub, bool out)

Writes true into out if sub appears anywhere in src.

startsWith

public startsWith(const string src, const string prefix, bool out)

Writes true into out if src begins with prefix.

endsWith

public endsWith(const string src, const string suffix, bool out)

Writes true into out if src ends with suffix.

indexOf

public indexOf(const string src, const string sub, int out)

Writes the index of the first occurrence of sub in src into out, or -1 if not found.

lastIndexOf

public lastIndexOf(const string src, const string sub, int out)

Writes the index of the last occurrence of sub in src into out, or -1 if not found.

equals

public equals(const string a, const string b, bool out)

Writes true into out if a and b are identical.

equalsIgnoreCase

public equalsIgnoreCase(const string a, const string b, bool out)

Writes true into out if a and b are equal ignoring case.

count

public count(const string src, const string sub, int out)

Writes the number of non-overlapping occurrences of sub in src into out.

Query example:

import fly.str

main() {
    string msg = "Hello, Fly!"
    int length
    bool empty
    bool found

    str.len(msg, length)            // length = 11
    str.isEmpty(msg, empty)         // empty  = false
    str.contains(msg, "Fly", found) // found  = true
}

Transform

All transform functions write a newly allocated string into out. The caller must free it when done, or use a smart pointer.

toUpper

public toUpper(const string src, string out)

Writes an upper-case copy of src into out.

toLower

public toLower(const string src, string out)

Writes a lower-case copy of src into out.

trim

public trim(const string src, string out)

Writes a copy of src with leading and trailing whitespace removed into out.

trimLeft

public trimLeft(const string src, string out)

Removes leading whitespace only.

trimRight

public trimRight(const string src, string out)

Removes trailing whitespace only.

substring

public substring(const string src, const int start, const int end, string out)

Writes the substring of src from index start (inclusive) to end (exclusive) into out.

replace

public replace(const string src, const string from, const string to, string out)

Writes a copy of src with all occurrences of from replaced by to into out.

repeat

public repeat(const string src, const int count, string out)

Writes src repeated count times into out.

concat

public concat(const string a, const string b, string out)

Writes the concatenation of a and b into out.

Transform example:

import fly.str

main() {
    string result
    str.concat("Hello, ", "Fly!", result)   // result = "Hello, Fly!"
    str.toUpper(result, result)             // result = "HELLO, FLY!"
}

fly.math

Coming soon.


fly.os

Coming soon.


fly.thread

Coming soon.