So, behold - Map.NET...
Early days yet, but it is going a lot better than the last attempt.
I can't quite work out whether I love or hate C#. It is definately one or the other.
This application needs to be able to parse text files that can contain quoted strings. I've managed to bodge together a file parser class that can handle this, but since it appears that StreamReader does not have the equivalent to a std::istream::putback function, I'm having to Peek() every character before I Read() it, which seems a bit strange:
using System;using System.IO;using System.Text;class FileParser{ private StreamReader Sr=null; public FileParser(string Path) { try { Sr=new StreamReader(Path); } catch(Exception) { Sr=null; } } public bool Failed { get { return Sr==null; } } public bool Next(out String Token) { StringBuilder S=new StringBuilder(); Int32 C=Sr.Peek(); while(C!=-1 && Char.IsWhiteSpace(Convert.ToChar(C))){ Sr.Read(); C=Sr.Peek(); } if(C==-1){ Token=""; return false; } if(C=='\"') { Sr.Read(); C=Sr.Peek(); while(C!=-1 && C!='\n' && C!='\"') { S.Append(Convert.ToChar(C)); Sr.Read(); C=Sr.Peek(); } Sr.Read(); Token=S.ToString(); return true; } while(C!=-1 && C!='\"' && C!=':' && !Char.IsWhiteSpace(Convert.ToChar(C))){ S.Append(Convert.ToChar(C)); Sr.Read(); C=Sr.Peek(); } Token=S.ToString(); return true; } public void Dispose() { if(Sr!=null) Sr.Close(); }}
I welcome comments on the above, but be gentle since C# is all a bit new to me.