class documentation

class CString(Type):

View In Hierarchy

A type constructor for NUL-terminated strings ("C-like" strings).

When reading data as instances of this type, reading will continue until it reaches a NUL character or a fixed maximum character count has been read.

NOTE: the NUL character is b'' for Ascii and Utf8, but b'' for Utf16, and b'' for Utf32

Method __init__ Initialize a new type of CString.
Property max_size Property: The maximum number of bytes to attempt to read.
Property max_character_count Property: The maximum number of characters to attempt to read.
Method size_bytes The minimal number of bytes necessary to hold an instance of this CString type. Since at most max_size bytes are read (even in the absence of a NUL terminator), it is equal to max_size.
Method parse Parses the value of a string from a raw buffer.
Instance Variable _construct Undocumented
Instance Variable _max_size Undocumented
Instance Variable _encoding Undocumented
Method _construct_type Return the underlying construct instance
Static Method _validate_arguments Undocumented

Inherited from Type:

Method is_context_sensitive Whether the context argument needed by some methods actually has an effect.
def __init__(self, encoding=Encoding.Utf8, max_size=None, max_character_count=None):

Initialize a new type of CString.

Information

ParametersencodingThe encoding of the string. Must be a member of the Encoding enum.
max_sizeThe maximum number of bytes to attempt to read. Must be a multiple of the size of one character (1 for Ascii and Utf8, but 2 and 4 for Utf16 and Utf32)
max_character_countThe maximum number of characters to attempt to read.
RaisesValueErrorif an encoding which is not a valid encoding is passed
ValueErrorif none of max_size and max_character_count are specified
ValueErrorif both max_size and max_character_count are specified
ValueErrorif max_size is specified but is not a multiple of the character size
ValueErrorif max_size or max_character_count are specified, but negative
_construct =

Undocumented

_max_size =

Undocumented

_encoding =

Undocumented

def _construct_type(self, context=None):

Return the underlying construct instance

@property
max_size =

Property: The maximum number of bytes to attempt to read.

Information

ReturnsAn integer.
@property
max_character_count =

Property: The maximum number of characters to attempt to read.

Information

ReturnsAn integer.
def size_bytes(self, context=None):

The minimal number of bytes necessary to hold an instance of this CString type. Since at most max_size bytes are read (even in the absence of a NUL terminator), it is equal to max_size.

Information

ReturnsAn integer.
def parse(self, buf, context=None):

Parses the value of a string from a raw buffer.

Information

ParametersbufUndocumented
contextThe context object. See package documentation.
ReturnsA formatted string.
RaisesUnicodeDecodeErrorif decoding in the specified encoding fails
@staticmethod
def _validate_arguments(encoding, max_size, max_character_count):

Undocumented

API Documentation for reven2, generated by pydoctor 21.2.2 at 2021-07-01 16:38:17.