1 /* 2 ** m_argv.h 3 ** 4 **--------------------------------------------------------------------------- 5 ** Copyright 1998-2006 Randy Heit 6 ** All rights reserved. 7 ** 8 ** Redistribution and use in source and binary forms, with or without 9 ** modification, are permitted provided that the following conditions 10 ** are met: 11 ** 12 ** 1. Redistributions of source code must retain the above copyright 13 ** notice, this list of conditions and the following disclaimer. 14 ** 2. Redistributions in binary form must reproduce the above copyright 15 ** notice, this list of conditions and the following disclaimer in the 16 ** documentation and/or other materials provided with the distribution. 17 ** 3. The name of the author may not be used to endorse or promote products 18 ** derived from this software without specific prior written permission. 19 ** 20 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 **--------------------------------------------------------------------------- 31 ** 32 */ 33 34 #ifndef __M_ARGV_H__ 35 #define __M_ARGV_H__ 36 37 #include "dobject.h" 38 #include "zstring.h" 39 40 // 41 // MISC 42 // 43 class DArgs : public DObject 44 { 45 DECLARE_CLASS(DArgs, DObject) 46 public: 47 DArgs(); 48 DArgs(const DArgs &args); 49 DArgs(int argc, char **argv); 50 DArgs(int argc, FString *argv); 51 52 DArgs &operator=(const DArgs &other); 53 54 void AppendArg(FString arg); 55 void AppendArgs(int argc, const FString *argv); 56 void RemoveArg(int argindex); 57 void RemoveArgs(const char *check); 58 void SetArgs(int argc, char **argv); 59 void CollectFiles(const char *param, const char *extension); 60 DArgs *GatherFiles(const char *param) const; 61 void SetArg(int argnum, const char *arg); 62 63 int CheckParm(const char *check, int start=1) const; // Returns the position of the given parameter in the arg list (0 if not found). 64 int CheckParmList(const char *check, FString **strings, int start=1) const; 65 const char *CheckValue(const char *check) const; 66 const char *GetArg(int arg) const; 67 FString *GetArgList(int arg) const; 68 FString TakeValue(const char *check); 69 int NumArgs() const; 70 void FlushArgs(); 71 72 private: 73 TArray<FString> Argv; 74 }; 75 76 extern DArgs *Args; 77 78 #endif //__M_ARGV_H__ 79