MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
property_value.hpp
Go to the documentation of this file.
1 #pragma once
2 
12 
13 #include <optional>
14 
15 namespace mbgl {
16 namespace style {
17 namespace conversion {
18 
19 template <class T>
21  std::optional<PropertyValue<T>> operator()(const Convertible& value, Error& error, bool allowDataExpressions, bool convertTokens) const;
22 
23  template <class S>
25  return PropertyValue<T>(t);
26  };
27 
29  return hasTokens(t)
31  : PropertyValue<T>(t);
32  }
33 
35  // This only works with a single-section `Formatted` created automatically
36  // by parsing a plain-text `text-field` property.
37  // Token conversion happens later than the initial string->Formatted conversion
38  // General purpose `format` expressions with embedded tokens are not supported
39  const std::string& firstUnformattedSection = t.sections[0].text;
40  return hasTokens(firstUnformattedSection)
42  : PropertyValue<T>(t);
43  }
44 
46  return hasTokens(image.id())
49  }
50 };
51 
52 template <>
53 struct Converter<PropertyValue<std::array<double, 3>>, void> {
54  std::optional<PropertyValue<std::array<double, 3>>> operator()(const Convertible& value, Error& error, bool, bool) const;
55 };
56 } // namespace conversion
57 } // namespace style
58 } // namespace mbgl
std::vector< FormattedSection > sections
Definition: formatted.hpp:58
std::unique_ptr< expression::Expression > convertTokenStringToExpression(const std::string &)
bool hasTokens(const std::string &)
std::unique_ptr< expression::Expression > convertTokenStringToImageExpression(const std::string &)
std::unique_ptr< expression::Expression > convertTokenStringToFormatExpression(const std::string &)
std::unique_ptr< Expression > error(std::string)
std::unique_ptr< Expression > image(const char *value)
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
Definition: actor.hpp:15
Definition: tile_id.hpp:256
PropertyValue< T > maybeConvertTokens(const S &t) const
PropertyValue< T > maybeConvertTokens(const expression::Image &image) const
PropertyValue< T > maybeConvertTokens(const expression::Formatted &t) const
PropertyValue< T > maybeConvertTokens(const std::string &t) const
std::optional< PropertyValue< T > > operator()(const Convertible &value, Error &error, bool allowDataExpressions, bool convertTokens) const