class CString(Type):
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 | to_bytes |
Build a byte buffer from a value of this type. |
| Method | is_context_sensitive |
Whether the context argument needed by some methods actually has an effect. |
Initialize a new type of CString.
| Parameters | encoding | The encoding of the string. Must be a member of the Encoding enum. |
| max_size | The 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_count | The maximum number of characters to attempt to read. | |
| Raises | ValueError | if an encoding which is not a valid encoding is passed |
| ValueError | if none of max_size and max_character_count are specified | |
| ValueError | if both max_size and max_character_count are specified | |
| ValueError | if max_size is specified but is not a multiple of the character size | |
| ValueError | if max_size or max_character_count are specified, but negative |
reven2.types._type.Type._construct_typeReturn the underlying construct instance
Property: The maximum number of bytes to attempt to read.
| Returns | An integer. | |
Property: The maximum number of characters to attempt to read.
| Returns | An integer. | |
reven2.types._type.Type.parseParses the value of a string from a raw buffer.
| Parameters | buf | Undocumented |
| context | The context object. See package documentation. | |
| Returns | A formatted string. | |
| Raises | UnicodeDecodeError | if decoding in the specified encoding fails |