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.cs153
1 files changed, 0 insertions, 153 deletions
diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs
deleted file mode 100644
index 22752aa..0000000
--- a/Prebuild/src/Core/Utilities/CommandLineCollection.cs
+++ /dev/null
@@ -1,153 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
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
12 distribution.
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.
15
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
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
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
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.Collections;
28using System.Collections.Specialized;
29using System.Diagnostics;
30
31namespace Prebuild.Core.Utilities
32{
33 /// <summary>
34 /// The CommandLine class parses and interprets the command-line arguments passed to
35 /// prebuild.
36 /// </summary>
37 public class CommandLineCollection
38 {
39 #region Fields
40
41 // The raw OS arguments
42 private string[] m_RawArgs;
43
44 // Command-line argument storage
45 private Hashtable m_Arguments;
46
47 #endregion
48
49 #region Constructors
50
51 /// <summary>
52 /// Create a new CommandLine instance and set some internal variables.
53 /// </summary>
54 public CommandLineCollection(string[] args)
55 {
56 m_RawArgs = args;
57 m_Arguments = new Hashtable();
58
59 Parse();
60 }
61
62 #endregion
63
64 #region Private Methods
65
66 private void Parse()
67 {
68 if(m_RawArgs.Length < 1)
69 return;
70
71 int idx = 0;
72 string arg = null, lastArg = null;
73
74 while(idx <m_RawArgs.Length)
75 {
76 arg = m_RawArgs[idx];
77
78 if(arg.Length > 2 && arg[0] == '/')
79 {
80 arg = arg.Substring(1);
81 lastArg = arg;
82 m_Arguments[arg] = "";
83 }
84 else
85 {
86 if(lastArg != null)
87 {
88 m_Arguments[lastArg] = arg;
89 lastArg = null;
90 }
91 }
92
93 idx++;
94 }
95 }
96
97 #endregion
98
99 #region Public Methods
100
101 /// <summary>
102 /// Wases the passed.
103 /// </summary>
104 /// <param name="arg">The arg.</param>
105 /// <returns></returns>
106 public bool WasPassed(string arg)
107 {
108 return (m_Arguments.ContainsKey(arg));
109 }
110
111 #endregion
112
113 #region Properties
114
115 /// <summary>
116 /// Gets the parameter associated with the command line option
117 /// </summary>
118 /// <remarks>Returns null if option was not specified,
119 /// null string if no parameter was specified, and the value if a parameter was specified</remarks>
120 public string this[string index]
121 {
122 get
123 {
124 if(m_Arguments.ContainsKey(index))
125 {
126 return (string)(m_Arguments[index]);
127 }
128 else
129 {
130 return null;
131 }
132 }
133 }
134
135 #endregion
136
137 #region IEnumerable Members
138
139 /// <summary>
140 /// Returns an enumerator that can iterate through a collection.
141 /// </summary>
142 /// <returns>
143 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/>
144 /// that can be used to iterate through the collection.
145 /// </returns>
146 public IDictionaryEnumerator GetEnumerator()
147 {
148 return m_Arguments.GetEnumerator();
149 }
150
151 #endregion
152 }
153}