Strukturanalyse im Parser ist komplett, Daten müssen nur noch gemapped werden
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
<Compile Include="src\Parser.cs" />
|
||||
<Compile Include="src\Backend.cs" />
|
||||
<Compile Include="src\StringUtils.cs" />
|
||||
<Compile Include="src\ParsingException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="src\DefaultGui\" />
|
||||
|
||||
@@ -43,7 +43,13 @@ namespace WorldOfPeacecraft
|
||||
// If package is not complete wait for more lines
|
||||
if (!IsCompletePackage())
|
||||
return;
|
||||
Block mainBlock = new Block(message, 0, message.Count - 1);
|
||||
MapData(mainBlock);
|
||||
}
|
||||
|
||||
public void MapData (Block block)
|
||||
{
|
||||
// TODO Implement
|
||||
}
|
||||
|
||||
public bool IsCompletePackage()
|
||||
@@ -74,12 +80,27 @@ namespace WorldOfPeacecraft
|
||||
public Block (String[] message, int start, int end)
|
||||
{
|
||||
int pos = start;
|
||||
Name = StringUtils.SubstringAfter(message[pos], ":");
|
||||
pos++;
|
||||
while (pos < end)
|
||||
{
|
||||
// Is the next element a block or a value?
|
||||
if (message[pos].StartsWith("begin:"))
|
||||
{
|
||||
// It's a block
|
||||
int blockstart = pos;
|
||||
int begins = 1;
|
||||
while (begins > 0)
|
||||
{
|
||||
pos++;
|
||||
if (pos >= end)
|
||||
throw new ParsingException("The message is missing end:-lines");
|
||||
if (message[pos].StartsWith("end:"))
|
||||
begins--;
|
||||
else if(message[pos].StartsWith("begin:"))
|
||||
begins++;
|
||||
}
|
||||
Blocks.Add(new Block(message, blockstart, pos));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
16
src/ParsingException.cs
Normal file
16
src/ParsingException.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace WorldOfPeacecraft
|
||||
{
|
||||
public class ParsingException : Exception
|
||||
{
|
||||
public ParsingException () : base();
|
||||
|
||||
public ParsingException (string message) : base(message);
|
||||
|
||||
public ParsingException (SerializationInfo info, StreamingContext context) : base(info, context);
|
||||
|
||||
public ParsingException (string message, Exception innerException) : base(message, innerException);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user