// Autogenerated C# message buffer code. // Source: clad/cloud/logcollector.clad // Full command line: victor-clad/tools/message-buffers/emitters/CSharp_emitter.py -C src -I clad/src lib/util/source/anki/clad robot/clad/src coretech/vision/clad_src coretech/common/clad_src -o generated/cladCSharp clad/cloud/logcollector.clad namespace Anki { namespace Vector { namespace LogCollector { public enum LogCollectorError : byte { ErrorConnecting = 0 }; public partial class UploadResponse { private string _logUrl; // string[uint_16] public string logUrl { get { return _logUrl; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("logUrl string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _logUrl = value; } } /**** Constructors ****/ public UploadResponse() { } public UploadResponse(string logUrl) { this.logUrl = logUrl; } public UploadResponse(System.IO.Stream stream) { Unpack(stream); } public UploadResponse(System.IO.BinaryReader reader) { Unpack(reader); } public UploadResponse Initialize(string logUrl) { this.logUrl = logUrl; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _logUrl_length = (int)reader.ReadUInt16(); byte[] _logUrl_bytes = reader.ReadBytes(_logUrl_length); _logUrl = System.Text.Encoding.UTF8.GetString(_logUrl_bytes); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_logUrl != null) { byte[] _logUrl_bytes = System.Text.Encoding.UTF8.GetBytes(_logUrl); writer.Write((ushort)_logUrl_bytes.Length); writer.Write(_logUrl_bytes); } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 2; // uint_16 if (logUrl != null) { result += System.Text.Encoding.UTF8.GetByteCount(logUrl); } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(UploadResponse a, UploadResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(UploadResponse a, UploadResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as UploadResponse); } public bool Equals(UploadResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._logUrl.Equals(p._logUrl); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public partial class UploadRequest { private string _logFileName; // string[uint_16] public string logFileName { get { return _logFileName; } set { if (!string.IsNullOrEmpty(value) && System.Text.Encoding.UTF8.GetByteCount(value) > 65535) { throw new System.ArgumentException("logFileName string is too long. Must decode to less than or equal to 65535 bytes.", "value"); } _logFileName = value; } } /**** Constructors ****/ public UploadRequest() { } public UploadRequest(string logFileName) { this.logFileName = logFileName; } public UploadRequest(System.IO.Stream stream) { Unpack(stream); } public UploadRequest(System.IO.BinaryReader reader) { Unpack(reader); } public UploadRequest Initialize(string logFileName) { this.logFileName = logFileName; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { int _logFileName_length = (int)reader.ReadUInt16(); byte[] _logFileName_bytes = reader.ReadBytes(_logFileName_length); _logFileName = System.Text.Encoding.UTF8.GetString(_logFileName_bytes); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { if (_logFileName != null) { byte[] _logFileName_bytes = System.Text.Encoding.UTF8.GetBytes(_logFileName); writer.Write((ushort)_logFileName_bytes.Length); writer.Write(_logFileName_bytes); } else { writer.Write((ushort)0); } } public int Size { get { int result = 0; result += 2; // uint_16 if (logFileName != null) { result += System.Text.Encoding.UTF8.GetByteCount(logFileName); } return result; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(UploadRequest a, UploadRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(UploadRequest a, UploadRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as UploadRequest); } public bool Equals(UploadRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._logFileName.Equals(p._logFileName); } public override int GetHashCode() { unchecked { int hash = 17; return hash; } } } public class LogCollectorRequest { public enum Tag { upload, // 0 INVALID = 255 }; private Tag _tag = Tag.INVALID; public Tag GetTag() { return _tag; } private object _state = null; public object GetState() { return _state; } public Anki.Vector.LogCollector.UploadRequest upload { get { if (_tag != Tag.upload) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"upload\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.LogCollector.UploadRequest)this._state; } set { _tag = (value != null) ? Tag.upload : Tag.INVALID; _state = value; } } public LogCollectorRequest Initialize(T state) { _state = state; if(typeof(T) == typeof(Anki.Vector.LogCollector.UploadRequest)) { _tag = Tag.upload; } else { _state = null; _tag = Tag.INVALID; } return this; } /**** Constructors ****/ public LogCollectorRequest() { } public LogCollectorRequest(System.IO.Stream stream) { Unpack(stream); } public LogCollectorRequest(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { Tag newTag = (Tag)reader.ReadByte(); switch(newTag) { case Tag.upload: upload = new Anki.Vector.LogCollector.UploadRequest(reader); break; default: break; } _tag = newTag; } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)GetTag()); switch(GetTag()) { case Tag.upload: if (upload == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } upload.Pack(writer); break; default: break; } } public int Size { get { int result = 1; // tag = byte switch(GetTag()) { case Tag.upload: if (upload == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += upload.Size; break; default: // Just tag size break; } return result; } } public static bool operator ==(LogCollectorRequest a, LogCollectorRequest b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(LogCollectorRequest a, LogCollectorRequest b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as LogCollectorRequest); } public bool Equals(LogCollectorRequest p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return (_tag == p._tag && _state.Equals(p._state)); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._tag.GetHashCode(); hash = hash * 23 + this._state.GetHashCode(); return hash; } } } public partial class LogCollectorErrorResponse { private Anki.Vector.LogCollector.LogCollectorError _err; // LogCollectorError public Anki.Vector.LogCollector.LogCollectorError err { get { return _err; } set { _err = value; } } /**** Constructors ****/ public LogCollectorErrorResponse() { } public LogCollectorErrorResponse(Anki.Vector.LogCollector.LogCollectorError err) { this.err = err; } public LogCollectorErrorResponse(System.IO.Stream stream) { Unpack(stream); } public LogCollectorErrorResponse(System.IO.BinaryReader reader) { Unpack(reader); } public LogCollectorErrorResponse Initialize(Anki.Vector.LogCollector.LogCollectorError err) { this.err = err; return this; } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { _err = (Anki.Vector.LogCollector.LogCollectorError)reader.ReadByte(); } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)_err); } public int Size { get { return 1; } } public static bool ArrayEquals(System.Collections.Generic.IList a1, System.Collections.Generic.IList a2) { if (System.Object.ReferenceEquals(a1, a2)) return true; if (System.Object.ReferenceEquals(a1, null) || System.Object.ReferenceEquals(a2, null)) return false; if (a1.Count != a2.Count) return false; for (int i = 0; i < a1.Count; i++) { if (!a1[i].Equals(a2[i])) { return false; } } return true; } public static bool operator ==(LogCollectorErrorResponse a, LogCollectorErrorResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(LogCollectorErrorResponse a, LogCollectorErrorResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as LogCollectorErrorResponse); } public bool Equals(LogCollectorErrorResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return this._err.Equals(p._err); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._err.GetHashCode(); return hash; } } } public class LogCollectorResponse { public enum Tag { upload, // 0 err, // 1 INVALID = 255 }; private Tag _tag = Tag.INVALID; public Tag GetTag() { return _tag; } private object _state = null; public object GetState() { return _state; } public Anki.Vector.LogCollector.UploadResponse upload { get { if (_tag != Tag.upload) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"upload\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.LogCollector.UploadResponse)this._state; } set { _tag = (value != null) ? Tag.upload : Tag.INVALID; _state = value; } } public Anki.Vector.LogCollector.LogCollectorErrorResponse err { get { if (_tag != Tag.err) { throw new System.InvalidOperationException(string.Format( "Cannot access union member \"err\" when a value of type {0} is stored.", _tag.ToString())); } return (Anki.Vector.LogCollector.LogCollectorErrorResponse)this._state; } set { _tag = (value != null) ? Tag.err : Tag.INVALID; _state = value; } } public LogCollectorResponse Initialize(T state) { _state = state; if(typeof(T) == typeof(Anki.Vector.LogCollector.UploadResponse)) { _tag = Tag.upload; } else if(typeof(T) == typeof(Anki.Vector.LogCollector.LogCollectorErrorResponse)) { _tag = Tag.err; } else { _state = null; _tag = Tag.INVALID; } return this; } /**** Constructors ****/ public LogCollectorResponse() { } public LogCollectorResponse(System.IO.Stream stream) { Unpack(stream); } public LogCollectorResponse(System.IO.BinaryReader reader) { Unpack(reader); } public void Unpack(System.IO.Stream stream) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); Unpack(reader); } public void Unpack(System.IO.BinaryReader reader) { Tag newTag = (Tag)reader.ReadByte(); switch(newTag) { case Tag.upload: upload = new Anki.Vector.LogCollector.UploadResponse(reader); break; case Tag.err: err = new Anki.Vector.LogCollector.LogCollectorErrorResponse(reader); break; default: break; } _tag = newTag; } public void Pack(System.IO.Stream stream) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); Pack(writer); } public void Pack(System.IO.BinaryWriter writer) { writer.Write((byte)GetTag()); switch(GetTag()) { case Tag.upload: if (upload == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } upload.Pack(writer); break; case Tag.err: if (err == null) { throw new System.InvalidOperationException("Arrays in messages may not have null entries."); } err.Pack(writer); break; default: break; } } public int Size { get { int result = 1; // tag = byte switch(GetTag()) { case Tag.upload: if (upload == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += upload.Size; break; case Tag.err: if (err == null) { throw new System.InvalidOperationException("Messages may not have null members."); } result += err.Size; break; default: // Just tag size break; } return result; } } public static bool operator ==(LogCollectorResponse a, LogCollectorResponse b) { if (System.Object.ReferenceEquals(a, null)) { return System.Object.ReferenceEquals(b, null); } return a.Equals(b); } public static bool operator !=(LogCollectorResponse a, LogCollectorResponse b) { return !(a == b); } public override bool Equals(System.Object obj) { return this.Equals(obj as LogCollectorResponse); } public bool Equals(LogCollectorResponse p) { if (System.Object.ReferenceEquals(p, null)) { return false; } return (_tag == p._tag && _state.Equals(p._state)); } public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + this._tag.GetHashCode(); hash = hash * 23 + this._state.GetHashCode(); return hash; } } } } // namespace LogCollector } // namespace Vector } // namespace Anki