Panda3D
|
00001 // Filename: win32ArgParser.h 00002 // Created by: drose (08Nov11) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef WIN32ARGPARSER_H 00016 #define WIN32ARGPARSER_H 00017 00018 #include "dtoolbase.h" 00019 00020 #ifdef _WIN32 00021 00022 #include "vector_string.h" 00023 #include "pvector.h" 00024 00025 #include <assert.h> 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : Win32ArgParser 00029 // Description : This class is used to parse the single command-line 00030 // string provided by Windows into the standard argc, 00031 // argv array of strings. In this way it duplicates the 00032 // functionality of Windows' own CommandLineToArgv() 00033 // function, but it is also supports automatic expansion 00034 // of glob filenames, e.g. *.egg is turned into an 00035 // explicit list of egg files in the directory. 00036 //////////////////////////////////////////////////////////////////// 00037 class EXPCL_DTOOL Win32ArgParser { 00038 public: 00039 Win32ArgParser(); 00040 ~Win32ArgParser(); 00041 00042 void clear(); 00043 00044 void set_command_line(const string &command_line); 00045 void set_command_line(const wstring &command_line); 00046 void set_system_command_line(); 00047 00048 char **get_argv(); 00049 int get_argc(); 00050 00051 static bool do_glob(); 00052 00053 private: 00054 string parse_quoted_arg(const char *&p); 00055 void parse_unquoted_arg(const char *&p); 00056 void save_arg(const string &arg); 00057 00058 typedef vector_string Args; 00059 Args _args; 00060 00061 char **_argv; 00062 int _argc; 00063 }; 00064 00065 #endif // _WIN32 00066 00067 #endif