Downcast helper functions

When you create a new derived class object from a base class object, the base class object must contain an object of the same derived class. Otherwise, the new derived class object will not be valid. Be careful to use the correct constructor and input type to ensure the constructed object is valid. You can use these helper functions for this. Each function performs type-safe downcasting, accepting a base class object and returning a new derived class object. The new object will be empty if the base class object does not contain the derived class or is empty. Use the isValid function on the new object to check its validity.

Here are the base classes whose derived classes can use the corresponding helper functions.

Every helper function follows the same signature pattern.

DerivedClassName dci = helper_function_name<BaseClassName>(bci);


  • DerivedClassName is the name of the derived class (such as Point).
  • dci is the variable to receive the derived class instance.
  • helper_function_name is the name of the helper functions (such as geometry_cast).
  • BaseClassName is the name of the base class (such as Geometry).
  • bci is the variable containing the base class instance.

For example, casting StretchParameters-derived class to StretchParameters is always valid.

MinMaxStretchParameters minMaxStretchParameters(minValues, maxValues);
StretchParameters stretchParameters = stretch_parameters_cast<StretchParameters>(minMaxStretchParameters);

But casting from StretchParameters to StretchParameters-derived class is valid only if stretchParametersType is the same type as target type.

StretchParameters stretchParameters = stretchRenderer->stretchParameters();
MinMaxStretchParameters minMaxStretchParameters = stretch_parameters_cast<MinMaxStretchParameters>(stretchParameters);

StretchParameters invalidStretchParameters = invalidStretchRenderer->stretchParameters();
MinMaxStretchParameters invalidMinMaxStretchParameters = stretch_parameters_cast<MinMaxStretchParameters>(invalidStretchParameters);

The following classes can be used with the downcast helper functions.


Indicates the units of measurement of an instance of AngularUnit, or an angular measurement operation


Indicates the units of measurement of an instance of AreaUnit, or area measurement operation


A domain which specifies an explicit set of valid values for a field


Represents a rectangular area, defined by a minimum and maximum x-coordinate and a minimum and maximum y-coordinate, and a spatial reference


Information about the feature service metadata for an ArcGIS Feature Service


A histogram equalization stretch parameters object


A domain which applies to domains on subtypes


Indicates the specific units of measurement of an instance of LinearUnit, or linear measurement operation


An object that represents the sub layer metadata for a Map service


A minimum/maximum stretch parameters object


An ordered collection of points that can be managed as a single geometry


A percent clip stretch parameters object


Represents a specific location, defined by x and y (and optionally z) coordinates, and a SpatialReference


A multipart shape used to represent an area


A multipart shape used to represent a linear feature


A domain which specifies a range of valid values for a field


A standard deviation stretch parameters object


Base class for various Stretch parameters

Note: The constructors for these classes may be marked as explicit in future versions. In the meantime, you should follow the recommended pattern of using the downcast helper function for casting from the base class, then using isValid function on the derived class to ensure the object is valid.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.