Formatted file streams, textscan/csvread parsing, and workspace save/load persistence. More...
Files | |
| file | iofun.hpp |
| Formatted text I/O and display builtins. | |
| file | env.hpp |
| Process-environment builtins. | |
| file | io.hpp |
| file | saveload.hpp |
| Workspace persistence — save / load (ASCII + matio v5 .mat). | |
Functions | |
| Value | nk::builtin::sprintf (const Value &fmt, Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Formats data into a character array or string according to format specifier fmt (sprintf(fmt, ...)). | |
| std::string | nk::builtin::sprintf (const std::string &fmt, Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Formats data into a C++ string according to format string fmt. | |
| std::string | nk::builtin::dispFormat (const Value &a) |
| Formats Value for terminal display via disp. | |
| void | nk::builtin::disp (const Value &v, std::ostream &os=std::cout) |
| Displays value to the standard output or specified stream (disp(v)). | |
| int | nk::builtin::fprintf (std::ostream &os, const std::string &fmt, Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Formats and writes data to an output stream (fprintf(os, fmt, ...)). | |
| Value | nk::builtin::sscanf (const std::string &str, const std::string &fmt, std::pmr::memory_resource *mr=nullptr) |
| Reads formatted data from a string according to format specifier fmt (sscanf(str, fmt)). | |
| void | nk::builtin::sscanf (Span< const Value > args, size_t nargout, Span< Value > outs, std::pmr::memory_resource *mr=nullptr) |
| Reads formatted data from a string with multi-output support ([A, count, errmsg, nextindex] = sscanf(...)). | |
| void | nk::runtime::registerEnvRuntime (Engine &engine) |
| void | nk::runtime::setenv (Span< const Value > args) |
| Set / unset an environment variable (setenv(name, value)). | |
| Value | nk::runtime::getenv (Span< const Value > args, std::pmr::memory_resource *mr=nullptr) |
| Read an environment variable (val = getenv(name)). | |
| std::size_t | nk::runtime::fprintf (::nk::Engine &engine, Span< const Value > args) |
| Formats and writes text to engine stdout or open file descriptor. | |
| void | nk::runtime::disp (::nk::Engine &engine, Span< const Value > args) |
| Displays value to engine standard output (disp(v)). | |
| void | nk::runtime::fscanf (::nk::Engine &engine, Span< const Value > args, size_t nargout, Span< Value > outs) |
| Reads formatted data from file descriptor (fscanf(fid, fmt, size)). | |
| void | nk::runtime::textscan (::nk::Engine &engine, Span< const Value > args, size_t nargout, Span< Value > outs) |
| Reads tabular data from open file descriptor or string (textscan(fid, fmt)). | |
| void | nk::runtime::save (Engine &engine, Environment &env, Span< const Value > args) |
| Save workspace variables to an ASCII file (save filename var1 var2 ...). | |
| void | nk::runtime::load (Engine &engine, Environment &env, Span< const Value > args, size_t nargout, Span< Value > outs) |
| Load workspace variables from an ASCII file (load filename / S = load(filename)). | |
Formatted file streams, textscan/csvread parsing, and workspace save/load persistence.
| void nk::builtin::disp | ( | const Value & | v, |
| std::ostream & | os = std::cout ) |
Displays value to the standard output or specified stream (disp(v)).
| v | Value to display. |
| os | Target output stream (defaults to std::cout). |
| void nk::runtime::disp | ( | ::nk::Engine & | engine, |
| Span< const Value > | args ) |
Displays value to engine standard output (disp(v)).
| engine | Reference to executing Engine instance. |
| args | Arguments span containing value to display. |
| std::string nk::builtin::dispFormat | ( | const Value & | a | ) |
| std::size_t nk::runtime::fprintf | ( | ::nk::Engine & | engine, |
| Span< const Value > | args ) |
Formats and writes text to engine stdout or open file descriptor.
| engine | Reference to executing Engine instance. |
| args | Arguments [fid, fmt, ...] or [fmt, ...]. |
| void nk::runtime::fscanf | ( | ::nk::Engine & | engine, |
| Span< const Value > | args, | ||
| size_t | nargout, | ||
| Span< Value > | outs ) |
Reads formatted data from file descriptor (fscanf(fid, fmt, size)).
| engine | Reference to executing Engine instance. |
| args | Input arguments span [fid, fmt, size]. |
| nargout | Number of requested outputs. |
| outs | Output spans to fill with results. |
Read an environment variable (val = getenv(name)).
| args | (name) — CHAR / STRING. |
| mr | Memory resource (nullptr -> process default). |
| Error | Bad argument type or count (m:getenv:nargin / m:getenv:badArg). |
| void nk::runtime::load | ( | Engine & | engine, |
| Environment & | env, | ||
| Span< const Value > | args, | ||
| size_t | nargout, | ||
| Span< Value > | outs ) |
Load workspace variables from an ASCII file (load filename / S = load(filename)).
Reads the file through engine's VFS, parses ASCII matrices, and either:
| engine | Engine context (VFS). |
| env | Variable environment to assign into. |
| args | (filename [, var1, var2, …]). |
| nargout | Number of requested outputs (0 = assign into env, 1 = return struct). |
| outs | Output slot for the struct form. |
| Error | On VFS failure, parse failure, or unknown variable. |
| void nk::runtime::save | ( | Engine & | engine, |
| Environment & | env, | ||
| Span< const Value > | args ) |
Save workspace variables to an ASCII file (save filename var1 var2 ...).
Looks each requested variable up in env, formats it as ASCII, and writes the file through engine's VFS. With no variables specified, saves the entire workspace.
| engine | Engine context (VFS). |
| env | Variable environment to read from. |
| args | (filename [, var1, var2, …]) — strings or symbol names. |
| Error | On VFS failure or unknown variable name. |
Set / unset an environment variable (setenv(name, value)).
Two-argument form sets name = value. Empty value removes the variable from the process environment.
| args | (name, value) — both CHAR / STRING. |
| Error | Bad argument types or count (m:setenv:nargin / m:setenv:badArg). |
| Value nk::builtin::sprintf | ( | const Value & | fmt, |
| Span< const Value > | args, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
| Value nk::builtin::sscanf | ( | const std::string & | str, |
| const std::string & | fmt, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Reads formatted data from a string according to format specifier fmt (sscanf(str, fmt)).
| str | Source string to scan. |
| fmt | Format specifier string. |
| mr | Memory resource. |
| void nk::runtime::textscan | ( | ::nk::Engine & | engine, |
| Span< const Value > | args, | ||
| size_t | nargout, | ||
| Span< Value > | outs ) |
Reads tabular data from open file descriptor or string (textscan(fid, fmt)).
| engine | Reference to executing Engine instance. |
| args | Input arguments span [fid/str, fmt, ...]. |
| nargout | Number of requested outputs. |
| outs | Output spans to fill with results. |