X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=CarFire%2FCarFire%2FCarFire%2FParse.cs;h=bb2e9c1115d6d10bfdde9ed296a34cb468bd4add;hb=3ca5852a7df47d4129743ed449816c7c7347b699;hp=b9320778babcbcdfb62d685aec9306ce2639d6c7;hpb=1393586d1e5639ac8f1e9fc8183644050dd54165;p=chaz%2Fcarfire
diff --git a/CarFire/CarFire/CarFire/Parse.cs b/CarFire/CarFire/CarFire/Parse.cs
index b932077..bb2e9c1 100644
--- a/CarFire/CarFire/CarFire/Parse.cs
+++ b/CarFire/CarFire/CarFire/Parse.cs
@@ -9,7 +9,8 @@ namespace CarFire
{
///
/// Class with handy static methods taking strings and returning objects
- /// parsed from those strings.
+ /// parsed from those strings. For all of these functions, white space is
+ /// generally ignored, but superfluous characters are not allowed.
///
public class Parse
{
@@ -29,7 +30,7 @@ namespace CarFire
/// Parses a comment of an INI file.
///
/// Text.
- /// The comment.
+ /// The comment, or null if parsing failed.
public static string IniComment(string line)
{
Match match = Regex.Match(line, @"^;\s*(.*)\s*$");
@@ -108,6 +109,18 @@ namespace CarFire
return null;
}
+ ///
+ /// Parses a single character.
+ ///
+ /// Text.
+ /// The character, or null if parsing failed.
+ public static char? Char(string atom)
+ {
+ string str = String(atom);
+ if (str != null && str.Length == 1) return str[0];
+ return null;
+ }
+
///
/// Parses a constant from an enum.
///
@@ -118,7 +131,7 @@ namespace CarFire
{
try
{
- return (T)System.Enum.Parse(typeof(T), String(atom), true);
+ return (T)System.Enum.Parse(typeof(T), String(atom));
}
#pragma warning disable 0168
catch (System.Exception ex)