MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mbgl::style::expression Namespace Reference

Namespaces

 detail
 
 dsl
 
 type
 

Classes

class  Assertion
 
class  At
 
class  Any
 
class  All
 
class  Case
 
class  Coalesce
 
class  Coercion
 
class  Collator
 
class  CollatorExpression
 
class  BasicComparison
 
class  CollatorComparison
 
class  CompoundExpression
 
class  Distance
 
class  Error
 
class  EvaluationError
 
class  EvaluationContext
 
class  Result
 
class  EvaluationResult
 
class  Expression
 
struct  FormatExpressionSection
 
class  FormatExpression
 
class  FormatSectionOverride
 
struct  FormattedSection
 
class  Formatted
 
class  Image
 
class  ImageExpression
 
class  In
 
class  Interpolate
 
class  ExponentialInterpolator
 
class  CubicBezierInterpolator
 
class  Length
 
class  Let
 
class  Var
 
class  Literal
 
class  Match
 
class  NumberFormat
 
struct  ParsingError
 
class  ParsingContext
 
class  Step
 
struct  Value
 
struct  ValueConverter
 
struct  ValueConverter< Value >
 
struct  ValueConverter< mbgl::Value >
 
struct  ValueConverter< float >
 
struct  ValueConverter< std::array< T, N > >
 
struct  ValueConverter< std::vector< T > >
 
struct  ValueConverter< Position >
 
struct  ValueConverter< T, std::enable_if_t< std::is_enum_v< T > > >
 
struct  ValueConverter< Rotation >
 
class  Within
 

Typedefs

using Interpolator = variant< ExponentialInterpolator, CubicBezierInterpolator >
 
using ParseResult = std::optional< std::unique_ptr< Expression > >
 
using ValueBase = variant< NullValue, bool, double, std::string, Color, Collator, Formatted, Image, mapbox::util::recursive_wrapper< std::vector< Value > >, mapbox::util::recursive_wrapper< std::unordered_map< std::string, Value > >>
 

Enumerations

enum class  Kind : int32_t {
  Coalesce , CompoundExpression , Literal , At ,
  Interpolate , Assertion , Length , Step ,
  Let , Var , CollatorExpression , Coercion ,
  Match , Error , Case , Any ,
  All , Comparison , FormatExpression , FormatSectionOverride ,
  NumberFormat , ImageExpression , In , Within ,
  Distance
}
 
enum class  TypeAnnotationOption { coerce , assert , omit }
 

Functions

ParseResult parseComparison (const mbgl::style::conversion::Convertible &, ParsingContext &)
 
ParseResult parseCompoundExpression (const std::string &name, const mbgl::style::conversion::Convertible &value, ParsingContext &ctx)
 
ParseResult createCompoundExpression (const std::string &name, std::vector< std::unique_ptr< Expression >> args, ParsingContext &ctx)
 
std::optional< variant< const Interpolate *, const Step *, ParsingError > > findZoomCurve (const expression::Expression *e)
 
variant< std::nullptr_t, const Interpolate *, const Step * > findZoomCurveChecked (const expression::Expression *e)
 
Range< float > getCoveringStops (const std::map< double, std::unique_ptr< Expression >> &stops, double lower, double upper)
 Return the smallest range of stops that covers the interval [lower, upper]. More...
 
ParseResult parseInterpolate (const mbgl::style::conversion::Convertible &value, ParsingContext &ctx)
 
ParseResult createInterpolate (type::Type type, Interpolator interpolator, std::unique_ptr< Expression > input, std::map< double, std::unique_ptr< Expression >> stops, ParsingContext &ctx)
 
template<typename T >
bool isGlobalPropertyConstant (const Expression &expression, const T &properties)
 
bool isFeatureConstant (const Expression &expression)
 
bool isZoomConstant (const Expression &e)
 
bool isRuntimeConstant (const Expression &e)
 Returns true if expression does not depend on information provided by the runtime. More...
 
bool isExpression (const conversion::Convertible &value)
 
ParseResult parseMatch (const mbgl::style::conversion::Convertible &value, ParsingContext &ctx)
 
bool isExpression (const std::string &)
 
type::Type typeOf (const Value &value)
 
std::string toString (const Value &value)
 
std::string stringify (const Value &value)
 
template<typename T >
type::Type valueTypeToExpressionType ()
 
template<typename T >
Value toExpressionValue (const T &value)
 
template<typename T >
std::optional< T > fromExpressionValue (const Value &value)
 
template<typename T >
std::vector< std::optional< T > > fromExpressionValues (const std::vector< std::optional< Value >> &values)
 

Variables

const char *const kFormattedSectionFontScale
 
const char *const kFormattedSectionTextFont
 
const char *const kFormattedSectionTextColor
 
constexpr NullValue Null = NullValue()
 

Typedef Documentation

◆ Interpolator

◆ ParseResult

using mbgl::style::expression::ParseResult = typedef std::optional<std::unique_ptr<Expression> >

Definition at line 28 of file parsing_context.hpp.

◆ ValueBase

using mbgl::style::expression::ValueBase = typedef variant<NullValue, bool, double, std::string, Color, Collator, Formatted, Image, mapbox::util::recursive_wrapper<std::vector<Value> >, mapbox::util::recursive_wrapper<std::unordered_map<std::string, Value> >>

Definition at line 25 of file value.hpp.

Enumeration Type Documentation

◆ Kind

enum mbgl::style::expression::Kind : int32_t
strong

Expression is an abstract class that serves as an interface and base class for particular expression implementations.

CompoundExpression implements the majority of expressions in the spec by inferring the argument and output from a simple function (const T0& arg0, const T1& arg1, ...) -> Result where T0, T1, ..., U are member types of mbgl::style::expression::Value.

The other Expression subclasses (Let, Curve, Match, etc.) exist in order to implement expressions that need specialized parsing, type checking, or evaluation logic that can't be handled by CompoundExpression's inference mechanism.

Each Expression subclass also provides a static ParseResult ExpressionClass::parse(const V&, ParsingContext), which handles parsing a style-spec JSON representation of the expression.

Enumerator
Coalesce 
CompoundExpression 
Literal 
At 
Interpolate 
Assertion 
Length 
Step 
Let 
Var 
CollatorExpression 
Coercion 
Match 
Error 
Case 
Any 
All 
Comparison 
FormatExpression 
FormatSectionOverride 
NumberFormat 
ImageExpression 
In 
Within 
Distance 

Definition at line 151 of file expression.hpp.

◆ TypeAnnotationOption

Controls the annotation behavior of the parser when encountering an expression whose type is not a subtype of the expected type. The default behavior, used when optional<TypeAnnotationOption> is a nullopt, is as follows:

When we expect a number, string, boolean, or array but have a value, wrap it in an assertion. When we expect a color or formatted string, but have a string or value, wrap it in a coercion. Otherwise, we do static type-checking.

These behaviors are overridable for: The "coalesce" operator, which needs to omit type annotations. String-valued properties (e.g. text-field), where coercion is more convenient than assertion.

Enumerator
coerce 
assert 
omit 

Definition at line 69 of file parsing_context.hpp.

Function Documentation

◆ createCompoundExpression()

ParseResult mbgl::style::expression::createCompoundExpression ( const std::string &  name,
std::vector< std::unique_ptr< Expression >>  args,
ParsingContext ctx 
)

◆ createInterpolate()

ParseResult mbgl::style::expression::createInterpolate ( type::Type  type,
Interpolator  interpolator,
std::unique_ptr< Expression input,
std::map< double, std::unique_ptr< Expression >>  stops,
ParsingContext ctx 
)

◆ findZoomCurve()

std::optional<variant<const Interpolate*, const Step*, ParsingError> > mbgl::style::expression::findZoomCurve ( const expression::Expression e)

◆ findZoomCurveChecked()

variant<std::nullptr_t, const Interpolate*, const Step*> mbgl::style::expression::findZoomCurveChecked ( const expression::Expression e)

◆ fromExpressionValue()

template<typename T >
std::optional<T> mbgl::style::expression::fromExpressionValue ( const Value value)

Definition at line 144 of file value.hpp.

◆ fromExpressionValues()

template<typename T >
std::vector<std::optional<T> > mbgl::style::expression::fromExpressionValues ( const std::vector< std::optional< Value >> &  values)

Definition at line 149 of file value.hpp.

◆ getCoveringStops()

Range<float> mbgl::style::expression::getCoveringStops ( const std::map< double, std::unique_ptr< Expression >> &  stops,
double  lower,
double  upper 
)

Return the smallest range of stops that covers the interval [lower, upper].

◆ isExpression() [1/2]

bool mbgl::style::expression::isExpression ( const conversion::Convertible value)

◆ isExpression() [2/2]

bool mbgl::style::expression::isExpression ( const std::string &  )

◆ isFeatureConstant()

bool mbgl::style::expression::isFeatureConstant ( const Expression expression)

◆ isGlobalPropertyConstant()

template<typename T >
bool mbgl::style::expression::isGlobalPropertyConstant ( const Expression expression,
const T &  properties 
)

Definition at line 11 of file is_constant.hpp.

◆ isRuntimeConstant()

bool mbgl::style::expression::isRuntimeConstant ( const Expression e)

Returns true if expression does not depend on information provided by the runtime.

◆ isZoomConstant()

bool mbgl::style::expression::isZoomConstant ( const Expression e)

◆ parseComparison()

ParseResult mbgl::style::expression::parseComparison ( const mbgl::style::conversion::Convertible ,
ParsingContext  
)

◆ parseCompoundExpression()

ParseResult mbgl::style::expression::parseCompoundExpression ( const std::string &  name,
const mbgl::style::conversion::Convertible value,
ParsingContext ctx 
)

◆ parseInterpolate()

ParseResult mbgl::style::expression::parseInterpolate ( const mbgl::style::conversion::Convertible value,
ParsingContext ctx 
)

◆ parseMatch()

ParseResult mbgl::style::expression::parseMatch ( const mbgl::style::conversion::Convertible value,
ParsingContext ctx 
)

◆ stringify()

std::string mbgl::style::expression::stringify ( const Value value)

◆ toExpressionValue()

template<typename T >
Value mbgl::style::expression::toExpressionValue ( const T &  value)

Definition at line 139 of file value.hpp.

◆ toString()

std::string mbgl::style::expression::toString ( const Value value)

◆ typeOf()

type::Type mbgl::style::expression::typeOf ( const Value value)

◆ valueTypeToExpressionType()

template<typename T >
type::Type mbgl::style::expression::valueTypeToExpressionType ( )

Variable Documentation

◆ kFormattedSectionFontScale

const char* const mbgl::style::expression::kFormattedSectionFontScale
extern

◆ kFormattedSectionTextColor

const char* const mbgl::style::expression::kFormattedSectionTextColor
extern

◆ kFormattedSectionTextFont

const char* const mbgl::style::expression::kFormattedSectionTextFont
extern

◆ Null

constexpr NullValue mbgl::style::expression::Null = NullValue()
constexpr

Definition at line 56 of file value.hpp.