Base64VarUInt

public struct Base64VarUInt : Hashable
extension Base64VarUInt: RawRepresentable
extension Base64VarUInt: Comparable
extension Base64VarUInt: TextOutputStreamable
extension Base64VarUInt: LosslessStringConvertible

An unsigned integer whose textual representation uses a variable-length code in base 64.

The textual representation of a Base64VarUInt is satisfies the following properties:

  • Small values use fewer characters than larger values.
  • The length of the representation can be determined by looking at just the first character.

The textual representation of v is composed of 1 to n ASCII characters (0 < n < 12), written an. v is decoded as follows:

  • If a0 < 51, then n = 1 and v = a0.
  • If a0 == 51, then n = 2 and v = 50 + a1.
  • If a0 == 52, then n = 3 and v = 114 + 64 * a1 + a2.
  • Otherwise, n = a0 and v is the sum of ai * 64^(a0 - i) for 1 <= i < a0.
  • The value of the digit, in the range 0 ..< UInt64.max.

    Declaration

    Swift

    public let rawValue: UInt64
  • Creates an instance from its.

    Requires

    n >= 0

    Declaration

    Swift

    public init<T>(_ n: T) where T : BinaryInteger
  • Creates an instance from its raw value.

    Declaration

    Swift

    public init(rawValue n: UInt64)
  • Returns true iff l is less than r.

    Declaration

    Swift

    public static func < (l: `Self`, r: `Self`) -> Bool
  • Declaration

    Swift

    public func write<T>(to output: inout T) where T : TextOutputStream
  • Declaration

    Swift

    public init?(_ description: String)
  • Declaration

    Swift

    public var description: String { get }
  • Parses an instance at the beginning of the given string, returning its value and the position immediately after the last character of the decoded value’s representation.

    Declaration

    Swift

    public static func decode<S: StringProtocol>(
      from input: S
    ) -> (decoded: Base64VarUInt, indexAfter: S.Index)?
  • Parses an instance at the beginning of the given byte sequence, returning its value and the number of bytes read.

    See more

    Declaration

    Swift

    public static func decode<S: Sequence<UInt8>>(
      from stream: S
    ) -> (decoded: Base64VarUInt, readCount: Int)?