Skip to content

Commit

Permalink
Prepare for first alpha of version 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
peteroupc committed Sep 18, 2018
1 parent 67582aa commit b9c6713
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 303 deletions.
15 changes: 8 additions & 7 deletions CBOR/CBOR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>3.3.0</Version>
<Version>3.4.0-a1</Version>
<Owners>Peter Occil</Owners>
<Description>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049.</Description>
<Summary>A C# implementation of Concise Binary Object Representation (CBOR), a general-purpose binary data format defined in RFC 7049. </Summary>
Expand All @@ -13,13 +13,14 @@
<PackageLicenseUrl>http://creativecommons.org/publicdomain/zero/1.0/</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/peteroupc/CBOR</PackageProjectUrl>
<PackageReleaseNotes>
Version 3.4.0-a1:

Version 3.3:
- Add ToObject method for deserializing CBOR objects.
- Add ICBORObjectConverter interface.
- Add HasMostOuterTag method to CBORObject class.
- Add CTAP2 canonicalization support to CBOR object encoding.
- Added examples in several places in documentation.

- Added Clear, RemoveAt and Remove(object) methods to CBORObject class. Formerly, it was very hard with existing methods to remove items from CBOR maps and arrays.
- Added CodePointLength and ToUpperCaseAscii methods to DataUtilities class.
- Added WriteValue family of methods to CBORObject class. This can be used for lower-level encoding of CBOR objects. Examples on its use were included in the documentation.
- Bug fixes.

</PackageReleaseNotes>
<PackageTags>cbor data serialization binary json numbers arithmetic</PackageTags>
Expand Down Expand Up @@ -61,4 +62,4 @@ Version 3.3:
<ItemGroup>
<PackageReference Include="PeterO.Numbers" Version="1.1.2" />
</ItemGroup>
</Project>
</Project>
173 changes: 12 additions & 161 deletions CBOR/PeterO/Cbor/CBORObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,38 +602,8 @@ public static CBORObject DecodeFromBytes(byte[] data) {
return DecodeFromBytes(data, new CBOREncodeOptions(true, true));
}

/// <summary>Generates a CBOR object from an array of CBOR-encoded
/// bytes, using the given <c>CBOREncodeOptions</c>
/// object to control
/// the decoding process.</summary>
/// <param name='data'>A byte array in which a single CBOR object is
/// encoded.</param>
/// <param name='options'>The parameter <paramref name='options'/> is a
/// CBOREncodeOptions object.</param>
/// <returns>A CBOR object decoded from the given byte array.</returns>
/// <exception cref='T:PeterO.Cbor.CBORException'>There was an error in
/// reading or parsing the data. This includes cases where not all of
/// the byte array represents a CBOR object. This exception is also
/// thrown if the parameter <paramref name='data'/> is
/// empty.</exception>
/// <exception cref='T:System.ArgumentNullException'>The parameter
/// <paramref name='data'/> is null.</exception>
/// <example>
/// <para>The following example (originally written in C# for the .NET
/// version) implements a method that decodes a text string from a CBOR
/// byte array. It's successful only if the CBOR object contains an
/// untagged text string.</para>
/// <code>private static String DecodeTextString&#x28;byte[]
/// bytes)&#x7b; if&#x28;bytes
/// == null)&#x7b; throw new
/// ArgumentNullException&#x28;nameof(mapObj));&#x7d;
/// if&#x28;bytes.Length ==
/// 0 || bytes[0]&lt;0x60 || bytes[0]&gt;0x7f)&#x7b;throw new
/// CBORException&#x28;);&#x7d;
/// return CBORObject.DecodeFromBytes&#x28;bytes,
/// CBOREncodeOptions.Default).AsString&#x28;); &#x7d;
/// </code>
/// </example>
/// <include file='../../docs.xml'
/// path='docs/doc[@name="M:PeterO.Cbor.CBORObject.DecodeFromBytes(System.Byte[],PeterO.Cbor.CBOREncodeOptions)"]/*'/>
public static CBORObject DecodeFromBytes(
byte[] data,
CBOREncodeOptions options) {
Expand Down Expand Up @@ -1870,33 +1840,8 @@ public CBORObject Add(object key, object valueOb) {
return this;
}

/// <summary><para>Adds a new object to the end of this array. (Used to
/// throw ArgumentNullException on a null reference, but now converts
/// the null reference to CBORObject.Null, for convenience with the
/// Object overload of this method).</para>
/// <para>NOTE: This method
/// can't be used to add a tag to an existing CBOR object. To create a
/// CBOR object with a given tag, call the
/// <c>CBORObject.FromObjectAndTag</c>
/// method and pass the CBOR object
/// and the desired tag number to that method.</para>
/// </summary>
/// <param name='obj'>The parameter <paramref name='obj'/> is a CBOR
/// object.</param>
/// <returns>This instance.</returns>
/// <exception cref='T:System.InvalidOperationException'>This object is
/// not an array.</exception>
/// <example>
/// <para>The following example creates a CBOR array and adds several
/// CBOR objects, one of which has a custom CBOR tag, to that array.
/// Note the chaining behavior made possible by this method.</para>
/// <code>CBORObject obj = CBORObject.NewArray()
/// .Add(CBORObject.False)
/// .Add(CBORObject.FromObject(5))
/// .Add(CBORObject.FromObject("text string"))
/// .Add(CBORObject.FromObjectAndTag(9999, 1));
/// </code>
/// </example>
/// <include file='../../docs.xml'
/// path='docs/doc[@name="M:PeterO.Cbor.CBORObject.Add(PeterO.Cbor.CBORObject)"]/*'/>
public CBORObject Add(CBORObject obj) {
if (this.ItemType == CBORObjectTypeArray) {
IList<CBORObject> list = this.AsList();
Expand All @@ -1906,32 +1851,8 @@ public CBORObject Add(CBORObject obj) {
throw new InvalidOperationException("Not an array");
}

/// <summary><para>Converts an object to a CBOR object and adds it to
/// the end of this array.</para>
/// <para>NOTE: This method can't be used
/// to add a tag to an existing CBOR object. To create a CBOR object
/// with a given tag, call the <c>CBORObject.FromObjectAndTag</c>
/// method and pass the CBOR object and the desired tag number to that
/// method.</para>
/// </summary>
/// <param name='obj'>The parameter <paramref name='obj'/> is a CBOR
/// object.</param>
/// <returns>This instance.</returns>
/// <exception cref='T:System.InvalidOperationException'>This object is
/// not an array.</exception>
/// <exception cref='T:System.ArgumentException'>The type of <paramref
/// name='obj'/> is not supported.</exception>
/// <example>
/// <para>The following example creates a CBOR array and adds several
/// CBOR objects, one of which has a custom CBOR tag, to that array.
/// Note the chaining behavior made possible by this method.</para>
/// <code>CBORObject obj = CBORObject.NewArray()
/// .Add(CBORObject.False)
/// .Add(5)
/// .Add("text string")
/// .Add(CBORObject.FromObjectAndTag(9999, 1));
/// </code>
/// </example>
/// <include file='../../docs.xml'
/// path='docs/doc[@name="M:PeterO.Cbor.CBORObject.Add(System.Object)"]/*'/>
public CBORObject Add(object obj) {
if (this.ItemType == CBORObjectTypeArray) {
IList<CBORObject> list = this.AsList();
Expand Down Expand Up @@ -2051,70 +1972,14 @@ public short AsInt16() {
return (short)this.AsInt32(Int16.MinValue, Int16.MaxValue);
}

/// <summary>Converts this object to a 32-bit signed integer.
/// Non-integer number values are truncated to an integer. (NOTE: To
/// determine whether this method call can succeed, call the
/// <b>CanTruncatedIntFitInInt32</b>
/// method before calling this method.
/// Checking whether this object's type is <c>CBORType.Number</c>
/// is
/// not sufficient. See the example.).</summary>
/// <returns>The closest 32-bit signed integer to this
/// object.</returns>
/// <exception cref='T:System.InvalidOperationException'>This object's
/// type is not a number type.</exception>
/// <exception cref='T:System.OverflowException'>This object's value
/// exceeds the range of a 32-bit signed integer.</exception>
/// <example>
/// <para>The following example code (originally written in C# for the
/// .NET Framework) shows a way to check whether a given CBOR object
/// stores a 32-bit signed integer before getting its value.</para>
/// <code>
/// CBORObject obj = CBORObject.FromInt32(99999);
/// if&#x28;obj.IsIntegral &amp;&amp;
/// obj.CanTruncatedIntFitInInt32&#x28;)) &#x7b;
/// // Not an Int32; handle the error
/// Console.WriteLine("Not a 32-bit integer.");
/// &#x7d; else {
/// Console.WriteLine("The value is " +
/// obj.AsInt32());
/// }
/// </code>
/// </example>
/// <include file='../../docs.xml'
/// path='docs/doc[@name="M:PeterO.Cbor.CBORObject.AsInt32"]/*'/>
public int AsInt32() {
return this.AsInt32(Int32.MinValue, Int32.MaxValue);
}

/// <summary>Converts this object to a 64-bit signed integer.
/// Non-integer numbers are truncated to an integer. (NOTE: To
/// determine whether this method call can succeed, call the
/// <b>CanTruncatedIntFitInInt64</b>
/// method before calling this method.
/// Checking whether this object's type is <c>CBORType.Number</c>
/// is
/// not sufficient. See the example.).</summary>
/// <returns>The closest 64-bit signed integer to this
/// object.</returns>
/// <exception cref='T:System.InvalidOperationException'>This object's
/// type is not a number type.</exception>
/// <exception cref='T:System.OverflowException'>This object's value
/// exceeds the range of a 64-bit signed integer.</exception>
/// <example>
/// <para>The following example code (originally written in C# for the
/// .NET Framework) shows a way to check whether a given CBOR object
/// stores a 64-bit signed integer before getting its value.</para>
/// <code>
/// CBORObject obj = CBORObject.FromInt64(99999);
/// if&#x28;obj.IsIntegral &amp;&amp;
/// obj.CanTruncatedIntFitInInt64&#x28;)) &#x7b;
/// // Not an Int64; handle the error
/// Console.WriteLine("Not a 64-bit integer.");
/// &#x7d; else {
/// Console.WriteLine("The value is " +
/// obj.AsInt64());
/// }
/// </code>
/// </example>
/// <include file='../../docs.xml'
/// path='docs/doc[@name="M:PeterO.Cbor.CBORObject.AsInt64"]/*'/>
public long AsInt64() {
ICBORNumber cn = NumberInterfaces[this.ItemType];
if (cn == null) {
Expand All @@ -2133,22 +1998,8 @@ public float AsSingle() {
return cn.AsSingle(this.ThisItem);
}

/// <summary>Gets the value of this object as a text string.</summary>
/// <returns>Gets this object's string.</returns>
/// <exception cref='T:System.InvalidOperationException'>This object's
/// type is not a string, including if this object is
/// CBORObject.Null.</exception>
/// <example>
/// <para>The following example code (originally written in C# for the
/// .NET Framework) shows an idiom for returning a string value if a
/// CBOR object is a text string, or <c>null</c>
/// if the CBOR object is
/// a CBOR null.</para>
/// <code>
/// CBORObject obj = CBORObject.FromString("test");
/// string str = obj.IsNull ? null : obj.AsString();
/// </code>
/// </example>
/// <include file='../../docs.xml'
/// path='docs/doc[@name="M:PeterO.Cbor.CBORObject.AsString"]/*'/>
public string AsString() {
// TODO: Consider returning null if this object is null
// in next major version
Expand Down
Loading

0 comments on commit b9c6713

Please sign in to comment.