6#include <memory_resource>
8#include <nk/value/value.hpp>
9#include <nk/value/span.hpp>
11namespace nk::builtin {
46Value num2str(
const Value &x,
const std::string &fmt, std::pmr::memory_resource *mr =
nullptr);
232Value strjoin(
const Value &c,
const std::string &delim =
" ", std::pmr::memory_resource *mr =
nullptr);
261Value strsplit(
const Value &s,
const std::string &delim =
" ", std::pmr::memory_resource *mr =
nullptr);
449Value strjust(
const Value &M,
const std::string &side =
"left", std::pmr::memory_resource *mr =
nullptr);
594Value rat(
const Value &x,
double tol = 0.0, std::pmr::memory_resource *mr =
nullptr);
602Value rats(
const Value &x,
int len = 13, std::pmr::memory_resource *mr =
nullptr);
609std::pair<Value, Value>
strtok(
const Value &str,
const std::string &delim =
" \t\n\r", std::pmr::memory_resource *mr =
nullptr);
664Value regexptranslate(
const std::string &type,
const std::string &str, std::pmr::memory_resource *mr =
nullptr);
Core MATLAB-compatible multidimensional array and scalar value type.
static const Value Empty
MATLAB-style empty matrix sentinel — a 0×0 DOUBLE value.
std::string dispFormat(const Value &a)
Formats Value for terminal display via disp.
Value extract(const Value &s, const Value &pat, std::pmr::memory_resource *mr=nullptr)
Extracts substring matching pattern (extract(s, pat)).
Value regexpFindOnce(const Value &s, const Value &pat, const std::string &option, bool ignoreCase, std::pmr::memory_resource *mr=nullptr)
Regular expression search once helper.
Value regexprep(const Value &str, const Value &pat, const Value &rep, bool ignoreCase=false, bool once=false, std::pmr::memory_resource *mr=nullptr)
Regular expression replacement (regexprep(str, pat, rep, ignoreCase, once)).
Value replaceBetween(const Value &s, const Value &start, const Value &end, const Value &newText, std::pmr::memory_resource *mr=nullptr)
Replaces text between specified start and end boundaries (replaceBetween(s, start,...
Value isstringscalar(const Value &s, std::pmr::memory_resource *mr=nullptr)
Tests if input is a scalar string (isstringscalar(s)).
Value isletter(const Value &s, std::pmr::memory_resource *mr=nullptr)
Tests if characters are letters (isletter(s)).
Value strncmpi(const Value &s1, const Value &s2, size_t n, std::pmr::memory_resource *mr=nullptr)
Compares first n characters of strings ignoring case (strncmpi(s1, s2, n)).
Value convertStringsToChars(const Value &x, std::pmr::memory_resource *mr=nullptr)
Converts string arrays in input to character vectors (convertStringsToChars(x)).
Value strjoin(const Value &c, const std::string &delim=" ", std::pmr::memory_resource *mr=nullptr)
Joins string array or cell array of strings with delimiter (strjoin(c, delim)).
Value strjust(const Value &M, const std::string &side="left", std::pmr::memory_resource *mr=nullptr)
Justifies character matrix (strjust(M, side)).
Value extractBefore(const Value &s, const Value &p, std::pmr::memory_resource *mr=nullptr)
Extracts substrings before specified pattern or position (extractBefore(s, p)).
Value rats(const Value &x, int len=13, std::pmr::memory_resource *mr=nullptr)
Formats numbers as rational string representations (rats(x, len)).
Value lower(const Value &s, std::pmr::memory_resource *mr=nullptr)
Converts string to lowercase (lower(s)).
Value matches(const Value &str, const Value &pat, std::pmr::memory_resource *mr=nullptr)
Tests if strings match pattern (matches(str, pat)).
Value count(const Value &str, const Value &pat, std::pmr::memory_resource *mr=nullptr)
Counts occurrences of pattern in string (count(str, pat)).
Value num2hex(const Value &x, std::pmr::memory_resource *mr=nullptr)
Converts double-precision floating-point number to 16-character hexadecimal string (num2hex(x)).
Value stringsND(Span< const size_t > dims, std::pmr::memory_resource *mr=nullptr)
Constructs an N-dimensional array of empty strings.
Value char_array(const Value &x, std::pmr::memory_resource *mr=nullptr)
Converts input to character array (char(x)).
Value dec2bin(const Value &d, int minDigits=0, std::pmr::memory_resource *mr=nullptr)
Decimal to binary string (dec2bin(d, minDigits)).
Value isstrprop(const Value &s, const std::string &category, std::pmr::memory_resource *mr=nullptr)
Tests if characters have specified string property (isstrprop(s, category)).
Value pad(const Value &s, size_t n, const Value &side=Value(), const Value &padChar=Value(), std::pmr::memory_resource *mr=nullptr)
Pads string to fixed length (pad(s, n, side, padChar)).
Value isspaceFn(const Value &s, std::pmr::memory_resource *mr=nullptr)
Tests if characters are whitespace (internal helper returning Value).
Value str2double(const Value &s, std::pmr::memory_resource *mr=nullptr)
Converts text to double precision numeric values (str2double(s)).
Value replace(const Value &s, const Value &oldPat, const Value &newPat, std::pmr::memory_resource *mr=nullptr)
Replaces substring pattern with new pattern in string array (replace(s, oldPat, newPat)).
Value strip(const Value &s, std::pmr::memory_resource *mr=nullptr)
Strips leading and trailing whitespace from string array (strip(s)).
Value convertContainedStringsToChars(const Value &v, std::pmr::memory_resource *mr=nullptr)
Recursively converts all contained strings in cells/structs to character vectors.
Value dec2base(const Value &d, int base, int minDigits=0, std::pmr::memory_resource *mr=nullptr)
Decimal to base-N string (dec2base(d, base, minDigits)).
Value strtrim(const Value &s, std::pmr::memory_resource *mr=nullptr)
Removes leading and trailing whitespace (strtrim(s)).
Value contains(const Value &str, const Value &pat, bool ignoreCase=false, std::pmr::memory_resource *mr=nullptr)
Checks if string contains pattern (contains(str, pat)).
Value hex2num(const Value &s, std::pmr::memory_resource *mr=nullptr)
Converts 16-character hexadecimal string to IEEE double-precision floating-point number (hex2num(s)).
Value extractBetween(const Value &s, const Value &start, const Value &end, std::pmr::memory_resource *mr=nullptr)
Extracts substrings between specified boundaries (extractBetween(s, start, end)).
size_t countFormatSpecs(const std::string &fmt)
Counts number of conversion specifiers in format string.
Value compose(const Value &fmt, const Value &x, std::pmr::memory_resource *mr=nullptr)
Formats data into string array (compose(fmt, x)).
Value str2num(const Value &s, std::pmr::memory_resource *mr=nullptr)
Converts string representation to numeric matrix (str2num(s)).
Value strlength(const Value &s, std::pmr::memory_resource *mr=nullptr)
Returns number of characters in each string element (strlength(s)).
Value split(const Value &s, const Value &delim=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Splits string array elements by delimiter (split(s, delim)).
Value toString(const Value &x, std::pmr::memory_resource *mr=nullptr)
Alias for string_array conversion (string(x)).
Value extractAfter(const Value &s, const Value &p, std::pmr::memory_resource *mr=nullptr)
Extracts substrings after specified pattern or position (extractAfter(s, p)).
Value newline(std::pmr::memory_resource *mr=nullptr)
Creates newline character string (newline).
Value isspace(const Value &s, std::pmr::memory_resource *mr=nullptr)
Tests if characters are whitespace (isspace(s)).
Value num2str(const Value &x, std::pmr::memory_resource *mr=nullptr)
Formats numeric array into character vector (num2str(x)).
Value endsWith(const Value &str, const Value &pat, bool ignoreCase=false, std::pmr::memory_resource *mr=nullptr)
Checks if string ends with pattern (endsWith(str, pat)).
Value regexptranslate(const std::string &type, const std::string &str, std::pmr::memory_resource *mr=nullptr)
Translates wildcard strings to regular expressions (regexptranslate(type, str)).
Value newlineFn(std::pmr::memory_resource *mr=nullptr)
Generates newline character as string Value.
Value validatestring(const Value &str, const Value &validStrings, std::pmr::memory_resource *mr=nullptr)
Validates text against list of valid strings (validatestring(str, validStrings)).
Value string_array(const Value &x, std::pmr::memory_resource *mr=nullptr)
Converts input to string array (string(x)).
Value strrep(const Value &orig, const Value &oldStr, const Value &newStr, std::pmr::memory_resource *mr=nullptr)
Replaces occurrences of substring within string (strrep(orig, old, new)).
Value startsWith(const Value &str, const Value &pat, bool ignoreCase=false, std::pmr::memory_resource *mr=nullptr)
Checks if string starts with pattern (startsWith(str, pat)).
Value insertAfter(const Value &s, const Value &p, const Value &newText, std::pmr::memory_resource *mr=nullptr)
Inserts text after specified position or pattern (insertAfter(s, p, newText)).
Value deblank(const Value &s, std::pmr::memory_resource *mr=nullptr)
Removes trailing whitespace (deblank(s)).
Value bin2dec(const Value &s, std::pmr::memory_resource *mr=nullptr)
Binary string to decimal (bin2dec(s)).
Value splitlines(const Value &s, std::pmr::memory_resource *mr=nullptr)
Splits string into separate lines (splitlines(s)).
Value insertBefore(const Value &s, const Value &p, const Value &newText, std::pmr::memory_resource *mr=nullptr)
Inserts text before specified position or pattern (insertBefore(s, p, newText)).
Value convertCharsToStrings(const Value &x, std::pmr::memory_resource *mr=nullptr)
Converts character arrays in input to string arrays (convertCharsToStrings(x)).
Value toChar(const Value &x, std::pmr::memory_resource *mr=nullptr)
Alias for char_array conversion (char(x)).
std::string formatCyclic(const std::string &fmt, Span< const Value > args, size_t argStart=0, std::pmr::memory_resource *mr=nullptr)
Formats cyclic repetition of format specification across array elements.
Value strcmpi(const Value &s1, const Value &s2, std::pmr::memory_resource *mr=nullptr)
Compares strings for equality ignoring case (strcmpi(s1, s2)).
Value dec2hex(const Value &d, int minDigits=0, std::pmr::memory_resource *mr=nullptr)
Decimal to hexadecimal string (dec2hex(d, minDigits)).
Value int2str(const Value &x, std::pmr::memory_resource *mr=nullptr)
Formats integer into character vector (int2str(x)).
Value strncmp(const Value &s1, const Value &s2, size_t n, std::pmr::memory_resource *mr=nullptr)
Compares first n characters of strings (case-sensitive) (strncmp(s1, s2, n)).
Value rat(const Value &x, double tol=0.0, std::pmr::memory_resource *mr=nullptr)
Rational approximation as fraction / continued fraction (rat(x, tol)).
Value mat2str(const Value &x, std::pmr::memory_resource *mr=nullptr)
Formats matrix into MATLAB syntax string (mat2str(x)).
Value reverse(const Value &str, std::pmr::memory_resource *mr=nullptr)
Reverses characters in string (reverse(str)).
Value join(const Value &arr, const Value &delim=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Combines elements of string array into single string (join(arr, delim)).
Value regexpi(const Value &str, const Value &pat, std::pmr::memory_resource *mr=nullptr)
Case-insensitive regular expression matching (regexpi(str, pat)).
Value regexpFind(const Value &s, const Value &pat, const std::string &option, bool ignoreCase, std::pmr::memory_resource *mr=nullptr)
Regular expression search helper.
Value hex2dec(const Value &s, std::pmr::memory_resource *mr=nullptr)
Hexadecimal string to decimal (hex2dec(s)).
Value eraseBetween(const Value &s, const Value &start, const Value &end, std::pmr::memory_resource *mr=nullptr)
Erases text between specified boundaries (eraseBetween(s, start, end)).
std::pair< Value, Value > strtok(const Value &str, const std::string &delim=" \t\n\r", std::pmr::memory_resource *mr=nullptr)
Extracts first token from character vector up to delimiter ([token, rem] = strtok(str,...
Value regexp(const Value &str, const Value &pat, std::pmr::memory_resource *mr=nullptr)
Regular expression matching (regexp(str, pat)).
Value upper(const Value &s, std::pmr::memory_resource *mr=nullptr)
Converts string to uppercase (upper(s)).
Value append(Span< const Value > parts, std::pmr::memory_resource *mr=nullptr)
Appends multiple strings element-wise (append(s1, s2, ...)).
std::string formatOnce(const std::string &fmt, Span< const Value > args, size_t argStart=0, bool literalWhenShort=false)
Formats single pass of format specification.
Value blanks(size_t n, std::pmr::memory_resource *mr=nullptr)
Creates character vector of blank spaces (blanks(n)).
Value base2dec(const Value &s, int base, std::pmr::memory_resource *mr=nullptr)
Base-N string to decimal (base2dec(s, base)).
Value strcat(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Concatenates strings horizontally (strcat(s1, s2, ...)).
Value erase(const Value &s, const Value &pat, std::pmr::memory_resource *mr=nullptr)
Erases occurrences of substring pattern from string (erase(s, pat)).
Value strsplit(const Value &s, const std::string &delim=" ", std::pmr::memory_resource *mr=nullptr)
Splits string by delimiter string (strsplit(s, delim)).
Value strcmp(const Value &s1, const Value &s2, std::pmr::memory_resource *mr=nullptr)
Compares strings for exact equality (case-sensitive) (strcmp(s1, s2)).
Value strfind(const Value &text, const Value &pattern, std::pmr::memory_resource *mr=nullptr)
Finds occurrences of substring within string (strfind(text, pattern)).