Skip to content

Commit

Permalink
Add datareader_size to C api
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisspyB committed Nov 18, 2024
1 parent d2e36b5 commit 1b962e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/fdb5/api/fdb_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ struct fdb_datareader_t {
ASSERT(dh_);
return dh_->read(buf, length);
}
long size() {
ASSERT(dh_);
return dh_->size();
}
void set(DataHandle* dh) {
if (dh_)
delete dh_;
Expand Down Expand Up @@ -554,6 +558,12 @@ int fdb_datareader_read(fdb_datareader_t* dr, void *buf, long count, long* read)
*read = dr->read(buf, count);
});
}
int fdb_datareader_size(fdb_datareader_t* dr, long* size) {
return wrapApiFunction([=]{
ASSERT(dr);
*size = dr->size();
});
}
int fdb_delete_datareader(fdb_datareader_t* dr) {
return wrapApiFunction([dr]{
ASSERT(dr);
Expand Down
7 changes: 7 additions & 0 deletions src/fdb5/api/fdb_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ int fdb_datareader_seek(fdb_datareader_t* dr, long pos);
*/
int fdb_datareader_skip(fdb_datareader_t* dr, long count);

/** Return size of internal datahandle in bytes.
* \param dr DataReader instance
* \param size Size of the DataReader
* \returns Return code (#FdbErrorValues)
*/
int fdb_datareader_size(fdb_datareader_t* dr, long* size);

/** Read binary data from a DataReader to a given memory buffer.
* \param dr DataReader instance
* \param buf Pointer of the target memory buffer.
Expand Down

0 comments on commit 1b962e5

Please sign in to comment.