Namespaces
As this library is part of a large framework, it’s nesting of namespaces may look unnecessary complicated. If using in context of larger applications, these additional levels of namespaces provide flexibility and prevent naming conflicts.
The Erbsland Qt TOML interface is placed in the namespace erbsland::qt::toml
:
-
namespace erbsland
The base namespace for all Erbsland DEV libraries.
-
namespace qt
The base namespace for all Erbsland DEV libraries that are made for the Qt library.
-
namespace toml
The namespace for the Erbsland Qt TOML library.
Shortcuts
To simplify your code, shortcuts for the base namespaces are automatically created by default.
namespace el = erbsland;
namespace elqt = erbsland::qt;
We recommended that you use either use these shortcuts to name the types from the library, or write using statements, importing the types you use into the namespace of your application.
#include <erbsland/qt/toml/Parser.hpp>
void foo() {
elqt::toml::Parser parser{};
// ...
}
#include <erbsland/qt/toml/Parser.hpp>
using elqt::toml::Parser;
// or `using erbsland::qt::toml::Parser;` when shortcuts are disabled.
void foo() {
Parser parser{};
// ...
}
Prevent or Redefine the Shortcuts
As the shortcuts can conflict with existing codes, there are several macro definitions that allow you to disable the shortcuts or redefine them. You will have to set these definition on the compile level for the whole project.
-
ERBSLAND_NO_SHORT_NAMESPACE
If you set this preprocessor directive, no namespace shortcuts are created by default. You have to set this directive on the compile level for the whole project.
-
ERBSLAND_SHORT_NAMESPACE
Set this preprocessor directive to overwrite the name that is used for the shortcut for the
erbsland
namespace. You have to set this directive on the compile level for the whole project.
-
ERBSLAND_QT_SHORT_NAMESPACE
Set this preprocessor directive to overwrite the name that is used for the shortcut for the
erbsland::qt
namespace. You have to set this directive on the compile level for the whole project.