A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::flow::Value Class Reference

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.
 

Detailed Description

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.

Member Typedef Documentation

◆ Pairs

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.

Member Enumeration Documentation

◆ Kind

enum class a11::flow::Value::Kind
strong
Enumerator
kNull 

A value that is not there: an absent key, an empty stream, a missing header.

One kind for all of them, because a flow asking if not x should not have to know which sort of nothing it got.

kBool 
kInteger 
kDouble 
kString 
kBytes 
kList 
kObject 
kDuration 
kTime 
kChunk 

An undecoded chunk, kept whole so a pipe that only moves values re-writes the producer's own bytes and mimetype.

kHost 

Constructor & Destructor Documentation

◆ Value()

a11::flow::Value::Value ( )
default

Member Function Documentation

◆ Bool()

Value a11::flow::Value::Bool ( bool  value)
static

◆ boolean()

bool a11::flow::Value::boolean ( ) const
inline

◆ Bytes()

Value a11::flow::Value::Bytes ( data::Bytes  value)
static

◆ chunk()

const data::Chunk & a11::flow::Value::chunk ( ) const
inline

◆ Chunk()

Value a11::flow::Value::Chunk ( data::Chunk  chunk)
static

◆ Double()

Value a11::flow::Value::Double ( double  value)
static

◆ duration()

absl::Duration a11::flow::Value::duration ( ) const
inline

◆ Duration()

Value a11::flow::Value::Duration ( absl::Duration  value)
static

◆ Get()

const Value *absl_nullable a11::flow::Value::Get ( std::string_view  key) const

The value at key of an object, or nullptr.

◆ host()

const HostObject & a11::flow::Value::host ( ) const
inline

◆ Host()

Value a11::flow::Value::Host ( std::shared_ptr< const HostObject >  object)
static

◆ host_object()

const std::shared_ptr< const HostObject > & a11::flow::Value::host_object ( ) const
inline

◆ integer()

std::int64_t a11::flow::Value::integer ( ) const
inline

◆ Integer()

Value a11::flow::Value::Integer ( std::int64_t  value)
static

◆ IsNull()

bool a11::flow::Value::IsNull ( ) const
inline

◆ IsNumber()

bool a11::flow::Value::IsNumber ( ) const
inline

◆ IsTextlike()

bool a11::flow::Value::IsTextlike ( ) const
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.

◆ IsTimelike()

bool a11::flow::Value::IsTimelike ( ) const
inline

◆ items()

const std::vector< Value > & a11::flow::Value::items ( ) const
inline

◆ kind()

Kind a11::flow::Value::kind ( ) const
inline

◆ List()

Value a11::flow::Value::List ( std::vector< Value >  items)
static

◆ Null()

static Value a11::flow::Value::Null ( )
inlinestatic

◆ number()

double a11::flow::Value::number ( ) const
inline

◆ Object()

Value a11::flow::Value::Object ( Pairs  pairs)
static

◆ Of()

Value a11::flow::Value::Of ( const syntax::Constant &  constant)
static

The value a Constant – a literal, or a folded literal expression – is.

◆ pairs()

const Pairs & a11::flow::Value::pairs ( ) const
inline

◆ String()

Value a11::flow::Value::String ( std::string  value)
static

◆ text()

const std::string & a11::flow::Value::text ( ) const
inline

◆ time()

absl::Time a11::flow::Value::time ( ) const
inline

◆ Time()

Value a11::flow::Value::Time ( absl::Time  value)
static

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const Value &  left,
const Value &  right 
)
friend

Whether the two values are equal, as == in a flow decides it.


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