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

Classes

struct  Capture
 What one hole took: a view into the subject that was matched. More...
 
struct  Compiled
 A pattern, or what is wrong with the text it was written as. More...
 
struct  Hole
 One capture position in a pattern. More...
 
struct  Pattern
 A compiled pattern: literals and holes, in the order they were written. More...
 

Enumerations

enum class  HoleType {
  kString , kInt , kNumber , kBool ,
  kWord , kLine , kRest , kDuration ,
  kTime , kJson
}
 Literal text and named holes used by match, such as age={age:int}. More...
 

Functions

std::string_view HoleTypeName (HoleType type)
 
std::optional< HoleType > HoleTypeFromName (std::string_view name)
 The type that name spells, or nothing where it is not one of them.
 
Compiled Compile (std::string_view text)
 Compile a pattern, saying what is wrong rather than throwing.
 
std::optional< std::vector< Capture > > Match (const Pattern &pattern, std::string_view subject)
 Match pattern anywhere in subject, taking the earliest fit.
 

Enumeration Type Documentation

◆ HoleType

enum class a11::flow::pattern::HoleType
strong

Literal text and named holes used by match, such as age={age:int}.

Matches search the input. Holes capture nonempty text and stay on one line unless their type permits line breaks. Captures retain text for decoding. What a hole reads its text as, and how much of it a hole may take.

Enumerator
kString 

Anything up to the next literal, on one line. The default.

kInt 

A whole number, with an optional sign.

kNumber 

A number, with an optional sign and fraction.

kBool 

true or false, in either case.

kWord 

A run of anything that is not whitespace.

kLine 

The rest of the line.

kRest 

Everything left, line breaks and all. Only as the last piece.

kDuration 

Text to be read as a duration: 250ms, 1m30s.

kTime 

Text to be read as an instant: RFC 3339, or a bare date.

kJson 

Text to be read as JSON.

Function Documentation

◆ Compile()

Compiled a11::flow::pattern::Compile ( std::string_view  text)

Compile a pattern, saying what is wrong rather than throwing.

◆ HoleTypeFromName()

std::optional< HoleType > a11::flow::pattern::HoleTypeFromName ( std::string_view  name)

The type that name spells, or nothing where it is not one of them.

◆ HoleTypeName()

std::string_view a11::flow::pattern::HoleTypeName ( HoleType  type)

◆ Match()

std::optional< std::vector< Capture > > a11::flow::pattern::Match ( const Pattern &  pattern,
std::string_view  subject 
)

Match pattern anywhere in subject, taking the earliest fit.

Nothing when it does not fit at all, which is how a stage knows to drop the value and a function knows to answer null.