public override string ToString() { StringBuilder lStringBuilder = new StringBuilder(); lStringBuilder.Append(";"); SGFProperty lLastSGFProperty = null; foreach (SGFProperty lSGFProperty in Properties) { if (lLastSGFProperty == null) { lStringBuilder.Append(lSGFProperty.ToString()); } else if (lLastSGFProperty.PropertyID == lSGFProperty.PropertyID) { lStringBuilder.Append(lSGFProperty.ToStringNoPropertyID()); } else { lStringBuilder.AppendLine(); lStringBuilder.Append(lSGFProperty.ToString()); } lLastSGFProperty = lSGFProperty; } lStringBuilder.AppendLine(); return(lStringBuilder.ToString()); }
public void AddPropertyIfNotEmpty(SGFProperty sgfProperty) { if (!string.IsNullOrEmpty(sgfProperty.Text)) { AddProperty(sgfProperty); } }
public bool Read(MemFile memFile) { char c = memFile.Get(); if (c != ';') return SetErrorMessage("Expecting semi-colon, found: " + c.ToString()); while (true) { if (memFile.EOF) return true; c = memFile.Peek(); if (c == '(') break; // variation if ((c == ';') || (c == ')')) break; if (Char.IsLetter(c)) { SGFProperty lSGFProperty = new SGFProperty(memFile); if (lSGFProperty.IsError()) return SetErrorMessage(lSGFProperty); AddProperty(lSGFProperty); while (true) { c = memFile.Peek(); if (c == ')') break; if (c == '(') break; if (c == '[') { memFile.Get(); // eat this character SGFProperty lSGFProperty2 = new SGFProperty(memFile, lSGFProperty.PropertyID); if (lSGFProperty2.IsError()) return SetErrorMessage(lSGFProperty2); ; AddProperty(lSGFProperty2); } else if (!Char.IsLetter(c)) { memFile.Get(); // eat this character if (memFile.EOF) return SetErrorMessage("Unexpected EOF."); } else break; } } else memFile.Get(); // eat this character if (memFile.EOF) return SetErrorMessage("Unexpected EOF."); } return true; }
public void AddPropertyIfNotEmpty(SGFProperty sgfProperty) { if (!string.IsNullOrEmpty(sgfProperty.Text)) AddProperty(sgfProperty); }
public void AddProperty(SGFProperty sgfProperty) { Properties.Add(sgfProperty); }
public bool Read(MemFile memFile) { char c = memFile.Get(); if (c != ';') { return(SetErrorMessage("Expecting semi-colon, found: " + c.ToString())); } while (true) { if (memFile.EOF) { return(true); } c = memFile.Peek(); if (c == '(') { break; // variation } if ((c == ';') || (c == ')')) { break; } if (Char.IsLetter(c)) { SGFProperty lSGFProperty = new SGFProperty(memFile); if (lSGFProperty.IsError()) { return(SetErrorMessage(lSGFProperty)); } AddProperty(lSGFProperty); while (true) { c = memFile.Peek(); if (c == ')') { break; } if (c == '(') { break; } if (c == '[') { memFile.Get(); // eat this character SGFProperty lSGFProperty2 = new SGFProperty(memFile, lSGFProperty.PropertyID); if (lSGFProperty2.IsError()) { return(SetErrorMessage(lSGFProperty2)); } ; AddProperty(lSGFProperty2); } else if (!Char.IsLetter(c)) { memFile.Get(); // eat this character if (memFile.EOF) { return(SetErrorMessage("Unexpected EOF.")); } } else { break; } } } else { memFile.Get(); // eat this character } if (memFile.EOF) { return(SetErrorMessage("Unexpected EOF.")); } } return(true); }