Boost.Nowide: boost::nowide::args Class Reference

Boost.Nowide

Classes | Public Member Functions | List of all members
boost::nowide::args Class Reference

`args` is a class that temporarily replaces standard main() function arguments with their equal, but UTF-8 encoded values under Microsoft Windows for the lifetime of the instance. More...

`#include <boost/nowide/args.hpp>`

## Public Member Functions
| args (int &argc, char **&argv)
| args (int &argc, char **&argv, char **&env)
| ~args ()

## Detailed Description

`args` is a class that temporarily replaces standard main() function arguments with their equal, but UTF-8 encoded values under Microsoft Windows for the lifetime of the instance.

The class uses `GetCommandLineW()`, `CommandLineToArgvW()` and `GetEnvironmentStringsW()` in order to obtain Unicode-encoded values. It does not relate to actual values of argc, argv and env under Windows.

It restores the original values in its destructor (usually at the end of the `main` function).

If any of the system calls fails, an exception of type std::runtime_error will be thrown and argc, argv, env remain unchanged.

Note
  The class owns the memory of the newly allocated strings. So you need to keep it alive as long as you use the values.

Usage:

int main(int argc, char** argv, char** env) {
boost::nowide::args _(argc, argv, env); // Note the _ as a "don't care" name for the instance
// Use argv and env as usual, they are now UTF-8 encoded on Windows
return 0; // Memory held by args is released
}
boost::nowide::args
args is a class that temporarily replaces standard main() function arguments with their equal,...
Definition: args.hpp:57

## Constructor & Destructor Documentation

## ◆ args() [1/2]

boost::nowide::args::args | ( | int & | argc,
|  | char **& | argv
| ) |  |
| inline

Fix command line arguments

## ◆ args() [2/2]

boost::nowide::args::args | ( | int & | argc,
|  | char **& | argv,
|  | char **& | env
| ) |  |
| inline

Fix command line arguments and environment

## ◆ ~args()

boost::nowide::args::~args | ( |  | ) |
| inline

Restore original argc, argv, env values, if changed

The documentation for this class was generated from the following file:

- boost/nowide/args.hpp