Vips.Sbuf¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w |
Source to load from |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
chars_in_buffer |
r |
||
input_buffer |
r |
||
line |
r |
||
parent_object |
r |
||
read_point |
r |
||
source |
r |
Class Details¶
- class Vips.Sbuf(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A [class`Sbuf`] provides a buffered reading interface for a [class`Source`].
You can fetch lines of text, skip whitespace, and so on.
It is useful for implementing things like CSV readers, for example.
- classmethod new_from_source(source)¶
- Parameters:
source (
Vips.Source) – source to operate on- Returns:
a new [class`Sbuf`]
- Return type:
Create a [class`Sbuf`] wrapping a source.
- get_line()¶
- Returns:
the next line of text, or
NULLon EOF or read error.- Return type:
Fetch the next line of text from self and return it. The end of line character (or characters, for DOS files) are removed, and the string is terminated with a null (
\0character).Returns
NULLon end of file or read error.If the line is longer than some arbitrary (but large) limit, it is truncated. If you need to be able to read very long lines, use the slower [method`Sbuf`.get_line_copy].
The return value is owned by self and must not be freed. It is valid until the next get call to self.
- get_line_copy()¶
- Returns:
the next line of text, or
NULLon EOF or read error.- Return type:
Fetch the next line of text from self and return it. The end of line character (or characters, for DOS files) are removed, and the string is terminated with a null (
\0character).The return result must be freed with [func`GLib`.free].
This is slower than [method`Sbuf`.get_line], but can work with lines of any length.
- get_non_whitespace()¶
- Returns:
the next block of non-whitespace, or
NULLon EOF or read error.- Return type:
Fetch the next chunk of non-whitespace text from the source, and null-terminate it.
After this, the next getc will be the first
strof the next block of whitespace (or EOF).If the first getc is whitespace, stop instantly and return the empty string.
If the item is longer than some arbitrary (but large) limit, it is truncated.
The return value is owned by self and must not be freed. It is valid until the next get call to self.
- getc()¶
-
Fetch the next character from the source.
If you can, use the macro [funcSBUF_GETC] instead for speed.
- require(require)¶
- Parameters:
require (
int) – make sure we have at least this many chars available- Returns:
0 on success, -1 on error or EOF.
- Return type:
Make sure there are at least require bytes of readahead available.
- skip_whitespace()¶
- Returns:
0 on success, or -1 on EOF.
- Return type:
After this, the next getc will be the first
strof the next block of non-whitespace (or EOF).Also skip comments, ie. from any ‘#’ character to the end of the line.
- unbuffer()¶
Discard the input buffer and reset the read point. You must call this before using read or seek on the underlying [class`Source`] class.
- ungetc()¶
The opposite of [method`Sbuf`.getc]: undo the previous getc.
unget more than one character is undefined. Unget at the start of the file does nothing.
If you can, use the macro [funcSBUF_UNGETC] instead for speed.
Property Details¶
- Vips.Sbuf.props.input¶
- Name:
input- Type:
- Default Value:
- Flags:
Source to load from