This article describes commonly used C++ conventions in the API, and how they map to other supported languages.
C++ conventions
Grouping of functionality
A folder hierarchy is used to organize the API functionality into groups.
You can see this grouping in the Modules section of the API reference documentation.
std::optional
Within the API, methods can return a std::optional<T> to express the possibility that there is no result.
C# conventions
In essence, the LuciadCPillar C# API is the same as the C++ API.
It complies with C# naming conventions. This means that C# namespaces, classes, and method names follow the PascalCasing convention of C#.
The following sections explain how some C++ constructs are mapped within the C# API.
Namespaces
The namespaces for the C# API are related to the C++ API organization into folders. The C++ API uses a single namespace and organizes functionality in folders. The folder names are used as a basis for the C# namespace. The modules within the API reference documentation can be mapped directly to C# namespaces. The folder names are converted to PascalCasing for the C# namespace names.
For example:
-
The C++ class
luciad/cartesian/Coordinate.his available asLuciad.Cartesian.Coordinatewithin the C# API. -
The C++ class
luciad/geometries/Geometry.his available asLuciad.Geometries.Geometrywithin the C# API.
std::optional
The C++ optional convention for return values is mapped to C# as follows:
-
For primitive types,
std::optional<int>is mapped toint?, for example. -
For reference objects, the C++ method
std::optional<T> myMethod();becomesT MyMethod(). The return type of the method is the actual type and the value isnullwhen there is no result.
luciad::expected
The luciad::expected C++ convention for return values is mapped to C# as follows:
Java conventions
In essence, the LuciadCPillar Java API is the same as the C++ API.
It complies with Java naming conventions. This means that Java packages, classes, and method names follow the casing conventions of Java.
The following sections explain how some C++ constructs are mapped within the Java API.
Packages
The packages for the Java API are related to the C++ API organization into folders. The C++ API uses a single namespace and organizes functionality in folders. The folder names are used as a basis for the Java package. The modules within the API reference documentation can be mapped directly to Java packages.
For example:
-
The C++ class
luciad/cartesian/Coordinate.his available ascom.luciad.cartesian.Coordinatewithin the Java API. -
The C++ class
luciad/geometries/Geometry.his available ascom.luciad.geometries.Geometrywithin the Java API.
std::optional
The C++ optional convention for return values is mapped to Java as follows:
-
For primitive types,
std::optional<int>is mapped to its corresponding boxed typeInteger, for example. -
For reference objects, the C++ method
std::optional<T> myMethod();becomesT MyMethod(). The return type of the method is the actual type and the value isnullwhen there is no result.
luciad::expected
The luciad::expected C++ convention for return values is mapped to Java as follows:
Exceptions
Exceptions in C++ are mapped to Java exceptions in the following way:
-
luciad::NullArgumentExceptionis mapped tojava.lang.IllegalArgumentException -
luciad::InvalidArgumentExceptionis mapped tojava.lang.IllegalArgumentException -
luciad::IOExceptionis mapped tojava.io.IOException -
luciad::LogicExceptionis mapped tojava.lang.IllegalStateException -
luciad::LicenseExceptionis mapped toLicenseExceptionLicenseExceptionLicenseException -
luciad::ParseExceptionis mapped tojava.text.ParseException -
luciad::NotImplementedExceptionis mapped tojava.text.UnsupportedOperationException -
Other
luciad::Exceptioninstances are mapped tojava.lang.RuntimeException