|
A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
|
One Flow value. More...
#include <cpp/a11/flow/values.h>
Public Types | |
| enum class | Kind { kNull , kBool , kInteger , kDouble , kString , kBytes , kList , kObject , kDuration , kTime , kChunk , kHost } |
| using | Pairs = std::vector< std::pair< std::string, Value > > |
| The pairs of an object, in the order they were written. | |
Public Member Functions | |
| Value ()=default | |
| Kind | kind () const |
| bool | IsNull () const |
| bool | IsNumber () const |
| bool | IsTimelike () const |
| bool | IsTextlike () const |
| Whether the value is one the language itself can take apart: a string or a byte string, which index and slice but are not containers of values. | |
| bool | boolean () const |
| std::int64_t | integer () const |
| double | number () const |
| const std::string & | text () const |
| const std::vector< Value > & | items () const |
| const Pairs & | pairs () const |
| absl::Duration | duration () const |
| absl::Time | time () const |
| const data::Chunk & | chunk () const |
| const HostObject & | host () const |
| const std::shared_ptr< const HostObject > & | host_object () const |
| const Value *absl_nullable | Get (std::string_view key) const |
The value at key of an object, or nullptr. | |
Static Public Member Functions | |
| static Value | Null () |
| static Value | Bool (bool value) |
| static Value | Integer (std::int64_t value) |
| static Value | Double (double value) |
| static Value | String (std::string value) |
| static Value | Bytes (data::Bytes value) |
| static Value | List (std::vector< Value > items) |
| static Value | Object (Pairs pairs) |
| static Value | Duration (absl::Duration value) |
| static Value | Time (absl::Time value) |
| static Value | Chunk (data::Chunk chunk) |
| static Value | Host (std::shared_ptr< const HostObject > object) |
| static Value | Of (const syntax::Constant &constant) |
The value a Constant – a literal, or a folded literal expression – is. | |
Friends | |
| bool | operator== (const Value &left, const Value &right) |
Whether the two values are equal, as == in a flow decides it. | |
One Flow value.
Immutable and cheap to copy: a container is held behind a shared_ptr, so an item read once and handed to eight readers is one allocation, not eight. Integers are kept apart from doubles because the language's own output depends on it – text 3 is "3" and text 3.0 is "3.0", exactly as the Python reference rendered them – and because a count of values has to be a whole number of them.
| using a11::flow::Value::Pairs = std::vector<std::pair<std::string, Value> > |
The pairs of an object, in the order they were written.
A vector rather than a hash map: a flow's objects have a handful of keys, insertion order is what a value written back out should keep, and a linear scan over five entries beats hashing them.
|
strong |
|
default |
|
static |
|
inline |
|
static |
|
inline |
|
static |
|
static |
|
inline |
|
static |
| const Value *absl_nullable a11::flow::Value::Get | ( | std::string_view | key | ) | const |
The value at key of an object, or nullptr.
|
inline |
|
static |
|
inline |
|
inline |
|
static |
|
inline |
|
inline |
|
inline |
Whether the value is one the language itself can take apart: a string or a byte string, which index and slice but are not containers of values.
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
static |
The value a Constant – a literal, or a folded literal expression – is.
|
inline |
|
static |
|
inline |
|
inline |
|
static |
Whether the two values are equal, as == in a flow decides it.