Package tlslite :: Package utils :: Module codec :: Class Writer
[hide private]
[frames] | no frames]

type Writer

source code


Serialisation helper for complex byte-based structures.

Instance Methods [hide private]
 
__init__(self)
Initialise the serializer with no data.
source code
 
add(self, x, length)
Add a single positive integer value x, encode it in length bytes
source code
 
addFixSeq(self, seq, length)
Add a list of items, encode every item in length bytes
source code
 
addFour(self, val)
Add a four-byte wide element to buffer, see add().
source code
 
addOne(self, val)
Add a single-byte wide element to buffer, see add().
source code
 
addThree(self, val)
Add a three-byte wide element to buffer, see add().
source code
 
addTwo(self, val)
Add a double-byte wide element to buffer, see add().
source code
 
addVarSeq(self, seq, length, lengthLength)
Add a bounded list of same-sized values
source code
 
addVarTupleSeq(self, seq, length, lengthLength)
Add a variable length list of same-sized element tuples.
source code
Class Variables [hide private]
  _addMethods = {1: <function addOne at 0x7fde3da77578>, 2: <fun...
Method Details [hide private]

__init__(self)
(Constructor)

source code 

Initialise the serializer with no data.

Overrides: object.__init__

add(self, x, length)

source code 

Add a single positive integer value x, encode it in length bytes

Encode positive iteger x in big-endian format using length bytes, add to the internal buffer.

Parameters:
  • x (int) - value to encode
  • length (int) - number of bytes to use for encoding the value

addFixSeq(self, seq, length)

source code 

Add a list of items, encode every item in length bytes

Uses the unbounded iterable seq to produce items, each of which is then encoded to length bytes

Parameters:
  • seq (iterable of int) - list of positive integers to encode
  • length (int) - number of bytes to which encode every element

addVarSeq(self, seq, length, lengthLength)

source code 

Add a bounded list of same-sized values

Create a list of specific length with all items being of the same size

Parameters:
  • seq (list of int) - list of positive integers to encode
  • length (int) - amount of bytes in which to encode every item
  • lengthLength (int) - amount of bytes in which to encode the overall length of the array

addVarTupleSeq(self, seq, length, lengthLength)

source code 

Add a variable length list of same-sized element tuples.

Note that all tuples must have the same size.

Inverse of Parser.getVarTupleList()

Parameters:
  • seq (enumerable) - list of tuples
  • length (int) - length of single element in tuple
  • lengthLength (int) - length in bytes of overall length field

Class Variable Details [hide private]

_addMethods

Value:
{1: <function addOne at 0x7fde3da77578>,
 2: <function addTwo at 0x7fde3da775f0>,
 3: <function addThree at 0x7fde3da77668>,
 4: <function addFour at 0x7fde3da776e0>}