Package pyffi :: Package object_models :: Module binary_type
[hide private]
[frames] | no frames]

Module binary_type

source code

Implements common basic types in XML file format descriptions.
Classes [hide private]
  BinaryType
Abstract base class for binary data types.
  BinarySimpleType
Abstract base class for binary data types.
  bytes
str(object) -> string
  IntType
Basic implementation of a 32-bit signed integer type.
  UIntType
Implementation of a 32-bit unsigned integer type.
  ByteType
Implementation of a 8-bit signed integer type.
  UByteType
Implementation of a 8-bit unsigned integer type.
  ShortType
Implementation of a 16-bit signed integer type.
  UShortType
Implementation of a 16-bit unsigned integer type.
  BoolType
Simple bool implementation.
  CharType
Implementation of an (unencoded) 8-bit character.
  Float
Implementation of a 32-bit float.
  ZString
String of variable length (null terminated).
  FixedString
String of fixed length.
  SizedString
Basic type for strings.
  UndecodedData
Basic type for undecoded data trailing at the end of a file.
Functions [hide private]
C{_bytes}
_as_bytes(value)
Helper function which converts a string to _bytes (this is useful for set_value in all string classes, which use bytes for representation).
source code
 
_as_str(value)
Helper function to convert bytes back to str.
source code
Variables [hide private]
  _b = ''
  _b00 = '\x00'
  __package__ = 'pyffi.object_models'
Function Details [hide private]

_as_bytes(value)

source code 

Helper function which converts a string to _bytes (this is useful for set_value in all string classes, which use bytes for representation).

>>> # following doctest fails on py3k, hence disabled
>>> _as_bytes(u"\u00e9defa") == u"\u00e9defa".encode("utf-8") # doctest: +SKIP
True
>>> _as_bytes(123) # doctest: +ELLIPSIS
Traceback (most recent call last):
    ...
TypeError: ...
Returns: C{_bytes}
The bytes representing the value.

_as_str(value)

source code 
Helper function to convert bytes back to str. This is used in the __str__ functions for simple string types. If you want a custom encoding, use an explicit decode call on the value.