Awkward Array: LayoutBuilder< T, I > Class Template Reference

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
LayoutBuilder< T, I > Class Template Reference

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. More...
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). 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...

## Detailed Description

template<typename T, typename I>
class awkward::LayoutBuilder< T, I >

User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilder subclass instances change in response to accumulating data.

## Constructor & Destructor Documentation

## ◆ LayoutBuilder()

LayoutBuilder | ( | const std::string & | json_form,
|  | const int64_t | initial,
|  | bool | vm_init = `true`
| ) |  |

Creates an LayoutBuilder from a full set of parameters.

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.

## Member Function Documentation

## ◆ add_begin_list()

void add_begin_list | ( |  | ) |

Begins building a nested list.

## ◆ add_bool()

void add_bool | ( | bool | x | ) |

Adds a boolean value `x` to the accumulated data.

## ◆ add_complex()

void add_complex | ( | std::complex< double > | x | ) |

Adds a complex value `x` to the accumulated data.

## ◆ add_double()

void add_double | ( | double | x | ) |

Adds a double value `x` to the accumulated data.

## ◆ add_end_list()

void add_end_list | ( |  | ) |

Ends a nested list.

## ◆ add_int64()

void add_int64 | ( | int64_t | x | ) |

Adds an int64_t value `x` to the accumulated data.

## ◆ add_string()

void add_string | ( | const std::string & | x | ) |

Adds a string value `x` to the accumulated data.

## ◆ begin_list()

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'.

## ◆ boolean()

void boolean | ( | bool | x | ) |

Adds a boolean value `x` to the accumulated data.

## ◆ builder()

const FormBuilderPtr< T, I > builder | ( |  | ) | const
| inline

## ◆ bytestring() [1/3]

void bytestring | ( | const char * | x | ) |

Adds an unencoded, null-terminated bytestring value `x` to the accumulated data.

## ◆ bytestring() [2/3]

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.

## ◆ bytestring() [3/3]

void bytestring | ( | const std::string & | x | ) |

Adds an unencoded bytestring `x` in STL format to the accumulated data.

## ◆ complex()

void complex | ( | std::complex< double > | x | ) |

Adds a complex value `x` to the accumulated data.

## ◆ connect()

void connect | ( | const std::shared_ptr< ForthMachineOf< T, I > > & | vm | ) |

Connects a Virtual Machine if it was not initialized before.

## ◆ debug_step()

void debug_step | ( |  | ) | const

Prints debug information from the Virtual Machine stack.

## ◆ end_list()

void end_list | ( |  | ) |

Ends a nested list.

## ◆ find_index_of()

bool find_index_of | ( | D | x,
|  | const std::string & | vm_output_data
| ) |  |
| inline

Finds an index of a data in a VM output buffer. This is used to build a 'categorical' array.

## ◆ float64()

void float64 | ( | double | x | ) |

Adds a real value `x` to the accumulated data.

## ◆ index()

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.

## ◆ int64()

void int64 | ( | int64_t | x | ) |

Adds an integer value `x` to the accumulated data.

## ◆ json_form()

const std::string & json_form | ( |  | ) | const
| inline

## ◆ length()

int64_t length | ( |  | ) | const

Current length of the accumulated array.

## ◆ next_error_id()

static int64_t next_error_id | ( |  | ) |
| static

Generates a user-defined error ID.

## ◆ next_id()

static int64_t next_id | ( |  | ) |
| static

Generates next unique ID.

## ◆ null()

void null | ( |  | ) |

Adds a `null` value to the accumulated data.

## ◆ pre_snapshot()

void pre_snapshot | ( |  | ) | const

## ◆ resume()

void resume | ( |  | ) | const

Resume Virtual machine run.

## ◆ string() [1/3]

void string | ( | const char * | x | ) |

Adds a UTF-8 encoded, null-terminated bytestring value `x` to the accumulated data.

## ◆ string() [2/3]

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.

## ◆ string() [3/3]

void string | ( | const std::string & | x | ) |

Adds a UTF-8 encoded bytestring `x` in STL format to the accumulated data.

## ◆ tag()

void tag | ( | int8_t | tag | ) |

Sets the pointer to a given tag `tag`; the next command will fill that slot.

## ◆ to_buffers()

const std::string to_buffers | ( | BuffersContainer & | container | ) | const

Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).

## ◆ vm()

const std::shared_ptr< ForthMachineOf< T, I > > vm | ( |  | ) | const

## ◆ vm_source()

const std::string vm_source | ( |  | ) | const

Returns an AwkwardForth source code generated from the 'Form' and passed to the 'ForthMachine' virtual machine.

## Member Data Documentation

## ◆ error_id

int64_t error_id
| staticprotected

An error ID to be used to generate a user 'halt' message.

## ◆ next_node_id

int64_t next_node_id
| staticprotected

A unique ID to use when Form nodes do not have Form key defined.

The documentation for this class was generated from the following files:

- include/awkward/layoutbuilder/FormBuilder.h
- include/awkward/layoutbuilder/LayoutBuilder.h