Application Manual

Table of Contents

About

The maxon::Application class collects several static functions that give access to information on the application's environment and properties.

Application

These functions allow to access various paths as a maxon::Url:

// This example uses maxon::Application to create the URL for a new temporary file.
// Then a string is written into that file.
// create URL of temporary file
// make file
// output string
const maxon::String text { "hello world" };
const maxon::BaseArray<maxon::Char> textData = text.GetCString() iferr_return;
// write to file using stream
const maxon::OutputStreamRef stream = tempFile.OpenOutputStream(flags) iferr_return;
stream.Write(textData) iferr_return;
stream.Close() iferr_return;
// This example gets the location of the plugin's resource folder and prints all files in that folder.
// get the resource folder
// read all files in the resource folder
for (const auto& it : resourceFolder.GetBrowseIterator(maxon::GETBROWSEITERATORFLAGS::NONE))
{
const maxon::IoBrowseRef& browseDirectory = (it)iferr_return;
const maxon::Url url = browseDirectory.GetCurrentPath();
DiagnosticOutput("File: @", url);
}

These functions allow to access the command line arguments applied to the application when it was started:

// This example loops through the application's command line arguments.
for (maxon::Int i = 0; i < cnt; ++i)
{
DiagnosticOutput("Argument #@: @", i, arg);
}

maxon::Application::GetMachineInfo() returns a DataDictionary which stores information on the current machine. See maxon::MACHINEINFO for IDs; compare with Machines Manual.

// This example prints the current machine's name and OS to the console.
const maxon::DataDictionary machineInfo = maxon::Application::GetMachineInfo();
const maxon::String computerName = machineInfo.Get(maxon::MACHINEINFO::COMPUTERNAME) iferr_return;
const maxon::String osVersion = machineInfo.Get(maxon::MACHINEINFO::OSVERSION) iferr_return;
DiagnosticOutput("Machine @ is running @", computerName, osVersion);

maxon::Application::GetVersion() allows to access the version number and build ID of the application.

// This example prints the application version and build ID to the console.
maxon::Int version;
maxon::String buildID;
DiagnosticOutput("Application version @ (@)", version, buildID);

The application mode defines the behaviour after startup.

Further application features (maxon::APPLICATIONFEATURE) are accessed with:

Further Reading