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'\x00' for Ascii and Utf8, but b'\x00\x00' for Utf16, and b'\x00\x00\x00\x00' for Utf32

Method __init__ Initialize a new type of CString.
Method max_size Property: The maximum number of bytes to attempt to read.
Method 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.
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
def _construct_type(self, context=None):

Return the underlying construct instance

@property
def max_size(self):

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

Information

ReturnsAn integer.
@property
def max_character_count(self):

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

ParameterscontextThe 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 at 2020-12-14 16:47:40.