diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-04-22 19:33:09 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-04-22 19:33:09 -0700 |
commit | 18383b973877f4c30c878414a51c0b44ea5dafe4 (patch) | |
tree | 811e7ccbdb9b0ba15b0ef95c8ab36502097abab2 /include | |
parent | 9fb0a22dcb1ae04a1007316497fe6d11b91d8183 (diff) |
feat: added generic interfaces for I/O
Diffstat (limited to 'include')
-rw-r--r-- | include/libbio.h | 9 | ||||
-rw-r--r-- | include/libn.h | 42 |
2 files changed, 51 insertions, 0 deletions
diff --git a/include/libbio.h b/include/libbio.h index 58540d4..9f54015 100644 --- a/include/libbio.h +++ b/include/libbio.h @@ -24,8 +24,17 @@ typedef struct bio·Tree bio·Node *root; } bio·Tree; +/* newick i/o */ bio·Tree bio·readnewick(Stream *file, mem·Allocator heap); error bio·writenewick(bio·Tree tree, Stream *out); // ----------------------------------------------------------------------- // Sequences + +typedef struct bio·FastaReader bio·FastaReader; + +/* fasta/q i/o */ +bio·Seq *bio·newfastareader(Stream *file, mem·Allocator heap); +bio·Seq *bio·readfasta(bio·FastaParser *p); +error bio·writefasta(bio·Seq *seq, Stream *out); + diff --git a/include/libn.h b/include/libn.h index c8d510f..67d131d 100644 --- a/include/libn.h +++ b/include/libn.h @@ -107,6 +107,48 @@ vlong io·write(Stream *s, int sz, int n, void *buf); int io·flush(Stream *s); int io·seek(Stream *s, long off, enum SeekPos origin); +/* Generic I/O interfaces */ + +typedef struct io·Reader +{ + int (*read)(int n, void *buf); +}; + +typedef struct io·Peeker +{ + byte (*get)(void); + error (*unget)(byte); +}; + +typedef struct io·FullReader +{ + io·Reader; + io·Peeker; +} io·FullReader; + +typedef struct io·Writer +{ + int (*write)(int n, void *buf); +} io·Writer; + +typedef struct io·Putter +{ + error (*put)(byte); + int (*putstr)(string); +} io·Putter; + +typedef struct io·FullWriter +{ + io·Writer; + io·Putter; +} io·FullWriter; + +typedef struct io·ReadWriter +{ + io·Reader; + io·Writer; +} io·ReadWriter; + // ----------------------------------------------------------------------------- // Buffered I/O |