aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Utilities/CommandLineCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Utilities/CommandLineCollection.cs')
-rw-r--r--Prebuild/src/Core/Utilities/CommandLineCollection.cs324
1 files changed, 162 insertions, 162 deletions
diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs
index 496731f..62eb18b 100644
--- a/Prebuild/src/Core/Utilities/CommandLineCollection.cs
+++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs
@@ -1,162 +1,162 @@
1#region BSD License 1#region BSD License
2/* 2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) 3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4 4
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided that the following conditions are met:
7 7
8* Redistributions of source code must retain the above copyright notice, this list of conditions 8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer. 9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions 10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the 11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution. 12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software 13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission. 14 without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/ 23*/
24#endregion 24#endregion
25 25
26#region CVS Information 26#region CVS Information
27/* 27/*
28 * $Source$ 28 * $Source$
29 * $Author: robloach $ 29 * $Author: robloach $
30 * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $ 30 * $Date: 2006-09-26 00:30:53 +0200 (ti, 26 sep 2006) $
31 * $Revision: 165 $ 31 * $Revision: 165 $
32 */ 32 */
33#endregion 33#endregion
34 34
35using System; 35using System;
36using System.Collections; 36using System.Collections;
37using System.Collections.Specialized; 37using System.Collections.Specialized;
38using System.Diagnostics; 38using System.Diagnostics;
39 39
40namespace Prebuild.Core.Utilities 40namespace Prebuild.Core.Utilities
41{ 41{
42 /// <summary> 42 /// <summary>
43 /// The CommandLine class parses and interprets the command-line arguments passed to 43 /// The CommandLine class parses and interprets the command-line arguments passed to
44 /// prebuild. 44 /// prebuild.
45 /// </summary> 45 /// </summary>
46 public class CommandLineCollection 46 public class CommandLineCollection
47 { 47 {
48 #region Fields 48 #region Fields
49 49
50 // The raw OS arguments 50 // The raw OS arguments
51 private string[] m_RawArgs; 51 private string[] m_RawArgs;
52 52
53 // Command-line argument storage 53 // Command-line argument storage
54 private Hashtable m_Arguments; 54 private Hashtable m_Arguments;
55 55
56 #endregion 56 #endregion
57 57
58 #region Constructors 58 #region Constructors
59 59
60 /// <summary> 60 /// <summary>
61 /// Create a new CommandLine instance and set some internal variables. 61 /// Create a new CommandLine instance and set some internal variables.
62 /// </summary> 62 /// </summary>
63 public CommandLineCollection(string[] args) 63 public CommandLineCollection(string[] args)
64 { 64 {
65 m_RawArgs = args; 65 m_RawArgs = args;
66 m_Arguments = new Hashtable(); 66 m_Arguments = new Hashtable();
67 67
68 Parse(); 68 Parse();
69 } 69 }
70 70
71 #endregion 71 #endregion
72 72
73 #region Private Methods 73 #region Private Methods
74 74
75 private void Parse() 75 private void Parse()
76 { 76 {
77 if(m_RawArgs.Length < 1) 77 if(m_RawArgs.Length < 1)
78 return; 78 return;
79 79
80 int idx = 0; 80 int idx = 0;
81 string arg = null, lastArg = null; 81 string arg = null, lastArg = null;
82 82
83 while(idx <m_RawArgs.Length) 83 while(idx <m_RawArgs.Length)
84 { 84 {
85 arg = m_RawArgs[idx]; 85 arg = m_RawArgs[idx];
86 86
87 if(arg.Length > 2 && arg[0] == '/') 87 if(arg.Length > 2 && arg[0] == '/')
88 { 88 {
89 arg = arg.Substring(1); 89 arg = arg.Substring(1);
90 lastArg = arg; 90 lastArg = arg;
91 m_Arguments[arg] = ""; 91 m_Arguments[arg] = "";
92 } 92 }
93 else 93 else
94 { 94 {
95 if(lastArg != null) 95 if(lastArg != null)
96 { 96 {
97 m_Arguments[lastArg] = arg; 97 m_Arguments[lastArg] = arg;
98 lastArg = null; 98 lastArg = null;
99 } 99 }
100 } 100 }
101 101
102 idx++; 102 idx++;
103 } 103 }
104 } 104 }
105 105
106 #endregion 106 #endregion
107 107
108 #region Public Methods 108 #region Public Methods
109 109
110 /// <summary> 110 /// <summary>
111 /// Wases the passed. 111 /// Wases the passed.
112 /// </summary> 112 /// </summary>
113 /// <param name="arg">The arg.</param> 113 /// <param name="arg">The arg.</param>
114 /// <returns></returns> 114 /// <returns></returns>
115 public bool WasPassed(string arg) 115 public bool WasPassed(string arg)
116 { 116 {
117 return (m_Arguments.ContainsKey(arg)); 117 return (m_Arguments.ContainsKey(arg));
118 } 118 }
119 119
120 #endregion 120 #endregion
121 121
122 #region Properties 122 #region Properties
123 123
124 /// <summary> 124 /// <summary>
125 /// Gets the parameter associated with the command line option 125 /// Gets the parameter associated with the command line option
126 /// </summary> 126 /// </summary>
127 /// <remarks>Returns null if option was not specified, 127 /// <remarks>Returns null if option was not specified,
128 /// null string if no parameter was specified, and the value if a parameter was specified</remarks> 128 /// null string if no parameter was specified, and the value if a parameter was specified</remarks>
129 public string this[string index] 129 public string this[string index]
130 { 130 {
131 get 131 get
132 { 132 {
133 if(m_Arguments.ContainsKey(index)) 133 if(m_Arguments.ContainsKey(index))
134 { 134 {
135 return (string)(m_Arguments[index]); 135 return (string)(m_Arguments[index]);
136 } 136 }
137 else 137 else
138 { 138 {
139 return null; 139 return null;
140 } 140 }
141 } 141 }
142 } 142 }
143 143
144 #endregion 144 #endregion
145 145
146 #region IEnumerable Members 146 #region IEnumerable Members
147 147
148 /// <summary> 148 /// <summary>
149 /// Returns an enumerator that can iterate through a collection. 149 /// Returns an enumerator that can iterate through a collection.
150 /// </summary> 150 /// </summary>
151 /// <returns> 151 /// <returns>
152 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/> 152 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/>
153 /// that can be used to iterate through the collection. 153 /// that can be used to iterate through the collection.
154 /// </returns> 154 /// </returns>
155 public IDictionaryEnumerator GetEnumerator() 155 public IDictionaryEnumerator GetEnumerator()
156 { 156 {
157 return m_Arguments.GetEnumerator(); 157 return m_Arguments.GetEnumerator();
158 } 158 }
159 159
160 #endregion 160 #endregion
161 } 161 }
162} 162}