Visual Studio 2012 Support
[xy_vsfilter.git] / src / thirdparty / VirtualDub / h / vd2 / system / cmdline.h
blobf4f217dd54b0b888b96de2a9d7825c58b97b5d2b
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.
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:
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.
26 #ifndef f_VD2_SYSTEM_CMDLINE_H
27 #define f_VD2_SYSTEM_CMDLINE_H
29 #include <vd2/system/vdstl.h>
31 class VDStringSpanW;
33 class VDCommandLineIterator {
34 friend class VDCommandLine;
35 public:
36 VDCommandLineIterator() : mIndex(1) {}
38 private:
39 int mIndex;
42 class VDCommandLine {
43 public:
44 VDCommandLine();
45 VDCommandLine(const wchar_t *s);
46 ~VDCommandLine();
48 void Init(const wchar_t *s);
50 // This splits the cmdline using rules that are closer to Visual C++'s:
51 // - 2N+1 backslashes followed by a quote inserts a literal quote.
52 // - 2N backslashes followed by a quote toggles the quote state.
53 // - Outside of a quote, spaces, tabs, and forward slashes delimit parameters.
55 // We still have special switch processing:
56 // - A parameter starting with a forward slash followed by a ? or an alphanumeric
57 // char is a switch. A switch is terminated by a non-alphanumeric character or
58 // a colon.
59 void InitAlt(const wchar_t *s);
61 uint32 GetCount() const;
62 const wchar_t *operator[](int index) const;
63 const VDStringSpanW operator()(int index) const;
65 bool GetNextArgument(VDCommandLineIterator& index, const wchar_t *& token, bool& isSwitch) const;
66 bool GetNextNonSwitchArgument(VDCommandLineIterator& index, const wchar_t *& token) const;
67 bool GetNextSwitchArgument(VDCommandLineIterator& index, const wchar_t *& token) const;
68 bool FindAndRemoveSwitch(const wchar_t *name);
69 bool FindAndRemoveSwitch(const wchar_t *name, const wchar_t *& token);
71 protected:
72 void RemoveArgument(int index);
74 vdfastvector<wchar_t> mLine;
76 struct Token {
77 int mTokenIndex;
78 bool mbIsSwitch;
81 vdfastvector<Token> mTokens;
84 #endif