Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
codecs.BufferedIncrementalDecoder Class Reference
Inheritance diagram for codecs.BufferedIncrementalDecoder:
Inheritance graph
[legend]
Collaboration diagram for codecs.BufferedIncrementalDecoder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def decode
def reset
def getstate
def setstate

Public Attributes

 buffer
 errors
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _buffer_decode

Detailed Description

This subclass of IncrementalDecoder can be used as the baseclass for an
incremental decoder if the decoder must be able to handle incomplete
byte sequences.

Definition at line 281 of file codecs.py.


Constructor & Destructor Documentation

def codecs.BufferedIncrementalDecoder.__init__ (   self,
  errors = 'strict' 
)
This subclass of IncrementalDecoder can be used as the baseclass for an
incremental decoder if the decoder must be able to handle incomplete
byte sequences.

Reimplemented from codecs.IncrementalDecoder.

Reimplemented in encodings.utf_16.IncrementalDecoder, encodings.utf_8_sig.IncrementalDecoder, and encodings.utf_32.IncrementalDecoder.

Definition at line 287 of file codecs.py.

00287 
00288     def __init__(self, errors='strict'):
00289         IncrementalDecoder.__init__(self, errors)
00290         # undecoded input that is kept between calls to decode()
00291         self.buffer = b""

Here is the caller graph for this function:


Member Function Documentation

def codecs.BufferedIncrementalDecoder._buffer_decode (   self,
  input,
  errors,
  final 
) [private]

Reimplemented in encodings.idna.IncrementalDecoder, encodings.utf_16.IncrementalDecoder, encodings.utf_8_sig.IncrementalDecoder, and encodings.utf_32.IncrementalDecoder.

Definition at line 292 of file codecs.py.

00292 
00293     def _buffer_decode(self, input, errors, final):
00294         # Overwrite this method in subclasses: It must decode input
00295         # and return an (output, length consumed) tuple
00296         raise NotImplementedError

Here is the caller graph for this function:

def codecs.BufferedIncrementalDecoder.decode (   self,
  input,
  final = False 
)
Decode input and returns the resulting object.

Reimplemented from codecs.IncrementalDecoder.

Definition at line 297 of file codecs.py.

00297 
00298     def decode(self, input, final=False):
00299         # decode input (taking the buffer into account)
00300         data = self.buffer + input
00301         (result, consumed) = self._buffer_decode(data, self.errors, final)
00302         # keep undecoded input until the next call
00303         self.buffer = data[consumed:]
00304         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Return the current state of the decoder.

This must be a (buffered_input, additional_state_info) tuple.
buffered_input must be a bytes object containing bytes that
were passed to decode() that have not yet been converted.
additional_state_info must be a non-negative integer
representing the state of the decoder WITHOUT yet having
processed the contents of buffered_input.  In the initial state
and after reset(), getstate() must return (b"", 0).

Reimplemented from codecs.IncrementalDecoder.

Reimplemented in encodings.utf_16.IncrementalDecoder, encodings.utf_8_sig.IncrementalDecoder, and encodings.utf_32.IncrementalDecoder.

Definition at line 309 of file codecs.py.

00309 
00310     def getstate(self):
00311         # additional state info is always 0
00312         return (self.buffer, 0)

Here is the caller graph for this function:

Reset the decoder to the initial state.

Reimplemented from codecs.IncrementalDecoder.

Reimplemented in encodings.utf_16.IncrementalDecoder, encodings.utf_8_sig.IncrementalDecoder, and encodings.utf_32.IncrementalDecoder.

Definition at line 305 of file codecs.py.

00305 
00306     def reset(self):
00307         IncrementalDecoder.reset(self)
00308         self.buffer = b""

Here is the caller graph for this function:

def codecs.BufferedIncrementalDecoder.setstate (   self,
  state 
)
Set the current state of the decoder.

state must have been returned by getstate().  The effect of
setstate((b"", 0)) must be equivalent to reset().

Reimplemented from codecs.IncrementalDecoder.

Reimplemented in encodings.utf_16.IncrementalDecoder, encodings.utf_32.IncrementalDecoder, and encodings.utf_8_sig.IncrementalDecoder.

Definition at line 313 of file codecs.py.

00313 
00314     def setstate(self, state):
00315         # ignore additional state info
00316         self.buffer = state[0]
00317 
00318 #
00319 # The StreamWriter and StreamReader class provide generic working
00320 # interfaces which can be used to implement new encoding submodules
00321 # very easily. See encodings/utf_8.py for an example on how this is
00322 # done.
00323 #

Here is the caller graph for this function:


Member Data Documentation

Definition at line 290 of file codecs.py.

Create a IncrementalDecoder instance.

The IncrementalDecoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
for a list of possible values.

Reimplemented in encodings.bz2_codec.IncrementalDecoder, encodings.zlib_codec.IncrementalDecoder, encodings.base64_codec.IncrementalDecoder, and encodings.hex_codec.IncrementalDecoder.

Definition at line 246 of file codecs.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: