GitHub    Download    Forum
Overview
Tutorial
C++ API
C# API
DTDL
Comments, Preprocessor
Definitions
Data types
Namespaces
Restrictions
DADL
Setup

Namespaces

Namespaces

DTDL supports namespaces. If you do not define or use namespaces, everything will be in the default unnamed namespace.
There are different ways of defining namespaces.
They can be defined in a way known from languages like C++:
namespace a
{
    namespace b
    {
        class q; // defines a::b::q
    }
}

namespace a::b
{
    class q; // defines a::b::q
}
in a shorter way or by simply putting the namespace name in front of the name of a new type.
class a::b::q; // defines a::b::q
Namespaces can also be used with #include or #use commands. In this case, the imported types and namespaces are put into the specified namespace.
For example, if you import a 'ca' class and an 'nm' namespace including another 'nm::jt' class into the 'q' namespace, you will get the 'q::ca' and 'q::nm::jt' classes and the 'q::nm' namespace.
#include <file.dtdl> namespace productA
#include "..\directory\file.dtdl" namespace productB::version2
Types can be imported into existing namespaces.
© 2022 Mobiland AG