// writes a canonical string literal private void WriteStringLiteral(StonTokenWriter writer, string content) { if (content == null) { throw new StonException("A non-existing string has been found in the structure to be written."); } else { writer.WriteStringLiteral(content); } }
// writes a simple value, depending on its data type private void WriteSimpleValue(StonTokenWriter writer, IStonSimpleValue value) { if (value == null) { throw new StonException("A simple-valued entity cannot have a non-existing value."); } switch (value.DataType) { case StonDataType.Null: writer.Write("null"); break; case StonDataType.Number: writer.WriteCanonicalNumberLiteral(value.Content); break; case StonDataType.Binary: writer.WriteBinaryLiteral(value.Content); break; case StonDataType.Named: writer.Write(value.Content); break; case StonDataType.Text: writer.WriteStringLiteral(value.Content, '"'); break; case StonDataType.Code: writer.WriteStringLiteral(value.Content, '`'); break; default: throw new StonException($"Unknown simple value data type: { (int)value.DataType }."); } }