vg
tools for working with variation graphs
|
#include <protobuf_iterator.hpp>
Public Member Functions | |
ProtobufIterator (istream &in) | |
Constructor. More... | |
ProtobufIterator ()=default | |
Default constructor for an end iterator. More... | |
T & | operator* () |
const T & | operator* () const |
const ProtobufIterator< T > & | operator++ () |
In-place pre-increment to advance the iterator. More... | |
bool | operator== (const ProtobufIterator< T > &other) const |
bool | operator!= (const ProtobufIterator< T > &other) const |
bool | has_current () const |
Return true if dereferencing the iterator will produce a valid value, and false otherwise. More... | |
void | advance () |
T | take () |
Take the current item, which must exist, and advance the iterator to the next one. More... | |
int64_t | tell_group () const |
bool | seek_group (int64_t virtual_offset) |
Static Public Member Functions | |
static pair< ProtobufIterator< T >, ProtobufIterator< T > > | range (istream &in) |
Returns iterators that act like begin() and end() for a stream containing messages. More... | |
static bool | parse_from_string (T &dest, const string &data) |
Private Member Functions | |
void | fill_value () |
Private Attributes | |
MessageIterator | message_it |
Wrap a MessageIterator and just do Protobuf parsing on top of that. More... | |
T | value |
We always maintain a parsed version of the current message. More... | |
Refactored io::for_each function that follows the unidirectional iterator interface. Also supports seeking and telling at the group level in bgzip files. Cannot be copied, but can be moved.
vg::io::ProtobufIterator< T >::ProtobufIterator | ( | istream & | in | ) |
|
default |
Default constructor for an end iterator.
auto vg::io::ProtobufIterator< T >::advance |
Advance the iterator to the next message, or the end if this was the last message. Basically the same as ++.
|
private |
Fill in value, if message_it has a value of an appropriate tag. Scans through tag-only groups.
auto vg::io::ProtobufIterator< T >::has_current |
Return true if dereferencing the iterator will produce a valid value, and false otherwise.
auto vg::io::ProtobufIterator< T >::operator!= | ( | const ProtobufIterator< T > & | other | ) | const |
Check if two iterators are not equal. Since you can only have one on a stream, this only has two equality classes: iterators that have hit the end, and iterators that haven't.
auto vg::io::ProtobufIterator< T >::operator* |
Get the current item. Caller may move it away. Only legal to call if we are not an end iterator.
const T& vg::io::ProtobufIterator< T >::operator* | ( | ) | const |
Get the current item when we are const. Only legal to call if we are not an end iterator.
auto vg::io::ProtobufIterator< T >::operator++ |
In-place pre-increment to advance the iterator.
auto vg::io::ProtobufIterator< T >::operator== | ( | const ProtobufIterator< T > & | other | ) | const |
Check if two iterators are equal. Since you can only have one on a stream, this only has two equality classes: iterators that have hit the end, and iterators that haven't.
|
static |
Parse a Protobuf message that may be very large from a string. Use this instead of ParseFromString on the message itself.
Returns the result of the parse attempt (i.e. whether it succeeded).
|
static |
Returns iterators that act like begin() and end() for a stream containing messages.
auto vg::io::ProtobufIterator< T >::seek_group | ( | int64_t | virtual_offset | ) |
Seek to the given virtual offset and start reading the group that is there. The next value produced will be the first value in that group (or in the next group that actually has values). If already at the start of the group at the given virtual offset, does nothing. Return false if seeking is unsupported or the seek fails.
auto vg::io::ProtobufIterator< T >::take |
Take the current item, which must exist, and advance the iterator to the next one.
auto vg::io::ProtobufIterator< T >::tell_group |
Return the virtual offset of the group being currently read (i.e. the group to which the current message belongs), to seek back to. You can't seek back to the current message, just to the start of the group. Returns -1 instead if the underlying file doesn't support seek/tell. Returns the past-the-end virtual offset of the file if EOF is reached.
|
private |
Wrap a MessageIterator and just do Protobuf parsing on top of that.
|
private |
We always maintain a parsed version of the current message.