home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / system / cmdline.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  2.2 KB  |  70 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    System library component
  3. //    Copyright (C) 1998-2005 Avery Lee, All Rights Reserved.
  4. //
  5. //    Beginning with 1.6.0, the VirtualDub system library is licensed
  6. //    differently than the remainder of VirtualDub.  This particular file is
  7. //    thus licensed as follows (the "zlib" license):
  8. //
  9. //    This software is provided 'as-is', without any express or implied
  10. //    warranty.  In no event will the authors be held liable for any
  11. //    damages arising from the use of this software.
  12. //
  13. //    Permission is granted to anyone to use this software for any purpose,
  14. //    including commercial applications, and to alter it and redistribute it
  15. //    freely, subject to the following restrictions:
  16. //
  17. //    1.    The origin of this software must not be misrepresented; you must
  18. //        not claim that you wrote the original software. If you use this
  19. //        software in a product, an acknowledgment in the product
  20. //        documentation would be appreciated but is not required.
  21. //    2.    Altered source versions must be plainly marked as such, and must
  22. //        not be misrepresented as being the original software.
  23. //    3.    This notice may not be removed or altered from any source
  24. //        distribution.
  25.  
  26. #ifndef f_VD2_SYSTEM_CMDLINE_H
  27. #define f_VD2_SYSTEM_CMDLINE_H
  28.  
  29. #include <vd2/system/vdstl.h>
  30.  
  31. class VDCommandLineIterator {
  32.     friend class VDCommandLine;
  33. public:
  34.     VDCommandLineIterator() : mIndex(1) {}
  35.  
  36. private:
  37.     int mIndex;
  38. };
  39.  
  40. class VDCommandLine {
  41. public:
  42.     VDCommandLine();
  43.     VDCommandLine(const wchar_t *s);
  44.     ~VDCommandLine();
  45.  
  46.     void Init(const wchar_t *s);
  47.  
  48.     uint32 GetCount() const;
  49.     const wchar_t *operator[](int index) const;
  50.  
  51.     bool GetNextArgument(VDCommandLineIterator& index, const wchar_t *& token, bool& isSwitch) const;
  52.     bool GetNextNonSwitchArgument(VDCommandLineIterator& index, const wchar_t *& token) const;
  53.     bool GetNextSwitchArgument(VDCommandLineIterator& index, const wchar_t *& token) const;
  54.     bool FindAndRemoveSwitch(const wchar_t *name);
  55.     bool FindAndRemoveSwitch(const wchar_t *name, const wchar_t *& token);
  56.  
  57. protected:
  58.     vdfastvector<wchar_t>    mLine;
  59.  
  60.     struct Token {
  61.         int mTokenIndex;
  62.         bool mbIsSwitch;
  63.         bool mbQuoted;
  64.     };
  65.  
  66.     vdfastvector<Token>    mTokens;
  67. };
  68.  
  69. #endif
  70.