8 #ifndef BOOST_NOWIDE_ARGS_HPP_INCLUDED 9 #define BOOST_NOWIDE_ARGS_HPP_INCLUDED 11 #include <boost/config.hpp> 13 #include <boost/nowide/stackstring.hpp> 14 #include <boost/nowide/windows.hpp> 21 #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN) 27 args(
int&,
char**&,
char**&)
56 args(
int& argc,
char**& argv) :
57 old_argc_(argc), old_argv_(argv), old_env_(0), old_argc_ptr_(&argc), old_argv_ptr_(&argv), old_env_ptr_(0)
64 args(
int& argc,
char**& argv,
char**& env) :
65 old_argc_(argc), old_argv_(argv), old_env_(env), old_argc_ptr_(&argc), old_argv_ptr_(&argv),
77 *old_argc_ptr_ = old_argc_;
79 *old_argv_ptr_ = old_argv_;
81 *old_env_ptr_ = old_env_;
90 wargv_ptr(
const wargv_ptr&);
91 wargv_ptr& operator=(
const wargv_ptr&);
96 p = CommandLineToArgvW(GetCommandLineW(), &argc);
107 operator bool()
const 111 const wchar_t* operator[](
size_t i)
const 120 wenv_ptr(
const wenv_ptr&);
121 wenv_ptr& operator=(
const wenv_ptr&);
124 wenv_ptr() : p(GetEnvironmentStringsW())
129 FreeEnvironmentStringsW(p);
131 operator const wchar_t*()
const 137 void fix_args(
int& argc,
char**& argv)
139 const wargv_ptr wargv;
141 throw std::runtime_error(
"Could not get command line!");
142 args_.resize(wargv.size() + 1, 0);
143 arg_values_.resize(wargv.size());
144 for(
int i = 0; i < wargv.size(); i++)
145 args_[i] = arg_values_[i].convert(wargv[i]);
149 void fix_env(
char**& env)
151 const wenv_ptr wstrings;
153 throw std::runtime_error(
"Could not get environment strings!");
154 const wchar_t* wstrings_end = 0;
156 for(wstrings_end = wstrings; *wstrings_end; wstrings_end += wcslen(wstrings_end) + 1)
158 env_.
convert(wstrings, wstrings_end);
159 envp_.resize(count + 1, 0);
160 char* p = env_.
get();
162 for(
int i = 0; i < count; i++)
171 std::vector<char*> args_;
172 std::vector<short_stackstring> arg_values_;
174 std::vector<char*> envp_;
181 char*** old_argv_ptr_;
182 char*** old_env_ptr_;
args(int &argc, char **&argv, char **&env)
Definition: args.hpp:64
args is a class that fixes standard main() function arguments and changes them to UTF-8 under Microso...
Definition: args.hpp:50
basic_stackstring< char, wchar_t, 256 > stackstring
Definition: stackstring.hpp:198
args(int &argc, char **&argv)
Definition: args.hpp:56
output_char * convert(const input_char *input)
Definition: stackstring.hpp:91
output_char * get()
Return the converted, NULL-terminated string or NULL if no string was converted.
Definition: stackstring.hpp:126
~args()
Definition: args.hpp:74