Sdk/Application: Add command-line arguments handling

Former-commit-id: 40feef03dfa4e0537490689cc1af8f68131007c7 [formerly ea93fa9625bce277d27cb1747ee34ee884fdfc28] [formerly 721b1b3400e2e6aed984b37f61cd54986e5c0e2e [formerly 50614ac42a3d1a2564e4c38d9c7c0675e44b2fb8]]
Former-commit-id: d64cc60dbd82cffc23e081f270d0e173b9e2a6a5 [formerly a9ff7af1ab1ebbd1687d120a8e8e036e6c6926b5]
Former-commit-id: 45f34e16b8d6a91d407df30c36e598ff3270e50f
This commit is contained in:
Lynix
2016-08-28 21:47:29 +02:00
parent ab69578e72
commit 517b2bbaaf
5 changed files with 132 additions and 28 deletions

View File

@@ -33,22 +33,6 @@ namespace Ndk
Sdk::Initialize();
}
/*!
* \brief Constructs an Application object with command-line arguments
*
* Pass the argc and argv arguments from the main function.
*
* Command-line arguments can be retrieved by application methods
*
* This calls Sdk::Initialize()
*
* \remark Only one Application instance can exist at a time
*/
inline Application::Application(int argc, const char* argv[]) :
Application()
{
}
/*!
* \brief Destructs the application object
*
@@ -233,6 +217,30 @@ namespace Ndk
}
#endif
/*!
* \brief Gets the options used to start the application
*
* Options are defined as "-optionName" in command-line and are always lower-case
*
* \return Command-line options
*/
inline const std::set<Nz::String>& Application::GetOptions() const
{
return m_options;
}
/*!
* \brief Gets the parameters used to start the application
*
* Parameters are defined as "-key=value" in command-line, their key is lower-case but value capitals are kept.
*
* \return Command-line parameters
*/
inline const std::map<Nz::String, Nz::String>& Application::GetParameters() const
{
return m_parameters;
}
/*!
* \brief Gets the update time of the application
* \return Update rate
@@ -242,6 +250,46 @@ namespace Ndk
return m_updateTime;
}
/*!
* \brief Query for a command-line option
*
* \param option Option name
*
* \remark option must be lower-case
*
* \return True if option is present
*
* \see GetOptions
*/
inline bool Application::HasOption(const Nz::String& option) const
{
return m_options.count(option) != 0;
}
/*!
* \brief Query for a command-line option
*
* \param key Parameter name
* \param value Optional string to receive the parameter value
*
* \remark key must be lower-case
*
* \return True if parameter is present
*
* \see GetParameters
*/
inline bool Application::HasParameter(const Nz::String& key, Nz::String* value) const
{
auto it = m_parameters.find(key);
if (it == m_parameters.end())
return false;
if (value)
*value = it->second;
return true;
}
/*!
* \brief Checks if the console overlay is enabled
*