gmio_core: add gmio_stringstream() constructor

This commit is contained in:
Hugues Delorme 2016-01-12 16:29:31 +01:00
parent b0803b0a7b
commit 38bfdb6e72
2 changed files with 19 additions and 1 deletions

View File

@ -17,6 +17,16 @@
#include "helper_stream.h" #include "helper_stream.h"
struct gmio_stringstream gmio_stringstream(
const struct gmio_stream stream, const struct gmio_string strbuff)
{
struct gmio_stringstream sstream = {0};
sstream.stream = stream;
sstream.strbuff = strbuff;
gmio_stringstream_init(&sstream);
return sstream;
}
void gmio_stringstream_init(struct gmio_stringstream *sstream) void gmio_stringstream_init(struct gmio_stringstream *sstream)
{ {
/* Trick: declaring the buffer exhausted will actually trigger the first /* Trick: declaring the buffer exhausted will actually trigger the first

View File

@ -38,7 +38,15 @@ struct gmio_stringstream
void* cookie, const struct gmio_string* strbuff); void* cookie, const struct gmio_string* strbuff);
}; };
/*! Initializes iterator */ /*! Returns an initialized gmio_stringstream object */
struct gmio_stringstream gmio_stringstream(
const struct gmio_stream stream,
const struct gmio_string strbuff);
/*! Initializes position indicator
*
* TODO: rename to gmio_stringstream_initpos()
*/
void gmio_stringstream_init(struct gmio_stringstream* sstream); void gmio_stringstream_init(struct gmio_stringstream* sstream);
/*! Returns the char where the iterator is currently pointing at */ /*! Returns the char where the iterator is currently pointing at */