SYNOPSIS
Gets the application wide argument parser set via either an
top
Gets the application wide argument parser set via either an
omni::application::run context or directly via omni::application::set_args. #include <omni/application.hpp>
omni::application::argparser& omni::application::args()
top
DESCRIPTION
If
top
If
omni::application::run or omni::application::set_args is called passing in the command line arguments from the main function, the reference returned has a copy of same arguments.
top
CONSIDERATIONS
The value returned is a direct reference to the underlying
top
The value returned is a direct reference to the underlying
argparser object, so any modifications done to the reference after it has be retrieved cannot be guaranteed to be thread safe.
top
EXAMPLE
top
#include <omni/application> void app_run() { // get a reference omni::application::argparser& args = omni::application::args(); for (int i = 0; i < args.size(); ++i) { std::cout << "args[" << i << "]: " << args[i] << std::endl; } // alternatively std::cout << "args = " << args << std::endl; std::cout << "Leaving, waiting for CTRL+C" << std::endl; } int main(int argc, const char* argv[]) { omni::application::set_args(argc, argv); return omni::application::run(&app_run); }Visit the examples page for more.
top