Getter für Block, Compilefehler entfernt
This commit is contained in:
@@ -20,7 +20,7 @@ namespace WorldOfPeacecraft
|
|||||||
LastLineRegex = new Regex ("^end:[0-9]+$");
|
LastLineRegex = new Regex ("^end:[0-9]+$");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RunParser ()
|
private void RunParser ()
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
bool waitRequired = false;
|
bool waitRequired = false;
|
||||||
@@ -38,7 +38,7 @@ namespace WorldOfPeacecraft
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Parse ()
|
private void Parse ()
|
||||||
{
|
{
|
||||||
// If package is not complete wait for more lines
|
// If package is not complete wait for more lines
|
||||||
if (!IsCompletePackage ())
|
if (!IsCompletePackage ())
|
||||||
@@ -47,12 +47,12 @@ namespace WorldOfPeacecraft
|
|||||||
MapData (mainBlock);
|
MapData (mainBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MapData (Block block)
|
private void MapData (Block block)
|
||||||
{
|
{
|
||||||
// TODO Implement
|
// TODO Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCompletePackage()
|
private bool IsCompletePackage ()
|
||||||
{
|
{
|
||||||
string lastLine = message.Last.Value;
|
string lastLine = message.Last.Value;
|
||||||
return LastLineRegex.IsMatch (lastLine);
|
return LastLineRegex.IsMatch (lastLine);
|
||||||
@@ -82,16 +82,13 @@ namespace WorldOfPeacecraft
|
|||||||
int pos = start;
|
int pos = start;
|
||||||
Name = StringUtils.SubstringAfter (message [pos], ":");
|
Name = StringUtils.SubstringAfter (message [pos], ":");
|
||||||
pos++;
|
pos++;
|
||||||
while (pos < end)
|
while (pos < end) {
|
||||||
{
|
|
||||||
// Is the next element a block or a value?
|
// Is the next element a block or a value?
|
||||||
if (message[pos].StartsWith("begin:"))
|
if (message [pos].StartsWith ("begin:")) {
|
||||||
{
|
|
||||||
// It's a block
|
// It's a block
|
||||||
int blockstart = pos;
|
int blockstart = pos;
|
||||||
int begins = 1;
|
int begins = 1;
|
||||||
while (begins > 0)
|
while (begins > 0) {
|
||||||
{
|
|
||||||
pos++;
|
pos++;
|
||||||
if (pos >= end)
|
if (pos >= end)
|
||||||
throw new ParsingException ("The message is missing end:-lines");
|
throw new ParsingException ("The message is missing end:-lines");
|
||||||
@@ -101,9 +98,7 @@ namespace WorldOfPeacecraft
|
|||||||
begins++;
|
begins++;
|
||||||
}
|
}
|
||||||
Blocks.Add (new Block (message, blockstart, pos));
|
Blocks.Add (new Block (message, blockstart, pos));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// It's a value
|
// It's a value
|
||||||
string name = StringUtils.SubstringBefore (message [pos], ":");
|
string name = StringUtils.SubstringBefore (message [pos], ":");
|
||||||
string val = StringUtils.SubstringAfter (message [pos], ":");
|
string val = StringUtils.SubstringAfter (message [pos], ":");
|
||||||
@@ -112,6 +107,31 @@ namespace WorldOfPeacecraft
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetName ()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISet<Block> GetBlocks ()
|
||||||
|
{
|
||||||
|
return Blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetStringValue (string name)
|
||||||
|
{
|
||||||
|
return Values [name];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetIntValue (string name)
|
||||||
|
{
|
||||||
|
return int.Parse (Values [name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long GetLongValue (string name)
|
||||||
|
{
|
||||||
|
return long.Parse (Values [name]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,20 @@ namespace WorldOfPeacecraft
|
|||||||
{
|
{
|
||||||
public class ParsingException : Exception
|
public class ParsingException : Exception
|
||||||
{
|
{
|
||||||
public ParsingException () : base();
|
public ParsingException () : base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public ParsingException (string message) : base(message);
|
public ParsingException (string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public ParsingException (SerializationInfo info, StreamingContext context) : base(info, context);
|
public ParsingException (SerializationInfo info, StreamingContext context) : base(info, context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public ParsingException (string message, Exception innerException) : base(message, innerException);
|
public ParsingException (string message, Exception innerException) : base(message, innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user