QGIS API Documentation 4.3.0-Master (9dce731a7a1)
Loading...
Searching...
No Matches
qgsdatadefinedutils.h File Reference
#include <algorithm>
#include <array>
#include <optional>
#include "qgis_core.h"
Include dependency graph for qgsdatadefinedutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  QgsDataDefinedStringDecoder< V, N >
 A template based class for efficiently decoding a string value to a corresponding enum value. More...

Macros

#define SIP_NO_FILE

Functions

template<typename V, size_t N>
constexpr QgsDataDefinedStringDecoder< V, N > makeDataDefinedStringDecoder (const DataDefinedDecoderEntry< V >(&values)[N])
 Creates a QgsDataDefinedStringDecoder from a hardcoded lookup table.

Macro Definition Documentation

◆ SIP_NO_FILE

#define SIP_NO_FILE

Definition at line 25 of file qgsdatadefinedutils.h.

Function Documentation

◆ makeDataDefinedStringDecoder()

template<typename V, size_t N>
QgsDataDefinedStringDecoder< V, N > makeDataDefinedStringDecoder ( const DataDefinedDecoderEntry< V >(&) values[N])
constexpr

Creates a QgsDataDefinedStringDecoder from a hardcoded lookup table.

String keys must:

  • be non-empty
  • start with a letter character (a-z)
  • be completely lower-case
  • be unique
  • not contain spaces, hyphens or underscores

Usage:

// create a decoder once as a static object
static constexpr auto sPointPositionMap = makeDataDefinedStringDecoder<Qgis::LabelPredefinedPointPosition>( {
} );
// use the static object to lookup candidate string values
if ( auto evaluatedPosition = sPointPositionMap.lookup( candidate ) )
{
// string was successfully matched, use the matched enum value
Qgis::LabelPredefinedPointPosition position = *evaluatedPosition;
}
else
{
// string did not match any entry in the lookup table...
}
LabelPredefinedPointPosition
Positions for labels when using the Qgis::LabelPlacement::OrderedPositionsAroundPoint placement mode.
Definition qgis.h:1342
@ TopRight
Label on top-right of point.
Definition qgis.h:1347
@ TopLeft
Label on top-left of point.
Definition qgis.h:1343
constexpr QgsDataDefinedStringDecoder< V, N > makeDataDefinedStringDecoder(const DataDefinedDecoderEntry< V >(&values)[N])
Creates a QgsDataDefinedStringDecoder from a hardcoded lookup table.
Since
QGIS 4.4

Definition at line 256 of file qgsdatadefinedutils.h.