diff --git a/inf3.csproj b/inf3.csproj
index e0326c1..0e64768 100644
--- a/inf3.csproj
+++ b/inf3.csproj
@@ -54,6 +54,7 @@
+
diff --git a/src/Parser.cs b/src/Parser.cs
index e69536b..954de14 100644
--- a/src/Parser.cs
+++ b/src/Parser.cs
@@ -10,7 +10,7 @@ namespace WorldOfPeacecraft
private Queue Buffer = new Queue ();
private AutoResetEvent BufferFilledEvent = new AutoResetEvent (false);
private Thread ParserThread;
- private List message;
+ private LinkedList message;
private Regex LastLineRegex;
public Parser ()
@@ -33,7 +33,7 @@ namespace WorldOfPeacecraft
if (waitRequired)
BufferFilledEvent.WaitOne ();
lock (Buffer) {
- message.Add (Buffer.Dequeue ());
+ message.AddLast (Buffer.Dequeue ());
}
}
}
@@ -43,7 +43,7 @@ namespace WorldOfPeacecraft
// If package is not complete wait for more lines
if (!IsCompletePackage())
return;
- // TODO Implement
+
}
public bool IsCompletePackage()
@@ -64,6 +64,33 @@ namespace WorldOfPeacecraft
BufferFilledEvent.Set ();
}
}
+
+ private class Block
+ {
+ private string Name;
+ private ISet Blocks = new HashSet();
+ private Dictionary Values = new Dictionary();
+
+ public Block (String[] message, int start, int end)
+ {
+ int pos = start;
+ while (pos < end)
+ {
+ // Is the next element a block or a value?
+ if (message[pos].StartsWith("begin:"))
+ {
+ // It's a block
+ }
+ else
+ {
+ string name = StringUtils.SubstringBefore(message[pos], ":");
+ string val = StringUtils.SubstringAfter(message[pos], ":");
+ Values[name] = val;
+ pos++;
+ }
+ }
+ }
+ }
}
}
diff --git a/src/StringUtils.cs b/src/StringUtils.cs
new file mode 100644
index 0000000..1eac5c1
--- /dev/null
+++ b/src/StringUtils.cs
@@ -0,0 +1,19 @@
+namespace WorldOfPeacecraft
+{
+ public class StringUtils
+ {
+ public static string SubstringBefore(string str, string separator)
+ {
+ if (str == null)
+ return null;
+ return str.Substring(0, str.IndexOf(separator));
+ }
+
+ public static string SubstringAfter(string str, string separator)
+ {
+ if (str == null)
+ return null;
+ return str.Substring(str.IndexOf(separator) + 1);
+ }
+ }
+}