From a1e240e759ad5de914495c370e3bda12a3988b3a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 17 Nov 2012 09:25:32 +0000 Subject: Adding C# style XML documentation. It turns out Doxygen handles that properly too. Wow, Doxygen, it really does it all :-P --- cs-dotnet/src/gatsexception.cs | 3 +++ cs-dotnet/src/gatsobject.cs | 42 +++++++++++++++++++++++++++++++ cs-dotnet/src/gatsstream.cs | 57 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) (limited to 'cs-dotnet/src') diff --git a/cs-dotnet/src/gatsexception.cs b/cs-dotnet/src/gatsexception.cs index 442a4ff..1d01e07 100644 --- a/cs-dotnet/src/gatsexception.cs +++ b/cs-dotnet/src/gatsexception.cs @@ -9,6 +9,9 @@ using System; namespace Com.Xagasoft.Gats { + /// + /// Exception used to report parsing or encoding errors in GATS. + /// public class GatsException : Exception { public enum Type diff --git a/cs-dotnet/src/gatsobject.cs b/cs-dotnet/src/gatsobject.cs index 7c92cff..57da747 100644 --- a/cs-dotnet/src/gatsobject.cs +++ b/cs-dotnet/src/gatsobject.cs @@ -9,11 +9,53 @@ using System.IO; namespace Com.Xagasoft.Gats { + /// + /// The base class of all GATS Data Type classes. + /// + /// + /// This provides the standard Read and Write methods that are used to do + /// all type serialization, as well as a handy static Read function that + /// can be used + /// to read in any type. These methods should not be used in normal + /// programming, instead use the GatsStream class to read and write + /// complete GATS packets. + /// public abstract class GatsObject { + /// + /// Read a single object from the provided stream. + /// + /// + /// This method does not read the leading type character. The static + /// Read method in GatsObject does this, and passes the type into the + /// Read method as a parameter in case it's needed by a specific type, + /// such as GatsBoolean. + /// + /// The Stream derived class to read from. + /// The already read type specifier. public abstract void Read( Stream s, char type ); + + /// + /// Write a single object to the provided stream. + /// + /// + /// Unlike the Read method, this does actually write the leading type + /// specifier. + /// + /// The Stream derived class to write to. public abstract void Write( Stream s ); + /// + /// Reads a GatsObject from the provided stream and returns it. + /// + /// + /// This method reads the initial type specifier byte, constructs the + /// proper object, calls the Read method on that object, and returns + /// the result. + /// + /// + /// The constructed object, or null if an end type was found. + /// public static GatsObject Read( Stream s ) { int b = s.ReadByte(); diff --git a/cs-dotnet/src/gatsstream.cs b/cs-dotnet/src/gatsstream.cs index e1bba91..742f0b4 100644 --- a/cs-dotnet/src/gatsstream.cs +++ b/cs-dotnet/src/gatsstream.cs @@ -11,6 +11,23 @@ using System; namespace Com.Xagasoft.Gats { + /// + /// Main I/O interface. Use this to read and write GATS. + /// + /// + /// GatsStream is not a traditional Stream class, it only can read and + /// write complete GATS packets. A GATS packet consists of a version, + /// size, and a single encoded GATS object (which can be a container). + /// + /// This one class handles both reading and writing. Writing is fairly + /// straight forward, but for volatile streams like network sockets you'll + /// probably want to wrap your stream with a buffer before handing it to + /// GatsStream. + /// + /// Reading handles it's own buffering, and will remember what has been + /// read between calls if it cannot get enough data at once to complete + /// a single packet. See the ReadObject docs for more details. + /// public class GatsStream { private Stream s; @@ -20,12 +37,37 @@ namespace Com.Xagasoft.Gats private BinaryWriter bw = null; private BinaryReader br = null; + /// + /// Construct a new GatsStream around a given Stream class. + /// + /// + /// The provided Stream does not need to be opened for both reading and + /// writing, you can construct a GatsStream around a read only or + /// write only stream. + /// + /// Stream to operate on. public GatsStream( Stream s ) { this.s = s; this.ReadBuf = new MemoryStream(); } + /// + /// Read a GATS packet and return the contained GatsObject. + /// + /// + /// This reads a complete packet into an internal buffer, parses the + /// gats object within it, and returns it. This method will read as + /// much data as it needs from the stream, but no more. Not a single + /// extra byte will be read. + /// + /// In the event that an end of stream is encountered, or a partial + /// packet has been read but no more data can be read at the moment, + /// this method will maintain it's buffer but return null to the caller. + /// + /// + /// The read object, or null if no object could be read yet. + /// public GatsObject ReadObject() { if( size == -1 ) @@ -70,6 +112,21 @@ namespace Com.Xagasoft.Gats return null; } + /// + /// Write a GatsObject to the stream in a proper GATS packet. + /// + /// + /// The object passed in is first written to an internal buffer, and + /// then to the output in several write operations. This means that + /// for many applications you will want to buffer the output. In the + /// case of writing to files, it could be faster to buffer the output. + /// In the case of writing to a socket buffering could prevent sending + /// many small packets. + /// + /// No flushing is done by this method, it is left to the caller to + /// determine the proper time to flush their streams. + /// + /// The object to be written. public void WriteObject( GatsObject obj ) { MemoryStream ms = new MemoryStream(); -- cgit v1.2.3