aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-09-29 19:30:51 -0500
committerrogerk <devnull@localhost>2011-09-29 19:30:51 -0500
commitf67c83365f4fe7850eb25b6af38833de61c79057 (patch)
tree7f0cf0575fd57063f371c7b1987437ddeb992b49 /src
parentfa8fa92499e4bb5f74ecaa08535f177c56d8fd52 (diff)
downloadprotobuf-f67c83365f4fe7850eb25b6af38833de61c79057.tar.gz
protobuf-f67c83365f4fe7850eb25b6af38833de61c79057.tar.bz2
protobuf-f67c83365f4fe7850eb25b6af38833de61c79057.zip
Added comments for private fields
Renamed StartMessage(name) to WriteMessageStart(name) on XmlFormatWriter as this was intended to be an overload that did not get renamed.
Diffstat (limited to 'src')
-rw-r--r--src/ProtocolBuffers.Serialization/JsonFormatReader.cs1
-rw-r--r--src/ProtocolBuffers.Serialization/JsonFormatWriter.cs2
-rw-r--r--src/ProtocolBuffers.Serialization/XmlFormatReader.cs4
-rw-r--r--src/ProtocolBuffers.Serialization/XmlFormatWriter.cs10
4 files changed, 13 insertions, 4 deletions
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatReader.cs b/src/ProtocolBuffers.Serialization/JsonFormatReader.cs
index 240ce625..7b88cafe 100644
--- a/src/ProtocolBuffers.Serialization/JsonFormatReader.cs
+++ b/src/ProtocolBuffers.Serialization/JsonFormatReader.cs
@@ -11,6 +11,7 @@ namespace Google.ProtocolBuffers.Serialization
public class JsonFormatReader : AbstractTextReader
{
private readonly JsonCursor _input;
+ // The expected token that ends the current item, either ']' or '}'
private readonly Stack<int> _stopChar;
private enum ReaderState
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
index 035870df..d7fd9e7b 100644
--- a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
+++ b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
@@ -168,7 +168,9 @@ namespace Google.ProtocolBuffers.Serialization
#endregion
+ //Tracks the writer depth and the array element count at that depth.
private readonly List<int> _counter;
+ //True if the top-level of the writer is an array as opposed to a single message.
private bool _isArray;
/// <summary>
diff --git a/src/ProtocolBuffers.Serialization/XmlFormatReader.cs b/src/ProtocolBuffers.Serialization/XmlFormatReader.cs
index 20027177..4bf6423c 100644
--- a/src/ProtocolBuffers.Serialization/XmlFormatReader.cs
+++ b/src/ProtocolBuffers.Serialization/XmlFormatReader.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
+using System.Diagnostics;
namespace Google.ProtocolBuffers.Serialization
{
@@ -14,7 +15,9 @@ namespace Google.ProtocolBuffers.Serialization
{
public const string DefaultRootElementName = XmlFormatWriter.DefaultRootElementName;
private readonly XmlReader _input;
+ // Tracks the message element for each nested message read
private readonly Stack<ElementStackEntry> _elements;
+ // The default element name for ReadMessageStart
private string _rootElementName;
private struct ElementStackEntry
@@ -118,6 +121,7 @@ namespace Google.ProtocolBuffers.Serialization
}
}
+ [DebuggerNonUserCode]
private static void Assert(bool cond)
{
if (!cond)
diff --git a/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs b/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
index fc3f9dc2..4bd27562 100644
--- a/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
+++ b/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
@@ -16,9 +16,11 @@ namespace Google.ProtocolBuffers.Serialization
{
private static readonly Encoding DefaultEncoding = new UTF8Encoding(false);
public const string DefaultRootElementName = "root";
- private const int NestedArrayFlag = 0x0001;
+
private readonly XmlWriter _output;
+ // The default element name used for WriteMessageStart
private string _rootElementName;
+ // Used to assert matching WriteMessageStart/WriteMessageEnd calls
private int _messageOpenCount;
private static XmlWriterSettings DefaultSettings(Encoding encoding)
@@ -119,7 +121,7 @@ namespace Google.ProtocolBuffers.Serialization
/// </summary>
public override void WriteMessageStart()
{
- StartMessage(_rootElementName);
+ WriteMessageStart(_rootElementName);
}
/// <summary>
@@ -127,7 +129,7 @@ namespace Google.ProtocolBuffers.Serialization
/// After this call you can call IMessageLite.MergeTo(...) and complete the message with
/// a call to WriteMessageEnd().
/// </summary>
- public void StartMessage(string elementName)
+ public void WriteMessageStart(string elementName)
{
if (TestOption(XmlWriterOptions.OutputJsonTypes))
{
@@ -169,7 +171,7 @@ namespace Google.ProtocolBuffers.Serialization
/// </summary>
public void WriteMessage(string elementName, IMessageLite message)
{
- StartMessage(elementName);
+ WriteMessageStart(elementName);
message.WriteTo(this);
WriteMessageEnd();
}