eccLib 1.1.0
Python library for bioinformatics written in C
Loading...
Searching...
No Matches
reader.h
Go to the documentation of this file.
1
6#ifndef READER_H
7#define READER_H
8
9#include "common.h"
10#include <Python.h>
11#include <stdbool.h>
12
33struct reader {
34 PyObject_HEAD union {
42 FILE *file;
47 PyObject *fileObj;
48 };
53 char *buff;
57 size_t buffSize;
58};
59
65void free_reader(struct reader *self);
66
71struct file {
72 PyObject_HEAD
76 const char *filename;
82 FILE *file;
83};
84
93PyObject *file_enter(struct file *self, PyObject *args);
94
102PyObject *file_exit(struct file *self, PyObject *args, PyObject *kwds);
103
107#define BUFFSIZE (1024)
108
118bool initialize_reader(const struct file *self, struct reader *reader);
119
125typedef struct {
136 PyObject *obj;
137} line_out;
138
149line_out next_line(struct reader *restrict self,
150 bool (*valid)(const char *, size_t));
151
152#endif
Contains common functions and structs used by the other modules.
void free_reader(struct reader *self)
Free the reader object.
Definition reader.c:41
line_out next_line(struct reader *restrict self, bool(*valid)(const char *, size_t))
Fetches the next line from the reader object.
Definition reader.c:83
PyObject * file_enter(struct file *self, PyObject *args)
enter method for file objects
Definition reader.c:11
PyObject * file_exit(struct file *self, PyObject *args, PyObject *kwds)
exit method for file objects
Definition reader.c:26
bool initialize_reader(const struct file *self, struct reader *reader)
Initialize the reader object based on the file object.
Definition reader.c:50
File base struct.
Definition reader.h:71
FILE * file
The FILE object.
Definition reader.h:82
const char * filename
The name of the file.
Definition reader.h:76
A simple that hold a string, and potentially it's Python parent object.
Definition reader.h:125
PyObject * obj
The Python object owning the token buffer.
Definition reader.h:136
occurrence_t line
The string token.
Definition reader.h:131
An occurrence of a token in a string.
Definition common.h:30
Reader base struct.
Definition reader.h:33
PyObject * fileObj
The file object that is being read using PyFile_GetLine.
Definition reader.h:47
FILE * file
The FILE that is being read.
Definition reader.h:42
char * buff
The buffer for getline to write to.
Definition reader.h:53
size_t buffSize
The size of the buff, garbage if buff is NULL.
Definition reader.h:57