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