StringLiteral

Module

Implements the StringLiteral class.

StringLiteral

This type represents a string literal.

String literals are all null-terminated for compatibility with C APIs, but this is subject to change. String literals store their length as an integer, and this does not include the null terminator.

Aliases:

  • index = scalar<index>
  • type = string

Fields:

value

The underlying storage for the string literal.

Functions:

__init__

__init__(value: string) -> Self

Create a string literal from a builtin string type.

Args:

  • value (string): The string value.

Returns:

A string literal object.

__bool__

__bool__(self: Self) -> Bool

Convert the string to a bool value.

Returns:

True if the string is not empty.

__eq__

__eq__(self: Self, rhs: Self) -> Bool

Compare two string literals for equality.

Args:

  • rhs (Self): The string to compare.

Returns:

True if they are equal.

__ne__

__ne__(self: Self, rhs: Self) -> Bool

Compare two string literals for inequality.

Args:

  • rhs (Self): The string to compare.

Returns:

True if they are not equal.

__add__

__add__(self: Self, rhs: Self) -> Self

Concatenate two string literals.

Args:

  • rhs (Self): The string to concat.

Returns:

The concatenated string.

__len__

__len__(self: Self) -> Int

Get the string length.

Returns:

The length of this StringLiteral.

data

data(self: Self) -> pointer<scalar<si8>>

Get raw pointer to the underlying data.

Returns:

The raw pointer to the data.