Panda3D
win32ArgParser.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file win32ArgParser.h
10  * @author drose
11  * @date 2011-11-08
12  */
13 
14 #ifndef WIN32ARGPARSER_H
15 #define WIN32ARGPARSER_H
16 
17 #include "dtoolbase.h"
18 
19 #ifdef _WIN32
20 
21 #include "vector_string.h"
22 #include "pvector.h"
23 
24 #include <assert.h>
25 
26 /**
27  * This class is used to parse the single command-line string provided by
28  * Windows into the standard argc, argv array of strings. In this way it
29  * duplicates the functionality of Windows' own CommandLineToArgv() function,
30  * but it is also supports automatic expansion of glob filenames, e.g. *.egg
31  * is turned into an explicit list of egg files in the directory.
32  */
33 class EXPCL_DTOOL_DTOOLUTIL Win32ArgParser {
34 public:
35  Win32ArgParser();
36  ~Win32ArgParser();
37 
38  void clear();
39 
40  void set_command_line(const std::string &command_line);
41  void set_command_line(const std::wstring &command_line);
42  void set_system_command_line();
43 
44  char **get_argv();
45  int get_argc();
46 
47  static bool do_glob();
48 
49 private:
50  std::string parse_quoted_arg(const char *&p);
51  void parse_unquoted_arg(const char *&p);
52  void save_arg(const std::string &arg);
53 
54  typedef vector_string Args;
55  Args _args;
56 
57  char **_argv;
58  int _argc;
59 };
60 
61 #endif // _WIN32
62 
63 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.