uce
Current State
This is in the early stages of development. Don't use this for anything important (or at all)!
Udo's C++ Entry Points
The aim of this project is to make a PHP-like runtime that enables server-side "scripting" using C/C++. At the core is a multi-worker FastCGI server that can be talked to from Nginx or similar front-end servers. UCE has a shared-nothing isolated architecture to serve page requests. To minimize the potential for memory leaks, UCE uses a per-request memory arena. UCE also provides a PHP-like API to ease web development. UCE aims to use minimal dependencies (at the moment, the only dependency is the Clang compiler). UCE pages are automatically recompiled and dynamically reloaded as necessary.
WebSockets
WebSocket-enabled pages can now expose both:
RENDER() { }for normal HTTP renderingWS() { }for inbound WebSocket messages on the same.ws.ucepage
The runtime keeps the socket lifecycle in-process and exposes a low-boilerplate API to page code:
ws_message()ws_connection_id()ws_scope()ws_opcode()ws_is_binary()ws_connections([scope])ws_connection_count([scope])ws_send(message[, scope])ws_broadcast(message[, scope])ws_send_to(connection_id, message)ws_close([connection_id])
By default, the WebSocket scope is the current page file, so ws_send() broadcasts to other clients connected to that same .ws.uce endpoint.
ws_message() may contain either text or binary payload data. Use ws_opcode() / ws_is_binary() to inspect the current inbound message type.
The current ws_send* helpers queue text frames. Binary send helpers are not exposed yet.
The runtime now accepts fragmented messages, validates reserved bits and UTF-8 for text payloads, and delivers both text and binary message frames into WS().
Service Setup
The repository now includes a systemd unit template and a management script for the FastCGI runtime:
scripts/systemd/uce.servicescripts/systemd/manage-uce-service.sh
Typical usage on the deployment host:
scripts/systemd/manage-uce-service.sh setup
scripts/systemd/manage-uce-service.sh status
scripts/systemd/manage-uce-service.sh restart
scripts/systemd/manage-uce-service.sh logs 200
The service runs the runtime from the repository root so COMPILER_SYS_PATH resolves correctly and nginx can forward .uce requests to the Unix socket defined in /etc/uce/settings.cfg.
For deployed WebSockets, nginx should proxy .ws.uce requests to the runtime's built-in HTTP listener instead of fastcgi_pass. The current OpenFU deployment already does this and keeps HTTP/WebSocket ownership on a single worker so page-scoped broadcasts stay coherent.
API
Memcache Functions
memcache_command
String memcache_command(u64 connection, String command)
Parameters
connection : connection handle
command : string containing the Memcache command
return value : string containing the Memcache server's response
Description
Executes a command on an open memcache connection.
memcache_connect
u64 memcache_connect(String host = "127.0.0.1", short port = 11211)
Parameters
host : optional host name of the memcache server, defaults to local address 127.0.0.1
port : optional memcache server's port, defaults to 11211
return value : the connection handle (or -1 if an error occurred)
Description
Connects to a memcache server instance.
memcache_delete
bool memcache_delete(u64 connection, String key)
Parameters
connection : connection handle
key : key string
return value : true if the operation was successful
Description
Deletes entry specified by the 'key'.
memcache_get
String memcache_get(u64 connection, String key, String default_value = "")
Parameters
connection : connection handle
key : key string
default_value : optional default value
return value : value that was returned by the Memcache server
Description
Retrieves a value from an existing connection to a Memcache server.
memcache_get_multiple
StringMap memcache_get_multiple(u64 connection, StringList keys)
Parameters
connection : connection handle
keys : a list of strings containing the keys to be retrieved
return value : a StringMap with the retrieved entries
Description
Retrieves a bunch of entries all at once.
memcache_set
bool memcache_set(u64 connection, String key, String value, u64 expires_in = 60*60)
Parameters
connection : connection handle
key : the entry's key
value : the value to be set
expires_in : optional expiration timeout, defaults to one hour
return value : true if the operation was successful
Description
Stores a 'value' on the Memcache server.
MySQL Functions
mysql_connect
MySQL* mysql_connect(String host = "localhost", String username = "root", String password = "")
Parameters
host : host name of the MySQL server
username : user name
password : password
return value : pointer to the MySQL connection struct
Description
Establishes a connection to a MySQL server.
mysql_disconnect
void mysql_disconnect(MySQL* m)
Parameters
m : pointer to an existing MySQL connection struct
Description
Closes a connection to a MySQL server.
mysql_error
String mysql_error(MySQL* m)
Parameters
m : pointer to a MySQL connection struct
return value : MySQL error message (if present, otherwise empty string)
Description
Returns the last error message from a connection to a MySQL server.
mysql_escape
String mysql_escape(String raw, char quote_char)
Parameters
raw : the string to be escaped
quote_char : the character that should be used to wrap the string (pass NULL for no wrapping)
return value : the safe version of the 'raw' string
Description
Escapes a string such that it can be passed as a safe value into an SQL expression.
mysql_insert_id
u64 mysql_insert_id(MySQL* m)
Parameters
m : pointer to an active MySQL connection
return value : the last used automatic row ID
Description
This retrieves the last row ID that was used for a column with an AUTO_INCREMENT row key.
mysql_query
DTree mysql_query(MySQL* m, String q, StringMap params)
Parameters
m : pointer to an active MySQL connection struct
q : a string containing a MySQL query
params : optional, a list of query parameter keys and values
return value : a list of rows returned from executing the query
Description
Executes a MySQL query and returns the resulting data (if any).
Examples
(tbd)
Noise/Hash Functions
draw_float
f64 draw_float(f64 from, f64 to)
Parameters
from : minimum value
to : maximum value
return value : a noise value between 'from' and 'to'
Description
This function works exactly like generate_float(), but context->random_index is used for the 'index' value and context->random_seed is used for the seed. After this function has been called, the context->random_index is increased by one. At the start of every request, context->random_seed is automatically populated with a new seed value.
draw_int
u64 draw_int(u64 from, u64 to)
Parameters
from : minimum value
to : maximum value
return value : a noise value between 'from' and 'to'
Description
This function works exactly like generate_int(), but context->random_index is used for the 'index' value and context->random_seed is used for the seed. After this function has been called, the context->random_index is increased by one. At the start of every request, context->random_seed is automatically populated with a new seed value.
gen_noise01
u32 noise01(u64 index, u64 seed = 0)
Parameters
index : index position
seed : seed set (defaults to 0)
return value : a noise value from 0 to 1
Description
Generates a noise value in the range from 0 to 1 for the given 'index' and 'seed' values.
gen_noise32
u32 noise32(u32 index, u32 seed = 0)
Parameters
index : index position
seed : seed set (defaults to 0)
return value : a noise value given the 'index' and 'seed' values.
Description
Generates a noise value for the given 'index' and 'seed' values.
gen_noise64
u32 noise64(u64 index, u64 seed = 0)
Parameters
index : index position
seed : seed set (defaults to 0)
return value : a noise value given the 'index' and 'seed' values.
Description
Generates a noise value for the given 'index' and 'seed' values.
gen_float
f64 generate_float(f64 from, f64 to, u64 index, u64 seed = 0)
Parameters
from : minimum result
to : maximum result
index : index position to generate number from
seed : seed position to generate number from (defaults to 0)
return value : noise value
Description
Generates a noise value between 'from' and 'to', given the 'index' and 'seed' numbers.
gen_int
u64 generate_int(u64 from, u64 to, u64 index, u64 seed = 0)
Parameters
from : minimum result
to : maximum result
index : index position to generate number from
seed : seed position to generate number from (defaults to 0)
return value : noise value
Description
Generates a noise value between 'from' and 'to', given the 'index' and 'seed' numbers.
gen_sha1
String sha1(String s, bool as_binary = false)
Parameters
s : data to be hashed
as_binary : when set to false, returns hash in hexadecimal notation (defaults to false)
return value : the resulting hash value
Description
Returns the sha1 hash of 's'.
Output Buffer Functions
ob_clear
void ob_clear()
Parameters
(none) :
Description
Discard the current output buffer.
ob_get
String ob_get()
Parameters
return value : content of the current output buffer
Description
Returns the contents of the current output buffer.
ob_get_clear
String ob_get_clear()
Parameters
return value : content of the current output buffer
Description
Returns the contents of the current output buffer and then discards the buffer.
ob_start
void ob_start()
Parameters
(none) :
Description
Starts a new output buffer. All subsequent output will be directed into this buffer.
Sessions
make_session_id
String make_session_id()
Parameters
return value : a new session ID
Description
Creates a session ID
session_destroy
void session_destroy(String session_name)
Parameters
session_name : the name of the session
Description
Deletes the cookie specified by 'session_name' and clears the data stored under the session ID. This empties the 'context->session_id' and 'context->session' variables.
session_start
String session_start(String session_name)
Parameters
return value : the session ID, defaults to "uce-session"
Description
Starts session or connects to existing session. This function sets a cookie with the name contained in 'session_name' if it does not exist and fills that cookie with a new unique session ID. It then loads the session data for that session ID. Afterwards, the following fields are populated in the 'context' variable:
context->session_id : the current session ID
context->session_name : the current session cookie name
context->session : the current session data. The session data is automatically saved after a request completes.
Socket Functions
socket_close
void socket_close(u64 sockfd)
Parameters
sockfd : socket handle
Description
Closes an existing socket connection.
socket_connect
u64 socket_connect(String host, short port)
Parameters
host : host name
port : port number
return value : the socket handle
Description
Opens a socket connection to the given 'host' and 'port'.
socket_read
String socket_read(u64 sockfd, u32 max_length = 1024*128, u32 timeout = 1);
Parameters
sockfd : socket handle
max_length : optional maximum data size, defaults to 128kBytes
timeout : optional operation timeout, defaults to one second
return value : string containing the data that was read
Description
Reads data from a socket connection.
socket_write
bool socket_write(u64 sockfd, String data)
Parameters
sockfd : socket handle
data : a string containing the data to be written to the socket
return value : true if the write operation was successful
Description
Writes a string of 'data' to the given socket.
String Functions
filter
StringList filter(StringList items, function f)
vector filter(vector items, function f)
Parameters
items : list of items to be filtered
f : a function that decides which items should be in the new list
return value : a new list
Description
Returns a list containing the members of 'items' for which 'f' returned boolean true.
first
String first(String... args)
Parameters
args : a variable number of String arguments
return value : first of the 'args' that was not empty.
Description
Given a variable number of String parameters, the first() function returns the first of these parameters that was not empty. Leading and trailing whitespace characters are not considered, resulting in a string that contains only whitespace characters being considered empty.
join
String join(StringList l, String delim = "\n")
Parameters
l : list of strings to be joined
delim : delimiter (defaults to newline character)
return value : a string containing items joined by 'delim'
Description
Joins the items contained in 'l' into a single String.
nibble
String nibble(String& haystack, String delim)
Parameters
haystack : string to be nibbled at
delim : delimiter
return value : string before first occurrence of 'delim'
Description
Returns the part of 'haystack' before the first occurrence of 'delim', removing the corresponding part from 'haystack' (including 'delim'). If the substring 'delim' does not occurr in 'haystack', the entire string is returned and 'haystack' is set to an empty string.
split
StringList split(String str, String delim)
Parameters
str : string to be split
delim : delimiter
return value : a list of strings
Description
Splits 'str' into multiple strings based on the given delimiter 'delim'.
split_space
StringList split_space(String str)
Parameters
str : string to be split
return value : a list of strings
Description
Splits 'str' into multiple strings along any whitespace characters (multiple whitespace characters count as one).
split_utf8
StringList split_utf8(String str, bool compound_characters = false)
Parameters
str : string to be split
compound_characters : optional, if true tries to combine compound characters
return value : a list of Unicode characters
Description
Splits the string 'str' into its constituent Unicode code points.
If 'compound_characters' is true, split_utf8 will attempt to combine compound characters based on very simple rules:
-
combine characters if they're connected by a Zero-Width Joiner (ZWJ) character
-
combine two characters if they're both a Regional Indicator Symbol Letter
-
if a character is a Variation Selector, append it to the previous character
-
in all other cases, characters remain on their own
replace
String replace(String s, String search, String replace_with)
Parameters
s : the string where replacements should happen
search : the string that should be searched for
replace_with : the string that should appear in places where 'search' occurs
return value : a version of 's' where all instances of 'search' have been replaced with 'replace_with'
Description
Replace all occurrences of 'search' with the string defined in 'replace_with'.
to_lower
String to_lower(String s)
Parameters
s : the string to be converted
return value : returns a version of 's' where all upper case characters have been changed into lower case
Description
Returns a lower case version of the input string 's'.
Note: this function is not yet Unicode-aware.
to_upper
String to_upper(String s)
Parameters
s : the string to be converted
return value : returns a version of 's' where all lower case characters have been changed into upper case
Description
Returns a upper case version of the input string 's'.
Note: this function is not yet Unicode-aware.
trim
String trim(String raw)
Parameters
raw : string to be trimmed
return value : string with leading and trailing whitespace characters removed
Description
Returns a string where leading an trailing whitespace characters have been trimmed off.
File System Functions
basename
String basename(String fn)
Parameters
fn : raw filename
return value : the file's name
Description
Isolates the file name component from a path/file name.
dirname
String dirname(String fn)
Parameters
fn : raw filename
return value : the directory's name
Description
Isolates the directory name component from a path/file name.
expand_path
String expand_path(String path, String relative_to_path = "")
Parameters
path : a relative path
relative_to_path : optional, expand relative to this path (if not given, the current path is used)
return value : expanded version of the 'path'
Description
Converts a relative path name into an absolute path, using the current working directory as a base.
file_append
void file_append(String file_name, ...val)
Parameters
file_name : file name of file that should be written to
...val : one or more values that should be written into the file
Description
Opens or creates a given file and appends data to it.
file_exists
bool file_exists(String path)
Parameters
path : the path name to be checked
return value : true if the file exists
Description
Checks whether the file or path specified by 'path' exists.
file_get_contents
String file_get_contents(String file_name)
Parameters
file_name : file name of file that should be read
return value : String containing the file's contents
Description
Reads the file identified by 'file_name' and returns it as a String. If the file cannot be read, this function will return an empty string.
file_mtime
time_t file_mtime(String file_name)
Parameters
file_name : name of the file
return value : Unix time stamp of the file's last modification
Description
Retrieves the last modification date of 'file_name' as a Unix timestamp.
file_put_contents
bool file_put_contents(String file_name, String content)
Parameters
file_name : file name of file that should be written
content : content that should be written
return value : true if write was successful
Description
Writes the String 'content' into a file identified by 'file_name'. Any pre-existing content of the file will be overwritten.
get_cwd
String get_cwd()
Parameters
return value : the current working directory
Description
Returns the current working directory.
ls
StringList ls(String path)
Parameters
path : a filesystem path
return value : list of directory entries
Description
Returns a list of files and subdirectories within the given 'path'.
mkdir
bool mkdir(String path)
Parameters
path : the path name to be created
return value : returns true if the directory was successfully created
Description
Creates a directory stated by 'path'
set_cwd
void set_cwd(String path)
Parameters
path : the new working directory
Description
Sets a new working directory.
shell_escape
String shell_escape(String raw)
Parameters
raw : string that should be escaped
return value : escaped version of 'raw'
Description
Escapes a parameter for shell_exec
shell_exec
String shell_exec(String cmd)
Parameters
cmd : string that contains the shell command line to be executed
return value : output of the command execution
Description
Executes a Linux shell command and returns the generated output
unlink
void unlink(String file_name)
Parameters
file_name : name of the file
Description
Deletes the file identified by 'file_name'.
Task API
kill
s64 kill(pid_t pid, s64 sig)
Parameters
pid : PID of the process
sig : signal number
return value : 0 if signal was sent, -1 otherwise
Description
This is the standard POSIX kill() function, provided here for reference.
Possible signal numbers are: SIGABND, SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE, SIGPOLL, SIGPROF, SIGQUIT, SIGSEGV, SIGSYS, SIGTERM, SIGTRAP, SIGURG, SIGUSR1, SIGUSR2, SIGVTALRM, SIGXCPU, SIGXFSZ, SIGCHLD, SIGIO, SIGIOERR, SIGWINCH, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGCONT.
task
pid_t task(String key, std::function exec_func)
Parameters
key : string uniquely identifying the task
exec_func : function to execute
return value : the process ID of the started (or still running) task
Description
task() starts the 'exec_func' in a new process and returns that process' ID. If a process with the same 'key' is already running, task will not start a new process but instead just return the PID of the process that is already running.
task_pid
pid_t task_pid(String key)
Parameters
key : string uniquely identifying the task
return value : the process ID of the task
Description
Checks whether a process with the given 'key' is running and returns its PID if it is. Returns 0 otherwise.
Time and Date Functions
microtime
f64 microtime()
Parameters
return value : current Unix timestamp
Description
Returns a 64 bit float containing the current Unix timestamp with millisecond accuracy or better.
time
u64 time()
Parameters
return value : second-accurate current Unix timestamp
Description
Returns a 64 bit integer containing the current Unix timestamp.
date
String date(String format = "", u64 timestamp = 0)
Parameters
format : formatting string specifying the date format
timestamp : optional timestamp value, defaults to current time
return value : a formatted date
Description
Returns a formatted date. This is based on the Linux date() command. The formatting string supports the following sequences:
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C century; like %Y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %\_d
%F full date; like %+4Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only
with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %\_H
%l hour, space padded ( 1..12); same as %\_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week
(00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week
(00..53)
%x locale's date representation (e.g., 12/31/99)
%X locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g.,
-04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
\_ (underscore) pad with spaces
0 (zero) pad with zeros
+ pad with zeros, and put '+' before future years with >4
digits
^ use upper case if possible
# use opposite case if possible
gmdate
String gmdate(String format = "", u64 timestamp = 0)
Parameters
format : formatting string specifying the date format
timestamp : optional timestamp value, defaults to current time
return value : a formatted date
Description
Returns a formatted date in the GMT/UTC timezone. This is based on the Linux date() command. The formatting string supports the following sequences:
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C century; like %Y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %\_d
%F full date; like %+4Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only
with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %\_H
%l hour, space padded ( 1..12); same as %\_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week
(00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week
(00..53)
%x locale's date representation (e.g., 12/31/99)
%X locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g.,
-04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
\_ (underscore) pad with spaces
0 (zero) pad with zeros
+ pad with zeros, and put '+' before future years with >4
digits
^ use upper case if possible
# use opposite case if possible
parse_time
u64 parse_time(String time_string)
Parameters
time_string : a string containing a date and/or time in text form
return value : the interpreted 'time_string' as a Unix timestamp
Description
Attempts to parse the given 'time_string' into a Unix timestamp.
URI Functions
encode_query
String encode_query(StringMap map)
Parameters
q : StringMap containing URL parameters to be encoded
return value : a string with the encoded parameters
Description
Encodes a StringMap containing URL parameters into a single String.
make_session_id
String make_session_id()
Parameters
return value : a new session ID
Description
Creates a session ID
parse_query
StringMap parse_query(String q)
Parameters
q : string containing URL parameters
return value : a StringMap containing the parameters
Description
Decodes a string of the format 'a=b&c=d' into a StringMap containing keyed entries.
uri_decode
String uri_decode(String s)
Parameters
s : string containing URI encoded data
return value : a string that contains the decoded version of 's'
Description
Decodes an URI-encoded string 's'.
uri_encode
String uri_encode(String s)
Parameters
s : string that should be encoded
return value : an URI-encoded version of 's'
Description
URI-encodes a string.
Other Functions and Data Structures
context
Request* context;
ServerState* server
Contains the current server state
StringMap params
All FastCGI server parameters
StringMap get
The current request's GET variables
StringMap post
The current request's POST variables
StringMap cookies
Cookies that have been transmitted by the browser
StringMap session
The current session
String session_id
ID of the session cookie
String session_name
Name of the session cookie
DTree var
Variable user-defined data
std::vector uploaded_files
Files that have been uploaded in the current request
StringMap header
Headers to be sent back to the browser
StringList set_cookies;
Cookies that should be sent back to the browser
u64 random_seed
The current request's "random" noise generator seed
u64 random_index
The current request's "random" noise generator index position
MemoryArena* mem
Contains the current request's memory arena
bool flags.log_request
Whether the request should be logged
Stats
u32 stats.bytes_written
f64 stats.time_init
f64 stats.time_start
f64 stats.time_end
invoke(String file_name, [DTree& call_param])
Invokes the UCE file 'file_name'
#load
#load "myfile.uce"
Parameters
file name : name of an UCE file that should be included
Description
Includes another UCE file
float_val
f64 float_val(String s)
Parameters
s : string to be converted
return value : a f64 containing the number (0 if no number could be identified).
Description
Extracts a floating point number from a String.
html_escape
String html_escape(String s)
Parameters
s : string to be escaped
return value : an HTML-safe escaped version of 's'
Description
Returns a version of the input string where the following characters have been replace by HTML entities:
- & → &
- < → lt;
- > → >
- " → "
int_val
u64 int_val(String s, u32 base = 10)
Parameters
s : string to be converted
base : number system base (default 10)
return value : a u64 containing the number (0 if no number could be identified).
Description
Extracts an integer from a String.
json_decode
DTree json_decode(String s)
Parameters
s : string containing JSON data
return value : a DTree object containing the deserialized JSON data
Description
Deserializes 's' into a DTree structure.
json_encode
String json_encode(DTree t)
Parameters
t : DTree object to be serialized
return value : string containing the JSON result
Description
Serializes a DTree structure 't' into a String in JSON notation.
void print(...val)
Parameters
...val : one or more values that should be output
Description
Appends data to the current request's output stream.
var_dump
String var_dump(StringMap t, String prefix = "", String postfix = "\n")
String var_dump(StringList t, String prefix = "", String postfix = "\n")
String var_dump(DTree t, String prefix = "", String postfix = "\n")
Parameters
t : object to be dumped into a string
return value : string containing a human-friendly representation of 't'
Description
Returns a string representation of 't' intended for debugging.