aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base152
1 files changed, 0 insertions, 152 deletions
diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base
deleted file mode 100644
index 786fa1e..0000000
--- a/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base
+++ /dev/null
@@ -1,152 +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.Collections;
27using System.Collections.Generic;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 /// The CommandLine class parses and interprets the command-line arguments passed to
33 /// prebuild.
34 /// </summary>
35 public class CommandLineCollection : IEnumerable<KeyValuePair<string, string>>
36 {
37 #region Fields
38
39 // The raw OS arguments
40 private readonly string[] m_RawArgs;
41
42 // Command-line argument storage
43 private readonly Dictionary<string, string> m_Arguments = new Dictionary<string, string>();
44
45 #endregion
46
47 #region Constructors
48
49 /// <summary>
50 /// Create a new CommandLine instance and set some internal variables.
51 /// </summary>
52 public CommandLineCollection(string[] args)
53 {
54 m_RawArgs = args;
55
56 Parse();
57 }
58
59 #endregion
60
61 #region Private Methods
62
63 private void Parse()
64 {
65 if(m_RawArgs.Length < 1)
66 return;
67
68 int idx = 0;
69 string lastArg = null;
70
71 while(idx <m_RawArgs.Length)
72 {
73 string arg = m_RawArgs[idx];
74
75 if(arg.Length > 2 && arg[0] == '/')
76 {
77 arg = arg.Substring(1);
78 lastArg = arg;
79 m_Arguments[arg] = "";
80 }
81 else
82 {
83 if(lastArg != null)
84 {
85 m_Arguments[lastArg] = arg;
86 lastArg = null;
87 }
88 }
89
90 idx++;
91 }
92 }
93
94 #endregion
95
96 #region Public Methods
97
98 /// <summary>
99 /// Wases the passed.
100 /// </summary>
101 /// <param name="arg">The arg.</param>
102 /// <returns></returns>
103 public bool WasPassed(string arg)
104 {
105 return (m_Arguments.ContainsKey(arg));
106 }
107
108 #endregion
109
110 #region Properties
111
112 /// <summary>
113 /// Gets the parameter associated with the command line option
114 /// </summary>
115 /// <remarks>Returns null if option was not specified,
116 /// null string if no parameter was specified, and the value if a parameter was specified</remarks>
117 public string this[string index]
118 {
119 get
120 {
121 if(m_Arguments.ContainsKey(index))
122 {
123 return (m_Arguments[index]);
124 }
125 return null;
126 }
127 }
128
129 #endregion
130
131 #region IEnumerable Members
132
133 /// <summary>
134 /// Returns an enumerator that can iterate through a collection.
135 /// </summary>
136 /// <returns>
137 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/>
138 /// that can be used to iterate through the collection.
139 /// </returns>
140 public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
141 {
142 return m_Arguments.GetEnumerator();
143 }
144
145 IEnumerator IEnumerable.GetEnumerator()
146 {
147 return GetEnumerator();
148 }
149
150 #endregion
151 }
152}