A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
values.cc File Reference
#include "a11/flow/values.h"
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <limits>
#include <regex>
#include <set>
#include <utility>
#include <absl/status/status.h>
#include <absl/status/status_macros.h>
#include <absl/strings/ascii.h>
#include <absl/strings/escaping.h>
#include <absl/strings/match.h>
#include <absl/strings/str_cat.h>
#include <absl/strings/str_format.h>
#include <absl/strings/str_join.h>
#include <absl/strings/str_split.h>
#include <absl/time/clock.h>
#include <cmath>
#include <nlohmann/json.hpp>
#include "a11/data/serialization.h"
#include "a11/flow/internal/pattern.h"
#include "a11/flow/vocabulary.h"
#include "a11/time.h"
#include "a11/utf8.h"

Namespaces

namespace  a11
 
namespace  a11::flow
 

Functions

bool a11::flow::operator== (const Value &left, const Value &right)
 
std::unique_ptr< HostBridge > a11::flow::NativeHostBridge ()
 A bridge over A11's own C++ serialisation registry.
 
Value a11::flow::Lookup (const Value &value, const Value &key)
 Take key out of value: a mapping key, an index, or a field.
 
bool a11::flow::Truthy (const Value &value)
 Whether value counts as true, as an if and a where decide it.
 
std::string a11::flow::AsText (const Value &value)
 value as text, the way the text stage and builtin render it.
 
Value a11::flow::AsNumber (const Value &value)
 value as a number, or zero when there is nothing to read.
 
double a11::flow::AsDouble (const Value &value)
 AsNumber as a double, for the places that only want the magnitude.
 
Value a11::flow::AsHole (pattern::HoleType type, std::string_view text)
 One hole's text, read as the hole said to read it.
 
absl::StatusOr< Value > a11::flow::MatchPattern (std::string_view pattern, std::string_view subject)
 The fields a pattern pulls out of subject, or null where it does not fit.
 
Value a11::flow::MatchCompiled (const pattern::Pattern &pattern, std::string_view subject)
 The same, against a pattern already compiled.
 
Value a11::flow::AsJson (const Value &value)
 Text parsed as JSON; anything already decoded is left alone.
 
Value a11::flow::Truncate (const Value &value, std::int64_t size)
 The first size of a value: characters, bytes, elements or pairs.
 
std::string a11::flow::JsonText (const Value &value)
 A value's own JSON text, as json.dumps(sort_keys=True) writes it.
 
double a11::flow::DurationSeconds (absl::Duration value)
 A duration as a number of seconds, for every duration there is.
 
absl::Duration a11::flow::SecondsDuration (double total)
 A duration of total seconds, negative ones included.
 
std::optional< absl::Duration > a11::flow::ParseDuration (std::string_view text)
 A duration from the way the language writes one, or nullopt.
 
absl::Duration a11::flow::AsDuration (const Value &value)
 A duration from a duration, from written text, or from seconds.
 
std::optional< absl::Time > a11::flow::ParseTime (std::string_view text)
 An instant from RFC 3339 text, as TimeText writes it.
 
absl::Time a11::flow::AsTime (const Value &value)
 An instant from an instant, from RFC 3339 text, or from epoch seconds.
 
std::string a11::flow::DurationText (absl::Duration value, std::string_view spec={})
 A duration as text: 1m30s by default, or one unit when spec names one.
 
std::string a11::flow::TimeText (absl::Time value, std::string_view spec={})
 An instant as text: RFC 3339 in UTC, a strftime pattern, or epoch.
 
std::string a11::flow::Strformat (const Value &format, absl::Span< const Value > arguments)
 format with each % conversion replaced by one of arguments.
 
absl::StatusOr< Value > a11::flow::CallBuiltin (std::string_view name, absl::Span< const Value > arguments, HostBridge *absl_nullable bridge)
 Call one of the language's fixed functions.
 
absl::StatusOr< Value > a11::flow::CoerceShape (const DtoPlan &shape, const Value &value, const CoerceContext &context)
 Make value a value of shape: fill its defaults, check its bounds, and coerce every field to the type the shape gives it.
 
absl::StatusOr< Value > a11::flow::Coerce (const Value &value, const syntax::TypeExpression &type, const CoerceContext &context)
 Make value a value of the type type names.
 
int a11::flow::Order (const Value &left, const Value &right)
 Where two values sit relative to one another: -1, 0 or 1.
 
absl::StatusOr< Value > a11::flow::Add (const Value &left, const Value &right)
 left + right, as an expression means it.
 
absl::StatusOr< Value > a11::flow::Evaluate (const syntax::Node &node, const EvalContext &context)
 Evaluate one expression.
 
Value a11::flow::StatusRecord (const absl::Status &status)
 A status as the record a flow sees when it looks at an outcome.
 
std::optional< absl::StatusCode > a11::flow::StatusCodeOf (const Value &value)
 The canonical code value names, by name or by number, or nullopt.
 
absl::Status a11::flow::StatusOfRecord (const Value &record)
 The status a record like the one above describes.
 

Variable Documentation

◆ name

std::string_view name

◆ seconds

double seconds