Keywords, variable naming rules, error/warning handling, exception structures, and interactive discovery (help, what). More...
Files | |
| file | lang.hpp |
| Language keywords, variable name validation, process environment, and diagnostics. | |
| file | diagnostics.hpp |
| file | help.hpp |
| file | standard_library.hpp |
Classes | |
| struct | nk::runtime::LastWarn |
| Snapshot of the most-recent warning. More... | |
| class | nk::bundle::HelpLibrary |
| Installs MATLAB-compatible help and documentation commands into the script Engine. More... | |
| class | nk::StandardLibrary |
Functions | |
| void | nk::builtin::setenv (const std::string &name, const std::string &value="") |
| Sets or clears an operating system environment variable (setenv(name, value)). | |
| std::string | nk::builtin::getenv (const std::string &name) |
| Reads an operating system environment variable as a C++ string (getenv(name)). | |
| Value | nk::builtin::getenv (const Value &name, std::pmr::memory_resource *mr=nullptr) |
| Reads an environment variable returning a character row Value (val = getenv(name)). | |
| bool | nk::builtin::iskeyword (const std::string &name) |
| Tests whether a string is a reserved MATLAB language keyword (iskeyword(s)). | |
| const std::vector< std::string > & | nk::builtin::keywords () |
| Lists all reserved MATLAB keywords as a C++ vector. | |
| Value | nk::builtin::iskeyword (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| MATLAB-compatible overload for iskeyword. | |
| bool | nk::builtin::isvarname (const std::string &name) |
| Tests whether a string is a valid MATLAB variable name (isvarname(s)). | |
| Value | nk::builtin::isvarname (const Value &name, std::pmr::memory_resource *mr=nullptr) |
| MATLAB-compatible overload for isvarname. | |
| Value | nk::builtin::isvarname (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Span-based MATLAB-compatible overload for isvarname. | |
| void | nk::runtime::registerDiagnosticsRuntime (Engine &engine) |
| void | nk::runtime::error (Span< const Value > args) |
| Throw an Error (error(...)). | |
| void | nk::runtime::warning (Engine &engine, Span< const Value > args) |
| Engine-stateful warning (warning(...)). | |
| LastWarn | nk::runtime::lastwarnGet () |
| Read most-recent warning state ([msg, id] = lastwarn()). | |
| void | nk::runtime::lastwarnSet (const std::string &msg, const std::string &id) |
| Overwrite the most-recent warning state. | |
| Value | nk::runtime::mexception (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Build an MException-like struct (me = MException(id, msg, args...)). | |
| void | nk::runtime::rethrowStruct (const Value &me) |
| Rethrow from an MException struct (rethrow(me) / throw(me)). | |
| void | nk::runtime::assertCond (Span< const Value > args) |
| Throw on a false condition (assert(...)). | |
| void | nk::bundle::registerHelpLibrary (Engine &engine) |
| Convenience alias to install help system into an engine. | |
| std::string | nk::bundle::help (const std::string &query="") |
| Formats help text or catalog index for given function or topic name (help query). | |
| Value | nk::bundle::help (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| MATLAB script engine wrapper for help. | |
| std::vector< std::string > | nk::bundle::what (const std::string &category="elmat") |
| Lists all functions in specified category (what category). | |
| Value | nk::bundle::what (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| MATLAB script engine wrapper for what. | |
| std::vector< std::string > | nk::bundle::builtins (const std::string &category="") |
| Lists all built-in functions registered in the system or specified category (builtins). | |
| Value | nk::bundle::builtins (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| MATLAB script engine wrapper for builtins. | |
| std::vector< std::string > | nk::bundle::categories () |
| Lists all registered documentation categories (categories). | |
| Value | nk::bundle::categories (std::pmr::memory_resource *mr) |
| Returns all registered categories as a cell array of strings. | |
| void | nk::installStandardLibrary (Engine &engine) |
| Forwarder for backward compatibility. | |
| std::unique_ptr< Engine > | nk::makeStandardEngine (std::pmr::memory_resource *mr=nullptr) |
Keywords, variable naming rules, error/warning handling, exception structures, and interactive discovery (help, what).
Throw on a false condition (assert(...)).
Forms:
Returns normally if cond is non-zero.
| args | Arguments per the forms above. |
| Error | Condition is false (form-dependent identifier / message). |
| std::vector< std::string > nk::bundle::builtins | ( | const std::string & | category = "" | ) |
Lists all built-in functions registered in the system or specified category (builtins).
| category | Category name (or empty string for all built-ins). |
MATLAB script engine wrapper for builtins.
| args | Category argument. |
| mr | Memory resource for output allocation. |
| std::vector< std::string > nk::bundle::categories | ( | ) |
Lists all registered documentation categories (categories).
| Value nk::bundle::categories | ( | std::pmr::memory_resource * | mr | ) |
Returns all registered categories as a cell array of strings.
| mr | Memory resource for output allocation. |
Throw an Error (error(...)).
Accepts any of:
| args | Arguments per the forms above. |
| Error | Always (never returns). |
| std::string nk::builtin::getenv | ( | const std::string & | name | ) |
Reads an operating system environment variable as a C++ string (getenv(name)).
| name | Environment variable name. |
Reads an environment variable returning a character row Value (val = getenv(name)).
| name | Variable name as Value (character array or string scalar). |
| mr | Memory resource for allocations (nullptr for default). |
| std::string nk::bundle::help | ( | const std::string & | query = "" | ) |
Formats help text or catalog index for given function or topic name (help query).
| query | Function, category, or empty string to display root catalog index. |
MATLAB script engine wrapper for help.
| args | Command-line arguments. |
| mr | Memory resource for output allocation. |
|
inline |
Forwarder for backward compatibility.
Definition at line 26 of file standard_library.hpp.
| bool nk::builtin::iskeyword | ( | const std::string & | name | ) |
Tests whether a string is a reserved MATLAB language keyword (iskeyword(s)).
Reserved keywords: break, case, catch, classdef, continue, else, elseif, end, for, function, global, if, otherwise, parfor, persistent, return, spmd, switch, try, while.
| name | String identifier to test. |
name is a reserved keyword, false otherwise. MATLAB-compatible overload for iskeyword.
If args is empty, returns a cell array of all keywords. If args has 1 argument, tests whether that name is a keyword.
| args | Optional (name) argument. |
| mr | Memory resource for allocations (nullptr for default). |
| bool nk::builtin::isvarname | ( | const std::string & | name | ) |
Tests whether a string is a valid MATLAB variable name (isvarname(s)).
A valid variable name begins with a letter, contains only alphanumeric characters and underscores, and is not a reserved keyword.
| name | String to validate. |
name is a valid variable name, false otherwise. MATLAB-compatible overload for isvarname.
Tests whether name (character array or string scalar) is a valid variable name. Non-text inputs safely return false.
| name | Target Value to test. |
| mr | Memory resource for allocations (nullptr for default). |
| const std::vector< std::string > & nk::builtin::keywords | ( | ) |
Lists all reserved MATLAB keywords as a C++ vector.
| LastWarn nk::runtime::lastwarnGet | ( | ) |
Read most-recent warning state ([msg, id] = lastwarn()).
Storage is thread_local in the implementation TU, so concurrent engines on different threads each see their own last-warning.
| void nk::runtime::lastwarnSet | ( | const std::string & | msg, |
| const std::string & | id ) |
Overwrite the most-recent warning state.
Used internally by warning; also exposed as the lastwarn(MSG, ID) setter form.
| msg | New message. |
| id | New identifier. |
| Value nk::runtime::mexception | ( | Span< const Value > | args, |
| std::pmr::memory_resource * | mr = nullptr ) |
Build an MException-like struct (me = MException(id, msg, args...)).
Returns a struct with identifier and message fields. The message is formatted via sprintf-style argument substitution.
| args | (id, msg, arg1, ...). Throws on fewer than 2 args. |
| mr | Memory resource (nullptr → process default). |
| Error | Bad argument count (m:MException:nargin). |
|
inline |
| void nk::runtime::rethrowStruct | ( | const Value & | me | ) |
Rethrow from an MException struct (rethrow(me) / throw(me)).
Extracts message + identifier from the struct and throws Error. Used by both rethrow() and throw() (they are aliases).
| me | MException-like struct. |
| Error | Always; reconstructed from me.identifier / me.message. |
| void nk::builtin::setenv | ( | const std::string & | name, |
| const std::string & | value = "" ) |
Sets or clears an operating system environment variable (setenv(name, value)).
Sets the process environment variable name to value. If value is empty, the variable is removed from the process environment.
| name | Environment variable name (must not be empty or contain '='). |
| value | Target string value. |
| std::runtime_error | If name is empty or contains '='. |
Engine-stateful warning (warning(...)).
Same form-dispatch as error but does not throw — writes "Warning: ...\n" via engine.outputText() and updates the most-recent-warning state (see lastwarnGet).
| std::vector< std::string > nk::bundle::what | ( | const std::string & | category = "elmat" | ) |
Lists all functions in specified category (what category).
| category | Category name (e.g. "elmat", "signal", "stats"). |