omni::application::args

SYNOPSIS

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 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

RETURN VALUES

A reference to the application wide omni::application::argparser

top

ERRORS

No errors specific to this context.

top

CONSIDERATIONS

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

PLATFORM SPECIFIC

Nothing platform specific to account for.

top

NOTES

No additional notes.

top

EXAMPLE
#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