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 <FormBuilder.h>
Public Member Functions | |
LayoutBuilder (const std::string &json_form, const ArrayBuilderOptions &options, bool vm_init=true) | |
Creates an LayoutBuilder from a full set of parameters. More... | |
void | connect (const std::shared_ptr< ForthMachineOf< T, I >> &vm) |
Connects a Virtual Machine if it was not initialized before. More... | |
void | debug_step () const |
Prints debug information from the Virtual Machine stack. More... | |
const std::string | vm_source () const |
Returns an AwkwardForth source code generated from the 'Form' and passed to the 'ForthMachine' virtual machine. More... | |
const std::shared_ptr< ForthMachineOf< T, I > > | vm () const |
int64_t | length () const |
Current length of the accumulated array. More... | |
void | pre_snapshot () const |
void | null () |
Adds a null value to the accumulated data. More... | |
void | boolean (bool x) |
Adds a boolean value x to the accumulated data. More... | |
void | int64 (int64_t x) |
Adds an integer value x to the accumulated data. More... | |
void | float64 (double x) |
Adds a real value x to the accumulated data. More... | |
void | complex (std::complex< double > x) |
Adds a complex value x to the accumulated data. More... | |
void | bytestring (const char *x) |
Adds an unencoded, null-terminated bytestring value x to the accumulated data. More... | |
void | bytestring (const char *x, int64_t length) |
Adds an unencoded bytestring value x with a given length to the accumulated data. More... | |
void | bytestring (const std::string &x) |
Adds an unencoded bytestring x in STL format to the accumulated data. More... | |
void | string (const char *x) |
Adds a UTF-8 encoded, null-terminated bytestring value x to the accumulated data. More... | |
void | string (const char *x, int64_t length) |
Adds a UTF-8 encoded bytestring value x with a given length to the accumulated data. More... | |
void | string (const std::string &x) |
Adds a UTF-8 encoded bytestring x in STL format to the accumulated data. More... | |
void | begin_list () |
Begins building a nested list. More... | |
void | add_begin_list () |
Begins building a nested list. More... | |
void | end_list () |
Ends a nested list. More... | |
void | add_end_list () |
Ends a nested list. More... | |
void | tag (int8_t tag) |
Sets the pointer to a given tag tag ; the next command will fill that slot. More... | |
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. More... | |
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. More... | |
void | add_bool (bool x) |
Adds a boolean value x to the accumulated data. More... | |
void | add_int64 (int64_t x) |
Adds an int64_t value x to the accumulated data. More... | |
void | add_double (double x) |
Adds a double value x to the accumulated data. More... | |
void | add_complex (std::complex< double > x) |
Adds a complex value x to the accumulated data. More... | |
void | add_string (const std::string &x) |
Adds a string value x to the accumulated data. More... | |
void | resume () const |
Resume Virtual machine run. More... | |
const FormBuilderPtr< T, I > | builder () const |
Static Public Member Functions | |
static int64_t | next_id () |
Generates next unique ID. More... | |
static int64_t | next_error_id () |
Generates a user-defined error ID. More... | |
Static Protected Attributes | |
static int64_t | next_node_id |
A unique ID to use when Form nodes do not have Form key defined. More... | |
static int64_t | error_id |
An error ID to be used to generate a user 'halt' message. More... | |
User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilder subclass instances change in response to accumulating data.
LayoutBuilder | ( | const std::string & | json_form, |
const ArrayBuilderOptions & | options, | ||
bool | vm_init = true |
||
) |
Creates an LayoutBuilder from a full set of parameters.
form | The Form that defines the Array to be build. |
options | The Array builder options. |
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. |
void add_begin_list | ( | ) |
Begins building a nested list.
void add_bool | ( | bool | x | ) |
Adds a boolean value x
to the accumulated data.
void add_complex | ( | std::complex< double > | x | ) |
Adds a complex value x
to the accumulated data.
void add_double | ( | double | x | ) |
Adds a double value x
to the accumulated data.
void add_end_list | ( | ) |
Ends a nested list.
void add_int64 | ( | int64_t | x | ) |
Adds an int64_t value x
to the accumulated data.
void add_string | ( | const std::string & | x | ) |
Adds a string value x
to the accumulated data.
void begin_list | ( | ) |
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'.
void boolean | ( | bool | x | ) |
Adds a boolean value x
to the accumulated data.
|
inline |
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.
The string does not need to be null-terminated.
void bytestring | ( | const std::string & | x | ) |
Adds an unencoded bytestring x
in STL format to the accumulated data.
void complex | ( | std::complex< double > | x | ) |
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.
void debug_step | ( | ) | const |
Prints debug information from the Virtual Machine stack.
void end_list | ( | ) |
Ends a nested list.
|
inline |
Finds an index of a data in a VM output buffer. This is used to build a 'categorical' array.
void float64 | ( | double | x | ) |
Adds a real value x
to the accumulated data.
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.
This is used to build a 'categorical' array.
void int64 | ( | int64_t | x | ) |
Adds an integer value x
to the accumulated data.
int64_t length | ( | ) | const |
Current length of the accumulated array.
|
static |
Generates a user-defined error ID.
|
static |
Generates next unique ID.
void null | ( | ) |
Adds a null
value to the accumulated data.
void pre_snapshot | ( | ) | const |
void resume | ( | ) | const |
Resume Virtual machine run.
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.
The string does not need to be null-terminated.
void string | ( | const std::string & | x | ) |
Adds a UTF-8 encoded bytestring x
in STL format to the accumulated data.
void tag | ( | int8_t | tag | ) |
Sets the pointer to a given tag tag
; the next command will fill that slot.
const std::shared_ptr<ForthMachineOf<T, I> > vm | ( | ) | const |
const std::string vm_source | ( | ) | const |
Returns an AwkwardForth source code generated from the 'Form' and passed to the 'ForthMachine' virtual machine.
|
staticprotected |
An error ID to be used to generate a user 'halt' message.
|
staticprotected |