User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilder subclass instances change in response to accumulating data. More...
#include <LayoutBuilder.h>
Public Member Functions | |
LayoutBuilder (const std::string &json_form, const int64_t initial, bool vm_init=true) | |
Creates an LayoutBuilder from a full set of parameters. | |
const std::string & | json_form () const |
const std::string | to_buffers (BuffersContainer &container) const |
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON). | |
void | connect (const std::shared_ptr< ForthMachineOf< T, I > > &vm) |
Connects a Virtual Machine if it was not initialized before. | |
void | debug_step () const |
Prints debug information from the Virtual Machine stack. | |
const std::string | vm_source () const |
Returns an AwkwardForth source code generated from the 'Form' and passed to the 'ForthMachine' virtual machine. | |
const std::shared_ptr< ForthMachineOf< T, I > > | vm () const |
int64_t | length () const |
Current length of the accumulated array. | |
void | pre_snapshot () const |
void | null () |
Adds a null value to the accumulated data. | |
void | boolean (bool x) |
Adds a boolean value x to the accumulated data. | |
void | int64 (int64_t x) |
Adds an integer value x to the accumulated data. | |
void | float64 (double x) |
Adds a real value x to the accumulated data. | |
void | complex (std::complex< double > x) |
Adds a complex value x to the accumulated data. | |
void | bytestring (const char *x) |
Adds an unencoded, null-terminated bytestring value x to the accumulated data. | |
void | bytestring (const char *x, int64_t length) |
Adds an unencoded bytestring value x with a given length to the accumulated data. | |
void | bytestring (const std::string &x) |
Adds an unencoded bytestring x in STL format to the accumulated data. | |
void | string (const char *x) |
Adds a UTF-8 encoded, null-terminated bytestring value x to the accumulated data. | |
void | string (const char *x, int64_t length) |
Adds a UTF-8 encoded bytestring value x with a given length to the accumulated data. | |
void | string (const std::string &x) |
Adds a UTF-8 encoded bytestring x in STL format to the accumulated data. | |
void | begin_list () |
Begins building a nested list. | |
void | add_begin_list () |
Begins building a nested list. | |
void | end_list () |
Ends a nested list. | |
void | add_end_list () |
Ends a nested list. | |
void | tag (int8_t tag) |
Sets the pointer to a given tag tag ; the next command will fill that slot. | |
void | index (int64_t x) |
Issues an 'index' vm command. The value 'x' is pushed to the VM stack, it is not added to the accumulated data, e.g. the VM output buffer. | |
template<typename D > | |
bool | find_index_of (D x, const std::string &vm_output_data) |
Finds an index of a data in a VM output buffer. This is used to build a 'categorical' array. | |
void | add_bool (bool x) |
Adds a boolean value x to the accumulated data. | |
void | add_int64 (int64_t x) |
Adds an int64_t value x to the accumulated data. | |
void | add_double (double x) |
Adds a double value x to the accumulated data. | |
void | add_complex (std::complex< double > x) |
Adds a complex value x to the accumulated data. | |
void | add_string (const std::string &x) |
Adds a string value x to the accumulated data. | |
void | resume () const |
Resume Virtual machine run. | |
const FormBuilderPtr< T, I > | builder () const |
Static Public Member Functions | |
static int64_t | next_id () |
Generates next unique ID. | |
static int64_t | next_error_id () |
Generates a user-defined error ID. | |
Static Protected Attributes | |
static int64_t | next_node_id |
A unique ID to use when Form nodes do not have Form key defined. | |
static int64_t | error_id |
An error ID to be used to generate a user 'halt' message. | |
User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilder subclass instances change in response to accumulating data.
Creates an LayoutBuilder from a full set of parameters.
form | The Form that defines the Array to be build. |
initial | The Array builder initial. |
vm_init | If 'true' the Virtual Machine is instantiated on construction. If 'false' an external Virtial Machine must be connected to the builder. The flag is used for debugging. |
Adds a boolean value x
to the accumulated data.
Adds a complex value x
to the accumulated data.
Adds a double value x
to the accumulated data.
Adds an int64_t value x
to the accumulated data.
Adds a string value x
to the accumulated data.
Begins building a nested list.
The first 'beginlist' puts AwkwardForth VM into a state that expects another 'beginlist' or 'endlist'. The second puts the VM into a state that expects 'int64', etc. or 'endlist'.
Adds a boolean value x
to the accumulated data.
Adds an unencoded, null-terminated bytestring value x
to the accumulated data.
Adds an unencoded bytestring value x
with a given length
to the accumulated data.
The string does not need to be null-terminated.
Adds an unencoded bytestring x
in STL format to the accumulated data.
Adds a complex value x
to the accumulated data.
void connect | ( | const std::shared_ptr< ForthMachineOf< T, I > > & | vm | ) |
Connects a Virtual Machine if it was not initialized before.
Prints debug information from the Virtual Machine stack.
Finds an index of a data in a VM output buffer. This is used to build a 'categorical' array.
Adds a real value x
to the accumulated data.
Issues an 'index' vm command. The value 'x' is pushed to the VM stack, it is not added to the accumulated data, e.g. the VM output buffer.
This is used to build a 'categorical' array.
Adds an integer value x
to the accumulated data.
Current length of the accumulated array.
Generates a user-defined error ID.
Adds a UTF-8 encoded, null-terminated bytestring value x
to the accumulated data.
Adds a UTF-8 encoded bytestring value x
with a given length
to the accumulated data.
The string does not need to be null-terminated.
Adds a UTF-8 encoded bytestring x
in STL format to the accumulated data.
Sets the pointer to a given tag tag
; the next command will fill that slot.
const std::string to_buffers | ( | BuffersContainer & | container | ) | const |
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).
Returns an AwkwardForth source code generated from the 'Form' and passed to the 'ForthMachine' virtual machine.
An error ID to be used to generate a user 'halt' message.