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

Module common

source code

Implements common basic types in XML file format descriptions.
Classes [hide private]
  bytes
str(object) -> string
  Int
Basic implementation of a 32-bit signed integer type.
  UInt
Implementation of a 32-bit unsigned integer type.
  Int64
Implementation of a 64-bit signed integer type.
  UInt64
Implementation of a 64-bit unsigned integer type.
  Byte
Implementation of a 8-bit signed integer type.
  UByte
Implementation of a 8-bit unsigned integer type.
  Short
Implementation of a 16-bit signed integer type.
  UShort
Implementation of a 16-bit unsigned integer type.
  ULittle32
Little endian 32 bit unsigned integer (ignores specified data byte order).
  Bool
Simple bool implementation.
  Char
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.