From 9d8c527211edd2bc74fa548f30f69f8d21868fef Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 15 Feb 2007 14:28:12 +0000 Subject: Parsing des argument ligne de commandes --- getopt/Arg.cs | 15 +++++ getopt/GetOpt.cs | 98 +++++++++++++++++++++++++++++++ getopt/bin/Debug/getopt.dll | Bin 0 -> 16384 bytes getopt/bin/Debug/getopt.pdb | Bin 0 -> 13824 bytes getopt/bin/Release/getopt.dll | Bin 0 -> 16384 bytes getopt/getopt.csproj | 106 ++++++++++++++++++++++++++++++++++ getopt/getopt.csproj.user | 58 +++++++++++++++++++ getopt/getopt.csproj.vspscc | 10 ++++ getopt/getopt.sln | 19 ++++++ getopt/getopt.suo | Bin 0 -> 14336 bytes getopt/mssccprj.scc | 5 ++ getopt/obj/Debug/Refactor/getopt.dll | Bin 0 -> 16384 bytes getopt/obj/Debug/getopt.dll | Bin 0 -> 16384 bytes getopt/obj/Debug/getopt.pdb | Bin 0 -> 13824 bytes getopt/obj/Release/getopt.dll | Bin 0 -> 16384 bytes getopt/obj/getopt.csproj.FileList.txt | 8 +++ getopt/vssver2.scc | Bin 0 -> 164 bytes 17 files changed, 319 insertions(+) create mode 100644 getopt/Arg.cs create mode 100644 getopt/GetOpt.cs create mode 100644 getopt/bin/Debug/getopt.dll create mode 100644 getopt/bin/Debug/getopt.pdb create mode 100644 getopt/bin/Release/getopt.dll create mode 100644 getopt/getopt.csproj create mode 100644 getopt/getopt.csproj.user create mode 100644 getopt/getopt.csproj.vspscc create mode 100644 getopt/getopt.sln create mode 100644 getopt/getopt.suo create mode 100644 getopt/mssccprj.scc create mode 100644 getopt/obj/Debug/Refactor/getopt.dll create mode 100644 getopt/obj/Debug/getopt.dll create mode 100644 getopt/obj/Debug/getopt.pdb create mode 100644 getopt/obj/Release/getopt.dll create mode 100644 getopt/obj/getopt.csproj.FileList.txt create mode 100644 getopt/vssver2.scc (limited to 'getopt') diff --git a/getopt/Arg.cs b/getopt/Arg.cs new file mode 100644 index 0000000..0b86cad --- /dev/null +++ b/getopt/Arg.cs @@ -0,0 +1,15 @@ +using System; + +namespace Gnu +{ + /// + /// An argument for GetOpt + /// + public class Arg + { + public char Flag; + public bool TakesParameter = false; + + public string Parameter = ""; + } +} diff --git a/getopt/GetOpt.cs b/getopt/GetOpt.cs new file mode 100644 index 0000000..a158073 --- /dev/null +++ b/getopt/GetOpt.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Specialized; +using System.Collections.Generic; + +namespace Gnu +{ + /// + /// An implementation of the getopt standard, as used by Gnu GetOpt + /// + public class GetOpt + { + StringCollection m_params = new StringCollection(); + StringCollection m_extras = new StringCollection(); + List m_args = new List(); + + public GetOpt(string[] CommandLineArgs, string ParametersDescription) + { + // Import the string array into the collection + foreach(string s in CommandLineArgs) + { + m_params.Add(s); + } + + // Parse the params description + for(int i = 0; i < ParametersDescription.Length; i++) + { + Arg a = new Arg(); + a.Flag = ParametersDescription[i]; + if((ParametersDescription.Length > i + 1) && (ParametersDescription[i + 1] == ':')) + { + a.TakesParameter = true; + i++; + } + + m_args.Add(a); + } + } + + public Arg NextArg() + { + SnarfExtras(); + + if(m_params.Count == 0) + return null; + + foreach(Arg a in m_args) + { + if(a.Flag == m_params[0][1] && m_params[0][0] == '-' ) + { + Arg matched = a; + try + { + if(a.TakesParameter) + { + matched.Parameter = m_params[1]; + m_params.RemoveAt(1); + } + } + catch(Exception) + { + } + + m_params.RemoveAt(0); + return matched; + } + } + + if(m_params[0][0] == '-') + { + Arg tempa = new Arg(); + tempa.Flag = m_params[0][1]; + tempa.TakesParameter = false; + return tempa; + } + return null; + } + + public StringCollection Extras + { + get + { + SnarfExtras(); + + return m_extras; + } + } + + private void SnarfExtras() + { + // Parameters must start with a hyphen + while((m_params.Count > 0) && (m_params[0][0] != '-')) + { + m_extras.Add(m_params[0]); + m_params.RemoveAt(0); + } + } + } +} diff --git a/getopt/bin/Debug/getopt.dll b/getopt/bin/Debug/getopt.dll new file mode 100644 index 0000000..d928e54 Binary files /dev/null and b/getopt/bin/Debug/getopt.dll differ diff --git a/getopt/bin/Debug/getopt.pdb b/getopt/bin/Debug/getopt.pdb new file mode 100644 index 0000000..7b5eb2b Binary files /dev/null and b/getopt/bin/Debug/getopt.pdb differ diff --git a/getopt/bin/Release/getopt.dll b/getopt/bin/Release/getopt.dll new file mode 100644 index 0000000..2dfdc9d Binary files /dev/null and b/getopt/bin/Release/getopt.dll differ diff --git a/getopt/getopt.csproj b/getopt/getopt.csproj new file mode 100644 index 0000000..3cca427 --- /dev/null +++ b/getopt/getopt.csproj @@ -0,0 +1,106 @@ + + + Local + 8.0.50727 + 2.0 + {228B5F0B-31AE-488F-A916-B7CBB269D25F} + Debug + AnyCPU + + + + + getopt + + + JScript + Grid + IE50 + false + Library + getopt + OnBuildSuccess + + + + + + + SAK + SAK + SAK + SAK + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/getopt/getopt.csproj.user b/getopt/getopt.csproj.user new file mode 100644 index 0000000..cfcf828 --- /dev/null +++ b/getopt/getopt.csproj.user @@ -0,0 +1,58 @@ + + + 7.10.3077 + Debug + AnyCPU + + + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + false + + \ No newline at end of file diff --git a/getopt/getopt.csproj.vspscc b/getopt/getopt.csproj.vspscc new file mode 100644 index 0000000..feffdec --- /dev/null +++ b/getopt/getopt.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/getopt/getopt.sln b/getopt/getopt.sln new file mode 100644 index 0000000..3dab7ec --- /dev/null +++ b/getopt/getopt.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "getopt", "getopt.csproj", "{228B5F0B-31AE-488F-A916-B7CBB269D25F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {228B5F0B-31AE-488F-A916-B7CBB269D25F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {228B5F0B-31AE-488F-A916-B7CBB269D25F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {228B5F0B-31AE-488F-A916-B7CBB269D25F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {228B5F0B-31AE-488F-A916-B7CBB269D25F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/getopt/getopt.suo b/getopt/getopt.suo new file mode 100644 index 0000000..fc0301d Binary files /dev/null and b/getopt/getopt.suo differ diff --git a/getopt/mssccprj.scc b/getopt/mssccprj.scc new file mode 100644 index 0000000..2aeb91c --- /dev/null +++ b/getopt/mssccprj.scc @@ -0,0 +1,5 @@ +SCC = This is a Source Code Control file + +[getopt.csproj] +SCC_Aux_Path = "C:\Users\fcolin\Documents\Visual Source Safe" +SCC_Project_Name = "$/CSharp/getopt", RBIAAAAA diff --git a/getopt/obj/Debug/Refactor/getopt.dll b/getopt/obj/Debug/Refactor/getopt.dll new file mode 100644 index 0000000..41e8a7f Binary files /dev/null and b/getopt/obj/Debug/Refactor/getopt.dll differ diff --git a/getopt/obj/Debug/getopt.dll b/getopt/obj/Debug/getopt.dll new file mode 100644 index 0000000..d928e54 Binary files /dev/null and b/getopt/obj/Debug/getopt.dll differ diff --git a/getopt/obj/Debug/getopt.pdb b/getopt/obj/Debug/getopt.pdb new file mode 100644 index 0000000..7b5eb2b Binary files /dev/null and b/getopt/obj/Debug/getopt.pdb differ diff --git a/getopt/obj/Release/getopt.dll b/getopt/obj/Release/getopt.dll new file mode 100644 index 0000000..2dfdc9d Binary files /dev/null and b/getopt/obj/Release/getopt.dll differ diff --git a/getopt/obj/getopt.csproj.FileList.txt b/getopt/obj/getopt.csproj.FileList.txt new file mode 100644 index 0000000..875bb18 --- /dev/null +++ b/getopt/obj/getopt.csproj.FileList.txt @@ -0,0 +1,8 @@ +bin\Debug\getopt.dll +bin\Debug\getopt.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\getopt.dll +obj\Debug\getopt.pdb +bin\Release\getopt.dll +obj\Release\ResolveAssemblyReference.cache +obj\Release\getopt.dll diff --git a/getopt/vssver2.scc b/getopt/vssver2.scc new file mode 100644 index 0000000..44d6a95 Binary files /dev/null and b/getopt/vssver2.scc differ -- cgit v1.1