GDAL
Public Member Functions | List of all members
OGRStyleMgr Class Reference

This class represents a style manager. More...

#include <ogr_featurestyle.h>

Public Member Functions

 OGRStyleMgr (OGRStyleTable *poDataSetStyleTable=nullptr)
 Constructor. More...
 
 ~OGRStyleMgr ()
 Destructor. More...
 
GBool SetFeatureStyleString (OGRFeature *, const char *pszStyleString=nullptr, GBool bNoMatching=FALSE)
 Set a style in a feature. More...
 
const char * InitFromFeature (OGRFeature *)
 Initialize style manager from the style string of a feature. More...
 
GBool InitStyleString (const char *pszStyleString=nullptr)
 Initialize style manager from the style string. More...
 
const char * GetStyleName (const char *pszStyleString=nullptr)
 Get the name of a style from the style table. More...
 
const char * GetStyleByName (const char *pszStyleName)
 find a style in the current style table. More...
 
GBool AddStyle (const char *pszStyleName, const char *pszStyleString=nullptr)
 Add a style to the current style table. More...
 
const char * GetStyleString (OGRFeature *=nullptr)
 Get the style string from the style manager. More...
 
GBool AddPart (OGRStyleTool *)
 Add a part (style tool) to the current style. More...
 
GBool AddPart (const char *)
 Add a part (style string) to the current style. More...
 
int GetPartCount (const char *pszStyleString=nullptr)
 Get the number of parts in a style. More...
 
OGRStyleToolGetPart (int hPartId, const char *pszStyleString=nullptr)
 Fetch a part (style tool) from the current style. More...
 

Detailed Description

This class represents a style manager.

Constructor & Destructor Documentation

◆ OGRStyleMgr()

OGRStyleMgr::OGRStyleMgr ( OGRStyleTable poDataSetStyleTable = nullptr)
explicit

Constructor.

This method is the same as the C function OGR_SM_Create()

Parameters
poDataSetStyleTable(currently unused, reserved for future use), pointer to OGRStyleTable. Pass NULL for now.

◆ ~OGRStyleMgr()

OGRStyleMgr::~OGRStyleMgr ( )

Destructor.

This method is the same as the C function OGR_SM_Destroy()

Member Function Documentation

◆ AddPart() [1/2]

GBool OGRStyleMgr::AddPart ( const char *  pszPart)

Add a part (style string) to the current style.

Parameters
pszPartthe style string defining the part to add.
Returns
TRUE on success, FALSE on errors.

◆ AddPart() [2/2]

GBool OGRStyleMgr::AddPart ( OGRStyleTool poStyleTool)

Add a part (style tool) to the current style.

This method is the same as the C function OGR_SM_AddPart().

Parameters
poStyleToolthe style tool defining the part to add.
Returns
TRUE on success, FALSE on errors.

◆ AddStyle()

GBool OGRStyleMgr::AddStyle ( const char *  pszStyleName,
const char *  pszStyleString = nullptr 
)

Add a style to the current style table.

This method is the same as the C function OGR_SM_AddStyle().

Parameters
pszStyleNamethe name of the style to add.
pszStyleStringthe style string to use, or NULL to use the style stored in the manager.
Returns
TRUE on success, FALSE on errors.

◆ GetPart()

OGRStyleTool * OGRStyleMgr::GetPart ( int  nPartId,
const char *  pszStyleString = nullptr 
)

Fetch a part (style tool) from the current style.

This method is the same as the C function OGR_SM_GetPart().

This method instantiates a new object that should be freed with OGR_ST_Destroy().

Parameters
nPartIdthe part number (0-based index).
pszStyleString(optional) the style string on which to operate. If NULL then the current style string stored in the style manager is used.
Returns
OGRStyleTool of the requested part (style tools) or NULL on error.

◆ GetPartCount()

int OGRStyleMgr::GetPartCount ( const char *  pszStyleString = nullptr)

Get the number of parts in a style.

This method is the same as the C function OGR_SM_GetPartCount().

Parameters
pszStyleString(optional) the style string on which to operate. If NULL then the current style string stored in the style manager is used.
Returns
the number of parts (style tools) in the style.

◆ GetStyleByName()

const char * OGRStyleMgr::GetStyleByName ( const char *  pszStyleName)

find a style in the current style table.

Parameters
pszStyleNamethe name of the style to add.
Returns
the style string matching the name or NULL if not found or error.

◆ GetStyleName()

const char * OGRStyleMgr::GetStyleName ( const char *  pszStyleString = nullptr)

Get the name of a style from the style table.

Parameters
pszStyleStringthe style to search for, or NULL to use the style currently stored in the manager.
Returns
The name if found, or NULL on error.

◆ GetStyleString()

const char * OGRStyleMgr::GetStyleString ( OGRFeature poFeature = nullptr)

Get the style string from the style manager.

Parameters
poFeaturefeature object from which to read the style or NULL to get the style string stored in the manager.
Returns
the style string stored in the feature or the style string stored in the style manager if poFeature is NULL

NOTE: this method will call OGRStyleMgr::InitFromFeature() if poFeature is not NULL and replace the style string stored in the style manager

◆ InitFromFeature()

const char * OGRStyleMgr::InitFromFeature ( OGRFeature poFeature)

Initialize style manager from the style string of a feature.

This method is the same as the C function OGR_SM_InitFromFeature().

Parameters
poFeaturefeature object from which to read the style.
Returns
a reference to the style string read from the feature, or NULL in case of error..

◆ InitStyleString()

GBool OGRStyleMgr::InitStyleString ( const char *  pszStyleString = nullptr)

Initialize style manager from the style string.

Style string can be an expanded style string (e.g. "PEN(c:#FF0000,w:5px)"), or (starting with GDAL 3.5.1), a reference to a style name starting with @ (e.g. "@my_style") registered in the associated style table.

This method is the same as the C function OGR_SM_InitStyleString().

Parameters
pszStyleStringthe style string to use (can be NULL).
Returns
TRUE on success, FALSE on errors.

◆ SetFeatureStyleString()

GBool OGRStyleMgr::SetFeatureStyleString ( OGRFeature poFeature,
const char *  pszStyleString = nullptr,
GBool  bNoMatching = FALSE 
)

Set a style in a feature.

Parameters
poFeaturethe feature object to store the style in
pszStyleStringthe style to store
bNoMatchingTRUE to lookup the style in the style table and add the name to the feature
Returns
TRUE on success, FALSE on error.

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