Application Manual

内容表

关于

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

应用程序

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

const maxon::Url tempDir = maxon::Application::GetUrl ( maxon::APPLICATION_URLTYPE::TEMP_DIR ) iferr_return ; const maxon::Url tempFile = maxon::Application::GetTempUrl (tempDir) iferr_return ;

// 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 auto flags = maxon::OPENSTREAMFLAGS::WRITE_DONT_TRUNCATE | maxon::OPENSTREAMFLAGS::SEEK_TO_END ; 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 const maxon::Url resourceFolder = maxon::Application::GetUrl ( maxon::APPLICATION_URLTYPE::CURRENT_MODULE_RESOURCE_DIR ) iferr_return ;

// 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. const maxon::Int cnt = maxon::Application::GetCommandLineArgCount (); for ( maxon::Int i = 0; i < cnt; ++i) { const maxon::String arg = maxon::Application::GetCommandLineArg (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; maxon::Application::GetVersion (version, buildID) iferr_return ; DiagnosticOutput ( "Application version @ (@)" , version, buildID);

The application mode defines the behaviour after startup.

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

延伸阅读

maxon::Application::GetMachineInfo
static MAXON_METHOD DataDictionary GetMachineInfo()
maxon::OPENSTREAMFLAGS::SEEK_TO_END
@ SEEK_TO_END
Sets the file handle to the end of file after opening. To append to the end of a file use WRITE_DONT_...
maxon::String
定义: string.h:1197
maxon::Application::GetVersion
static MAXON_METHOD Result< void > GetVersion(Int &version, String &buildID)
maxon::APPLICATION_URLTYPE::CURRENT_MODULE_RESOURCE_DIR
@ CURRENT_MODULE_RESOURCE_DIR
Resource directory of the module that invoked this call.
iferr_return
#define iferr_return
定义: resultbase.h:1434
maxon::BaseArray
定义: basearray.h:366
maxon::Application::GetCommandLineArgCount
static MAXON_METHOD Int GetCommandLineArgCount()
maxon::Application::GetTempUrl
static MAXON_METHOD Result< Url > GetTempUrl(const Url &directory)
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
maxon::Url
定义: url.h:819
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
maxon::Application::GetUrl
static MAXON_FUNCTION Result< Url > GetUrl(APPLICATION_URLTYPE urlType)
maxon::GETBROWSEITERATORFLAGS::NONE
@ NONE
No flags specified.
maxon::OPENSTREAMFLAGS::WRITE_DONT_TRUNCATE
@ WRITE_DONT_TRUNCATE
Allows to write to existing files without truncation, so the existing file is kept as is.
maxon::Application::GetCommandLineArg
static MAXON_METHOD String GetCommandLineArg(Int idx)
maxon::APPLICATION_URLTYPE::TEMP_DIR
@ TEMP_DIR

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1