Spicy
Public Member Functions | Static Public Member Functions | List of all members
hilti::AttributeSet Class Reference

#include <attribute.h>

Inheritance diagram for hilti::AttributeSet:
hilti::NodeBase hilti::trait::isNode

Public Member Functions

 AttributeSet (std::vector< Attribute > a, Meta m=Meta())
 
 AttributeSet (Meta m=Meta())
 
auto attributes () const
 
hilti::optional_ref< const Attributefind (std::string_view tag) const
 
auto findAll (std::string_view tag) const
 
Result< bool > coerceValueTo (const std::string &tag, const Type &dst)
 
bool has (std::string_view tag) const
 
auto properties () const
 
bool operator== (const AttributeSet &other) const
 
 operator bool () const
 
- Public Member Functions inherited from hilti::NodeBase
 NodeBase (Meta meta)
 
 NodeBase (std::vector< Node > childs, Meta meta)
 
template<typename T >
const T & child (int i) const
 
template<typename T >
void assertChildIsA (int i)
 
template<typename T >
auto childs (int begin, int end) const
 
auto childRefs (int begin, int end)
 
template<typename T >
hilti::node::Set< T > childsOfType () const
 
template<typename T >
std::vector< NodeRefchildRefsOfType () const
 
void addChild (Node n)
 
const auto & childs () const
 
auto & childs ()
 
auto & meta () const
 
void setMeta (Meta m)
 
bool pruneWalk () const
 

Static Public Member Functions

static AttributeSet add (AttributeSet s, Attribute a)
 
static AttributeSet add (std::optional< AttributeSet > s, Attribute a)
 
static hilti::optional_ref< const Attributefind (const hilti::optional_ref< const AttributeSet > &attrs, std::string_view tag)
 
static hilti::node::Set< AttributefindAll (const std::optional< const AttributeSet > &attrs, std::string_view tag)
 
static hilti::node::Set< AttributefindAll (const hilti::optional_ref< const AttributeSet > &attrs, std::string_view tag)
 
static bool has (const std::optional< AttributeSet > &attrs, std::string_view tag)
 

Detailed Description

AST node holding a set of Attribute nodes.

Constructor & Destructor Documentation

◆ AttributeSet() [1/2]

hilti::AttributeSet::AttributeSet ( std::vector< Attribute a,
Meta  m = Meta() 
)
inlineexplicit

Constructs a set from from a vector of attributes.

Parameters
avector to initialize attribute set from
mmeta data to associate with the node

◆ AttributeSet() [2/2]

hilti::AttributeSet::AttributeSet ( Meta  m = Meta())
inline

Constructs an empty set.

Parameters
mmeta data to associate with the node

Member Function Documentation

◆ add() [1/2]

static AttributeSet hilti::AttributeSet::add ( AttributeSet  s,
Attribute  a 
)
inlinestatic

Returns a new attribute set that adds one element.

Parameters
sset to add to.
aelement to add.
Returns
s with `a' added

◆ add() [2/2]

static AttributeSet hilti::AttributeSet::add ( std::optional< AttributeSet s,
Attribute  a 
)
inlinestatic

Returns a new attribute set that adds one element.

Parameters
sset to add to.
aelement to add.
Returns
s with `a' added

◆ attributes()

auto hilti::AttributeSet::attributes ( ) const
inline

Returns the set's attributes.

◆ coerceValueTo()

Result<bool> hilti::AttributeSet::coerceValueTo ( const std::string &  tag,
const Type dst 
)
inline

If an attribute of a given name exists and has an expression value, the value is coerced to a specified type. If not, nothing is done.

Returns
A successful return value if either the coercion succeeded (then the result's value is true), or nothing was to be done (then the result's value is false); a failures if a coercion would have been necessary, but failed.

◆ find() [1/2]

hilti::optional_ref<const Attribute> hilti::AttributeSet::find ( std::string_view  tag) const
inline

Retrieves an attribute with a given name from the set. If multiple attributes with that tag exist, it's undefined which is returned.

Returns
attribute if found

◆ find() [2/2]

static hilti::optional_ref<const Attribute> hilti::AttributeSet::find ( const hilti::optional_ref< const AttributeSet > &  attrs,
std::string_view  tag 
)
inlinestatic

Retrieves an attribute with a given name from a set, dealing correctly with an unset optional set. If multiple attributes with that tag exist, it's undefined which is returned.

Parameters
attrsset to inspect
Returns
attribute if found

◆ findAll() [1/3]

auto hilti::AttributeSet::findAll ( std::string_view  tag) const
inline

Retrieves all attributes with a given name from the set.

Returns
all attributes with matching name

◆ findAll() [2/3]

static hilti::node::Set<Attribute> hilti::AttributeSet::findAll ( const std::optional< const AttributeSet > &  attrs,
std::string_view  tag 
)
inlinestatic

Retrieves all attribute with a given name from a set, dealing correctly with an unset optional set.

Parameters
attrsset to inspect
Returns
all attributes with matching name

◆ findAll() [3/3]

static hilti::node::Set<Attribute> hilti::AttributeSet::findAll ( const hilti::optional_ref< const AttributeSet > &  attrs,
std::string_view  tag 
)
inlinestatic

Retrieves all attribute with a given name from a set, dealing correctly with an unset optional set.

Parameters
attrsset to inspect
Returns
all attributes with matching name

◆ has() [1/2]

bool hilti::AttributeSet::has ( std::string_view  tag) const
inline

Returns true if there's an attribute with a given name in the set.

Parameters
trueif found

◆ has() [2/2]

static bool hilti::AttributeSet::has ( const std::optional< AttributeSet > &  attrs,
std::string_view  tag 
)
inlinestatic

Returns true if there's an attribute with a given name in a set, dealing correctly with an unset optional set.

Parameters
attrsset to inspect
trueif found

◆ operator bool()

hilti::AttributeSet::operator bool ( ) const
inline

Returns true if the set has at least one element.

◆ properties()

auto hilti::AttributeSet::properties ( ) const
inline

Implements Node interface.


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