Layout Formatter |
Typedefs | |
typedef pair< forest < dictionary_t >, vector < dictionary_t > > | layout_assembly_t |
Functions | |
void | assemble_layout (const string_t &layout_name, const layout_assembly_t &assembly, std::ostream &out) |
layout_assembly_t | disassemble_layout (std::istream &stream, const line_position_t &position) |
Detailed Description
This code is useful for parsing a layout description to an intermediate format for later modification and/or formatting back out to a CEL-based layout.
The layout disassembler finds two basic layout components during a parse. The first a forest of view declarations, the second is a set of layout cells.
Each parsed view and cell in the layout is is represented by its own dictionary. Each dictionary contains within it a set of associated values that completely describe the layout cell or view that has been parsed. They are:
key | mapped type | cell/view/both | description | notes |
---|---|---|---|---|
cell_type |
adobe::name_t | cell | The type of cell parsed | Value is one of interface or constant . |
comment_brief |
adobe::string_t | both | The comment found after the view parsed in C++ "//... " format |
|
comment_detailed |
adobe::string_t | both | The comment found before the view parsed in C "/ *...* / " format |
|
initializer |
adobe::array_t | cell | Parsed token expression | Use a virtual_machine_t to evaluate the token vector to get the initial state of the cell |
name |
adobe::name_t | both | Name of the cell or view | |
parameters |
adobe::array_t | view | Named argument set parsed as the attributes of the view | The array is an expression vector that always evaluates to an adobe::dictionary_t. To get the dictionary the expression must be evaluated by an adobe::virtual_machine_t |
- Example
- Source File:
layout sample_dialog { constant: pi : 355/113; // approximation interface: advanced : false; view dialog(name: "Sample Dialog") { edit_text(name: 'Name:', bind: @cell_name); // Maybe full name? checkbox(name: 'Advanced Options', bind: @advanced); } }
- View Forest and Cell Set Result:
[ { comment_brief: '', comment_detailed: '', name: @dialog, parameters: [ @name, 'Sample Dialog', 1, @.dictionary ] }, [ { comment_brief: ' Maybe full name?', comment_detailed: '', name: @edit_text, parameters: [ @name, 'Name:', @bind, @cell_name, 2, @.dictionary ] }, { comment_brief: '', comment_detailed: '', name: @checkbox, parameters: [ @name, 'Advanced Options', @bind, @advanced, 2, @.dictionary ] } ] ] [ { cell_type: @constant, comment_brief: ' approximation', comment_detailed: '', initializer: [ 355, 113, @.divide ], name: @pi }, { cell_type: @interface, comment_brief: '', comment_detailed: '', initializer: [ false ], name: @advanced } ]
- See also:
- adobe::format_expression
Typedef Documentation
typedef pair<forest<dictionary_t>, vector<dictionary_t> > layout_assembly_t |
The result type of adobe::disassemble_layout. first
is a forest of dictionaries, each dictionary describing a node parsed in the layout. second
is a vector of dictionaries, each representing a layout cell parsed in the layout.
Definition at line 184 of file layout_formatter.hpp.
Function Documentation
void adobe::assemble_layout | ( | const string_t & | layout_name, |
const layout_assembly_t & | assembly, | ||
std::ostream & | out | ||
) |
Assembles fundamental layout components into a CEL-syntax layout definition.
- Parameters:
-
layout_name the name to give to the final layout. assembly the fundamental layout components to be used in the layout creation out the stream to which the final result is to be output
layout_assembly_t adobe::disassemble_layout | ( | std::istream & | stream, |
const line_position_t & | position | ||
) |
Breaks down a layout definition to its fundamental components.
- Parameters:
-
stream the layout definition stream position an adobe::line_position_t describing the stream
- Returns:
- an adobe::layout_assembly_t fully describing the layout components