Awkl
Loading...
Searching...
No Matches
type Namespace Reference

Functions

number isTrue (any x)
 Check if variable is true: truthy of type number|bool
 
number isFalse (any x)
 Check if variable is false: falsy of type number|bool
 
number asUintN (number w, number n)
 Convert a number to an unsigned integer of a specified bit width.
 
number asIntN (number w, number n)
 Convert a number to a signed integer of a specified bit width.
 
number u64 (number n)
 Convert a number to a 64-bit unsigned integer.
 
number u32 (number n)
 Convert a number to a 32-bit unsigned integer.
 
number u16 (number n)
 Convert a number to a 16-bit unsigned integer.
 
number u8 (number n)
 Convert a number to a 8-bit unsigned integer.
 
number i64 (number n)
 Convert a number to a 64-bit signed integer.
 
number i32 (number n)
 Convert a number to a 32-bit signed integer.
 
number i16 (number n)
 Convert a number to a 16-bit signed integer.
 
number i8 (number n)
 Convert a number to a 8-bit signed integer.
 
number isUnassigned (any x)
 Check if variable is of type unassigned
 
number isNil (any x)
 Check if variable is of type unassigned. Alias for type::isUnassigned
 
number isUntyped (any x)
 Check if variable is of type untyped
 
number isNily (any x)
 Check if variable is of type unassigned or untyped
 
number isEmpty (any x)
 Check if variable is of type unassigned or untyped or string of length 0.
 
number isNull (any x)
 Check if variable is the null string i.e. of type string and of length 0.
 
number isZero (any x)
 Check if variable is of type number and of value 0.
 
number isNumber (any x)
 Check if variable is of type number
 
number isString (any x)
 Check if variable is of type string
 
number isBool (any x)
 Check if variable is of type number|bool
 
number isStrnum (any x)
 Check if variable is of type strnum
 
number isRegexp (any x)
 Check if variable is of type regexp
 
number isArray (any x)
 Check if variable is of type array
 
number isScalar (any x)
 Check if variable is of a primitive scalar type i.e. number, regexp, string, strnum, unassigned, number|bool
 
number isNumbery (any x)
 Check if variable is of type number, strnum or number|bool
 
number isNumeric (any x)
 Check if variable is of type number, strnum, number|bool or string that looks numeric.
 
number isStringy (any x)
 Check if variable is of type string or strnum
 
number isChar (any x)
 Check if variable is of type string and of length 1.
 
number isChary (any x)
 Check if variable is of type string or strnum and of length 1.
 
number isIndexedArray (any x, number i0=1)
 Check if variable is an array with numerical correlative numbers as keys.
 
number is (any x, string t)
 Check if string is of a certain type. Either a gawk builtin type or that has a boolean function type::is*
 
number isType (string t)
 Check if string is one of gawk's builtin types or that has a type::is* function.
 
number isPrimitiveType (string x)
 Check if string is one of gawk's builtin types i.e. array, number, regexp, string, strnum, unassigned, untyped, number|bool
 
number isArrayOf (any A, string type)
 Check if variable is an array of elements of a specific type.
 
auto areComparable (x, y)
 
number number (scalar x)
 Convert variable to a number
 
string string (scalar x)
 Convert variable to a string
 
regexp regexp (scalar x)
 Convert variable to a regexp
 
auto bool (scalar x) -> number|bool
 Convert variable to a number|bool
 
strnum strnum (scalar x)
 Convert variable to a strnum
 

Variables

bool true = awk::mkbool(1)
 True: 1 of type number|bool
 
bool false = awk::mkbool(0)
 False: 0 of type number|bool
 
number U64_MAX = 0xFFFFFFFFFFFFFFFF
 Maximum value for a 64-bit unsigned integer \(2^{64} - 1\).
 
number U32_MAX = 0xFFFFFFFF
 Maximum value for a 32-bit unsigned integer \(2^{32} - 1\).
 
number U16_MAX = 0xFFFF
 Maximum value for a 16-bit unsigned integer \(2^{16} - 1\).
 
number U8_MAX = 0xFF
 Maximum value for a 8-bit unsigned integer \(2^{8} - 1\).
 
unassigned nil
 Unassigned variable.
 

Function Documentation

◆ areComparable()

auto type::areComparable ( x ,
y  )

◆ asIntN()

number type::asIntN ( number w,
number n )

Convert a number to a signed integer of a specified bit width.

Parameters
wBit-width
nNumber to convert
Returns
The w-bit signed integer representation of n, i.e. wrapped around \(\left[-2^{w-1}, 2^{w-1} - 1\right)\)

◆ asUintN()

number type::asUintN ( number w,
number n )

Convert a number to an unsigned integer of a specified bit width.

Parameters
wBit-width
nNumber to convert
Returns
The w-bit unsigned integer representation of n, i.e. wrapped around \(\left[0, 2^{w} - 1\right)\)

◆ bool()

auto type::bool ( scalar x) -> number|bool

Convert variable to a number|bool

Parameters
xScalar value to convert
Returns
Value converted to a number|bool

◆ i16()

number type::i16 ( number n)

Convert a number to a 16-bit signed integer.

Parameters
nNumber to convert
Returns
The 16-bit signed integer representation of n, i.e. wrapped around \(\left[-2^{15}, 2^{15} - 1\right)\)

◆ i32()

number type::i32 ( number n)

Convert a number to a 32-bit signed integer.

Parameters
nNumber to convert
Returns
The 32-bit signed integer representation of n, i.e. wrapped around \(\left[-2^{31}, 2^{31} - 1\right)\)

◆ i64()

number type::i64 ( number n)

Convert a number to a 64-bit signed integer.

Parameters
nNumber to convert
Returns
The 64-bit signed integer representation of n, i.e. wrapped around \(\left[-2^{63}, 2^{63} - 1\right)\)

◆ i8()

number type::i8 ( number n)

Convert a number to a 8-bit signed integer.

Parameters
nNumber to convert
Returns
The 8-bit signed integer representation of n, i.e. wrapped around \(\left[-2^{7}, 2^{7} - 1\right)\)

◆ is()

number type::is ( any x,
string t )

Check if string is of a certain type. Either a gawk builtin type or that has a boolean function type::is*

Parameters
xVariable to check for its type
tType name
Returns
1 if variable is of a specific type. 0 otherwise
Note
if there is a type::is t function, the type checking is delegated to it

◆ isArray()

number type::isArray ( any x)

Check if variable is of type array

Parameters
xVariable to check for its type
Returns
1 if variable is of type array. 0 otherwise

◆ isArrayOf()

number type::isArrayOf ( any A,
string type )

Check if variable is an array of elements of a specific type.

Parameters
AArray to check
typeType name
Returns
1 is all of the array's elements are of the specified type. 0 otherwise

◆ isBool()

number type::isBool ( any x)

Check if variable is of type number|bool

Parameters
xVariable to check for its type
Returns
1 if variable is of type number|bool. 0 otherwise

◆ isChar()

number type::isChar ( any x)

Check if variable is of type string and of length 1.

Parameters
xVariable to check for its type
Returns
1 if variable is of type string and of length 1. 0 otherwise

◆ isChary()

number type::isChary ( any x)

Check if variable is of type string or strnum and of length 1.

Parameters
xVariable to check for its type
Returns
1 if variable is of type string or strnum and of length 1. 0 otherwise

◆ isEmpty()

number type::isEmpty ( any x)

Check if variable is of type unassigned or untyped or string of length 0.

Parameters
xVariable to check for its type
Returns
1 if variable is of type unassigned or untyped or string of length 0. 0 otherwise

◆ isFalse()

number type::isFalse ( any x)

Check if variable is false: falsy of type number|bool

Parameters
xVariable to check for its type
Returns
1 if variable is falsy of type number|bool. 0 otherwise

◆ isIndexedArray()

number type::isIndexedArray ( any x,
number i0 = 1 )

Check if variable is an array with numerical correlative numbers as keys.

Parameters
xVariable to check for its type
i0Starting index
Returns
1 if variable is of type array with numerical correlative numbers as keys. 0 otherwise

◆ isNil()

number type::isNil ( any x)

Check if variable is of type unassigned. Alias for type::isUnassigned

Parameters
xVariable to check for its type
Returns
1 if variable is of type unassigned. 0 otherwise

◆ isNily()

number type::isNily ( any x)

Check if variable is of type unassigned or untyped

Parameters
xVariable to check for its type
Returns
1 if variable is of type unassigned or untyped. 0 otherwise
Note
As far as I know this can also be done as x == 0 && x == ""

◆ isNull()

number type::isNull ( any x)

Check if variable is the null string i.e. of type string and of length 0.

Parameters
xVariable to check for its type
Returns
1 if variable is of type string and of length 0. 0 otherwise
Note
This is not the same as x == "" which is also thruthy for nily values

◆ isNumber()

number type::isNumber ( any x)

Check if variable is of type number

Parameters
xVariable to check for its type
Returns
1 if variable is of type number. 0 otherwise

◆ isNumbery()

number type::isNumbery ( any x)

Check if variable is of type number, strnum or number|bool

Parameters
xVariable to check for its type
Returns
1 if variable is of type number, strnum or number|bool. 0 otherwise

◆ isNumeric()

number type::isNumeric ( any x)

Check if variable is of type number, strnum, number|bool or string that looks numeric.

Parameters
xVariable to check for its type
Returns
1 if variable is of type number, strnum, number|bool or string that looks numeric. 0 otherwise
Note
Numeric strings as checked by this function comply with not having leading or trailing space characters and can be:
  • Composed only of ASCII digits (e.g. 123)
  • Prefixed by one plus + or one minus - sign (e.g. +1, -1)
  • Written with an according decimal mark character:
    • Dot . by default (e.g. 0.1, .1)
    • Another character (e.g. 0,1) if using a respective available locale or LC_NUMERIC environment variable and the -N or --use-lc-numeric gawk option is used
  • Written in scientific "e" notation (e.g. 1e2, 1e+2, 1e-2, 1E+2)
  • Written in hexadecimal (e.g. 0xff, 0XFF) if the -n or --non-decimal-data gawk option is used
Additionally if using -n or --non-decimal-data, numbers with leading zeros and that only have octal digits (01234567) will be interpreted in base 8, not base 10.
These strings are primarily those that can be coerced to an according number with arithmetic operations like +, -, *, /, etc., with the exception of those that have leading or trailing space characters.

◆ isPrimitiveType()

number type::isPrimitiveType ( string x)

Check if string is one of gawk's builtin types i.e. array, number, regexp, string, strnum, unassigned, untyped, number|bool

Parameters
xType name
Returns
1 if string is array, number, regexp, string, strnum, unassigned, untyped or number|bool. 0 otherwise

◆ isRegexp()

number type::isRegexp ( any x)

Check if variable is of type regexp

Parameters
xVariable to check for its type
Returns
1 if variable is of type regexp. 0 otherwise

◆ isScalar()

number type::isScalar ( any x)

Check if variable is of a primitive scalar type i.e. number, regexp, string, strnum, unassigned, number|bool

Parameters
xVariable to check for its type
Returns
1 if variable is of type number, regexp, string, strnum, unassigned, number|bool. 0 otherwise

◆ isString()

number type::isString ( any x)

Check if variable is of type string

Parameters
xVariable to check for its type
Returns
1 if variable is of type string. 0 otherwise

◆ isStringy()

number type::isStringy ( any x)

Check if variable is of type string or strnum

Parameters
xVariable to check for its type
Returns
1 if variable is of type string or strnum. 0 otherwise

◆ isStrnum()

number type::isStrnum ( any x)

Check if variable is of type strnum

Parameters
xVariable to check for its type
Returns
1 if variable is of type strnum. 0 otherwise

◆ isTrue()

number type::isTrue ( any x)

Check if variable is true: truthy of type number|bool

Parameters
xVariable to check for its type
Returns
1 if variable is truthy of type number|bool. 0 otherwise

◆ isType()

number type::isType ( string t)

Check if string is one of gawk's builtin types or that has a type::is* function.

Parameters
tType name
Returns
1 if the type exists i.e. is a gawk builtin or there is a type::is t function. 0 otherwise

◆ isUnassigned()

number type::isUnassigned ( any x)

Check if variable is of type unassigned

Parameters
xVariable to check for its type
Returns
1 if variable is of type unassigned. 0 otherwise

◆ isUntyped()

number type::isUntyped ( any x)

Check if variable is of type untyped

Parameters
xVariable to check for its type
Returns
1 if variable is of type untyped. 0 otherwise
Examples
opt_parse.awk.

◆ isZero()

number type::isZero ( any x)

Check if variable is of type number and of value 0.

Parameters
xVariable to check for its type
Returns
1 if variable is of type number and of value 0. 0 otherwise
Note
This is not the same as x == 0 which is also thruthy for nily values and "0" strnums

◆ number()

number type::number ( scalar x)

Convert variable to a number

Parameters
xScalar value to convert
Returns
Value converted to a number

◆ regexp()

regexp type::regexp ( scalar x)

Convert variable to a regexp

Parameters
xScalar value to convert
Returns
Value converted to a regexp

◆ string()

string type::string ( scalar x)

Convert variable to a string

Parameters
xScalar value to convert
Returns
Value converted to a string

◆ strnum()

strnum type::strnum ( scalar x)

Convert variable to a strnum

Parameters
xScalar value to convert
Returns
Value converted to a strnum

◆ u16()

number type::u16 ( number n)

Convert a number to a 16-bit unsigned integer.

Parameters
nNumber to convert
Returns
The 16-bit unsigned integer representation of n, i.e. wrapped around \(\left[0, 2^{16} - 1\right)\)

◆ u32()

number type::u32 ( number n)

Convert a number to a 32-bit unsigned integer.

Parameters
nNumber to convert
Returns
The 32-bit unsigned integer representation of n, i.e. wrapped around \(\left[0, 2^{32} - 1\right)\)

◆ u64()

number type::u64 ( number n)

Convert a number to a 64-bit unsigned integer.

Parameters
nNumber to convert
Returns
The 64-bit unsigned integer representation of n, i.e. wrapped around \(\left[0, 2^{64} - 1\right)\)

◆ u8()

number type::u8 ( number n)

Convert a number to a 8-bit unsigned integer.

Parameters
nNumber to convert
Returns
The 8-bit unsigned integer representation of n, i.e. wrapped around \(\left[0, 2^{8} - 1\right)\)

Variable Documentation

◆ false

bool type::false = awk::mkbool(0)

False: 0 of type number|bool

◆ nil

unassigned type::nil

Unassigned variable.

◆ true

bool type::true = awk::mkbool(1)

True: 1 of type number|bool

◆ U16_MAX

number type::U16_MAX = 0xFFFF

Maximum value for a 16-bit unsigned integer \(2^{16} - 1\).

◆ U32_MAX

number type::U32_MAX = 0xFFFFFFFF

Maximum value for a 32-bit unsigned integer \(2^{32} - 1\).

◆ U64_MAX

number type::U64_MAX = 0xFFFFFFFFFFFFFFFF

Maximum value for a 64-bit unsigned integer \(2^{64} - 1\).

◆ U8_MAX

number type::U8_MAX = 0xFF

Maximum value for a 8-bit unsigned integer \(2^{8} - 1\).