Lolly 1.4.28
Loading...
Searching...
No Matches
args.cpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : args.cpp
4 * DESCRIPTION: lolly::system::args like nowide::args
5 * COPYRIGHT : (C) 2024 Darcy Shen
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#include "args.hpp"
14#include "string.hpp"
15
16#if defined(OS_WIN) || defined(OS_MINGW)
17#include <windows.h>
18#endif
19#include <stdio.h>
20#if defined(OS_WIN) || defined(OS_MINGW)
21#include <shellapi.h>
22#endif
23
24#if defined(OS_MINGW) || defined(OS_WIN)
25using lolly::data::wchar_to_utf8;
26#endif
27
28namespace lolly {
29namespace system {
30#if defined(OS_WIN) || defined(OS_MINGW)
31void
32args::fix_args (int& argc, char**& argv) {
33 int wargc;
35 if (!wargv) {
36 argc = 0;
37 static char* dummy= 0;
38 argv = &dummy;
39 return;
40 }
41 try {
42 args_.resize (wargc + 1, 0);
43 arg_values_.resize (wargc);
44 for (int i= 0; i < wargc; i++) {
45 arg_values_[i]= wchar_to_utf8 (wargv[i]);
46 args_[i] = as_charp (arg_values_[i]);
47 }
48 argc= wargc;
49 argv= &args_[0];
50 } catch (...) {
52 throw;
53 }
55}
56#endif
57
58} // namespace system
59} // namespace lolly
The list class represents a linked list.
Definition list.hpp:48
char * as_charp(string s)
Definition string.cpp:256