gmio_core: rename gmio_stream_pos -> gmio_streampos
This commit is contained in:
parent
fb81b25407
commit
a2c071369b
@ -74,7 +74,7 @@ enum { STL_TRIANGLE_ARRAY_SIZE = 512 };
|
|||||||
struct stl_readwrite_conv
|
struct stl_readwrite_conv
|
||||||
{
|
{
|
||||||
struct gmio_rwargs rwargs;
|
struct gmio_rwargs rwargs;
|
||||||
struct gmio_stream_pos out_stream_pos_begin;
|
struct gmio_streampos out_stream_pos_begin;
|
||||||
enum gmio_stl_format in_format;
|
enum gmio_stl_format in_format;
|
||||||
enum gmio_stl_format out_format;
|
enum gmio_stl_format out_format;
|
||||||
struct gmio_stl_triangle triangle_array[STL_TRIANGLE_ARRAY_SIZE];
|
struct gmio_stl_triangle triangle_array[STL_TRIANGLE_ARRAY_SIZE];
|
||||||
|
@ -62,7 +62,7 @@ GMIO_INLINE gmio_streamsize_t gmio_stream_size(struct gmio_stream* stream)
|
|||||||
|
|
||||||
/*! Safe and convenient function for gmio_stream::func_get_pos() */
|
/*! Safe and convenient function for gmio_stream::func_get_pos() */
|
||||||
GMIO_INLINE int gmio_stream_get_pos(
|
GMIO_INLINE int gmio_stream_get_pos(
|
||||||
struct gmio_stream* stream, struct gmio_stream_pos* pos)
|
struct gmio_stream* stream, struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
if (stream != NULL && stream->func_get_pos != NULL)
|
if (stream != NULL && stream->func_get_pos != NULL)
|
||||||
return stream->func_get_pos(stream->cookie, pos);
|
return stream->func_get_pos(stream->cookie, pos);
|
||||||
@ -71,7 +71,7 @@ GMIO_INLINE int gmio_stream_get_pos(
|
|||||||
|
|
||||||
/*! Safe and convenient function for gmio_stream::func_set_pos() */
|
/*! Safe and convenient function for gmio_stream::func_set_pos() */
|
||||||
GMIO_INLINE int gmio_stream_set_pos(
|
GMIO_INLINE int gmio_stream_set_pos(
|
||||||
struct gmio_stream* stream, const struct gmio_stream_pos* pos)
|
struct gmio_stream* stream, const struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
if (stream != NULL && stream->func_set_pos != NULL)
|
if (stream != NULL && stream->func_set_pos != NULL)
|
||||||
return stream->func_set_pos(stream->cookie, pos);
|
return stream->func_set_pos(stream->cookie, pos);
|
||||||
|
@ -129,7 +129,7 @@ static gmio_streamsize_t gmio_stream_stdio_size(void* cookie)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_stdio_get_pos(void* cookie, struct gmio_stream_pos* pos)
|
static int gmio_stream_stdio_get_pos(void* cookie, struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
fpos_t fpos;
|
fpos_t fpos;
|
||||||
int res = fgetpos((FILE*)cookie, &fpos);
|
int res = fgetpos((FILE*)cookie, &fpos);
|
||||||
@ -137,7 +137,7 @@ static int gmio_stream_stdio_get_pos(void* cookie, struct gmio_stream_pos* pos)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_stdio_set_pos(void* cookie, const struct gmio_stream_pos* pos)
|
static int gmio_stream_stdio_set_pos(void* cookie, const struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
fpos_t fpos;
|
fpos_t fpos;
|
||||||
memcpy(&fpos, &pos->cookie[0], sizeof(fpos_t));
|
memcpy(&fpos, &pos->cookie[0], sizeof(fpos_t));
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define GMIO_STREAM_H
|
#define GMIO_STREAM_H
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "stream_pos.h"
|
#include "streampos.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef GMIO_HAVE_INT64_TYPE
|
#ifdef GMIO_HAVE_INT64_TYPE
|
||||||
@ -108,7 +108,7 @@ struct gmio_stream
|
|||||||
* \retval 0 on success
|
* \retval 0 on success
|
||||||
* \retval !=0 on error
|
* \retval !=0 on error
|
||||||
*/
|
*/
|
||||||
int (*func_get_pos)(void* cookie, struct gmio_stream_pos* pos);
|
int (*func_get_pos)(void* cookie, struct gmio_streampos* pos);
|
||||||
|
|
||||||
/*! Pointer on a function that restores the current position in the stream
|
/*! Pointer on a function that restores the current position in the stream
|
||||||
* to \p pos
|
* to \p pos
|
||||||
@ -116,7 +116,7 @@ struct gmio_stream
|
|||||||
* \retval 0 on success
|
* \retval 0 on success
|
||||||
* \retval !=0 on error
|
* \retval !=0 on error
|
||||||
*/
|
*/
|
||||||
int (*func_set_pos)(void* cookie, const struct gmio_stream_pos* pos);
|
int (*func_set_pos)(void* cookie, const struct gmio_streampos* pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "stream_pos.h"
|
#include "streampos.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct gmio_stream_pos gmio_stream_pos_null()
|
struct gmio_streampos gmio_streampos_null()
|
||||||
{
|
{
|
||||||
struct gmio_stream_pos pos = {0};
|
struct gmio_streampos pos = {0};
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
@ -13,42 +13,42 @@
|
|||||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/*! \file stream_pos.h
|
/*! \file streampos.h
|
||||||
* Declaration of gmio_stream_pos and utility functions
|
* Declaration of gmio_streampos and utility functions
|
||||||
*
|
*
|
||||||
* \addtogroup gmio_core
|
* \addtogroup gmio_core
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GMIO_STREAM_POS_H
|
#ifndef GMIO_STREAMPOS_H
|
||||||
#define GMIO_STREAM_POS_H
|
#define GMIO_STREAMPOS_H
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
/*! Size of the byte array gmio_stream_pos::cookie */
|
/*! Size of the byte array gmio_streampos::cookie */
|
||||||
enum { GMIO_STREAM_POS_COOKIE_SIZE = 32 /* bytes */ };
|
enum { GMIO_STREAMPOS_COOKIE_SIZE = 32 /* bytes */ };
|
||||||
|
|
||||||
/*! Specifies a position within a stream
|
/*! Specifies a position within a stream
|
||||||
*
|
*
|
||||||
* The information in gmio_stream_pos objects is usually filled by a call to
|
* The information in gmio_streampos objects is usually filled by a call to
|
||||||
* gmio_stream::func_get_pos(), which takes a pointer to an object of this type
|
* gmio_stream::func_get_pos(), which takes a pointer to an object of this type
|
||||||
* as argument.
|
* as argument.
|
||||||
*
|
*
|
||||||
* The content of a gmio_stream_pos object is not meant to be read directly,
|
* The content of a gmio_streampos object is not meant to be read directly,
|
||||||
* but only to be used as an argument in a call to gmio_stream::func_set_pos()
|
* but only to be used as an argument in a call to gmio_stream::func_set_pos()
|
||||||
*/
|
*/
|
||||||
struct gmio_stream_pos
|
struct gmio_streampos
|
||||||
{
|
{
|
||||||
/*! Stores the actual(concrete) stream position object */
|
/*! Stores the actual(concrete) stream position object */
|
||||||
uint8_t cookie[GMIO_STREAM_POS_COOKIE_SIZE];
|
uint8_t cookie[GMIO_STREAMPOS_COOKIE_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
GMIO_C_LINKAGE_BEGIN
|
GMIO_C_LINKAGE_BEGIN
|
||||||
|
|
||||||
/*! Returns a null stream position */
|
/*! Returns a null stream position */
|
||||||
GMIO_LIB_EXPORT struct gmio_stream_pos gmio_stream_pos_null();
|
GMIO_LIB_EXPORT struct gmio_streampos gmio_streampos_null();
|
||||||
|
|
||||||
GMIO_C_LINKAGE_END
|
GMIO_C_LINKAGE_END
|
||||||
|
|
||||||
#endif /* GMIO_STREAM_POS_H */
|
#endif /* GMIO_STREAMPOS_H */
|
||||||
/*! @} */
|
/*! @} */
|
@ -38,7 +38,7 @@ enum gmio_stl_format gmio_stl_get_format(struct gmio_stream *stream)
|
|||||||
{
|
{
|
||||||
char fixed_buffer[GMIO_FIXED_BUFFER_SIZE] = {0};
|
char fixed_buffer[GMIO_FIXED_BUFFER_SIZE] = {0};
|
||||||
size_t read_size = 0;
|
size_t read_size = 0;
|
||||||
struct gmio_stream_pos stream_start_pos = gmio_stream_pos_null();
|
struct gmio_streampos stream_start_pos = gmio_streampos_null();
|
||||||
|
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return GMIO_STL_FORMAT_UNKNOWN;
|
return GMIO_STL_FORMAT_UNKNOWN;
|
||||||
|
@ -111,12 +111,12 @@ gmio_streamsize_t ostream_cpp_size(void* cookie)
|
|||||||
return end_pos - begin_pos;
|
return end_pos - begin_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
GMIO_INLINE void copy_cpp_streampos(gmio_stream_pos* pos, std::streampos spos)
|
GMIO_INLINE void copy_cpp_streampos(gmio_streampos* pos, std::streampos spos)
|
||||||
{
|
{
|
||||||
std::memcpy(&pos->cookie[0], &spos, sizeof(std::streampos));
|
std::memcpy(&pos->cookie[0], &spos, sizeof(std::streampos));
|
||||||
}
|
}
|
||||||
|
|
||||||
GMIO_INLINE std::streampos to_cpp_streampos(const gmio_stream_pos* pos)
|
GMIO_INLINE std::streampos to_cpp_streampos(const gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
std::streampos spos;
|
std::streampos spos;
|
||||||
std::memcpy(&spos, &pos->cookie[0], sizeof(std::streampos));
|
std::memcpy(&spos, &pos->cookie[0], sizeof(std::streampos));
|
||||||
@ -124,28 +124,28 @@ GMIO_INLINE std::streampos to_cpp_streampos(const gmio_stream_pos* pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename STREAM>
|
template<typename STREAM>
|
||||||
int istream_cpp_get_pos(void* cookie, gmio_stream_pos* pos)
|
int istream_cpp_get_pos(void* cookie, gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
copy_cpp_streampos(pos, static_cast<STREAM*>(cookie)->tellg());
|
copy_cpp_streampos(pos, static_cast<STREAM*>(cookie)->tellg());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename STREAM>
|
template<typename STREAM>
|
||||||
int istream_cpp_set_pos(void* cookie, const gmio_stream_pos* pos)
|
int istream_cpp_set_pos(void* cookie, const gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
static_cast<STREAM*>(cookie)->seekg(to_cpp_streampos(pos));
|
static_cast<STREAM*>(cookie)->seekg(to_cpp_streampos(pos));
|
||||||
return 0; // TODO: return error code
|
return 0; // TODO: return error code
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename STREAM>
|
template<typename STREAM>
|
||||||
int ostream_cpp_get_pos(void* cookie, gmio_stream_pos* pos)
|
int ostream_cpp_get_pos(void* cookie, gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
copy_cpp_streampos(pos, static_cast<STREAM*>(cookie)->tellp());
|
copy_cpp_streampos(pos, static_cast<STREAM*>(cookie)->tellp());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename STREAM>
|
template<typename STREAM>
|
||||||
static int ostream_cpp_set_pos(void* cookie, const gmio_stream_pos* pos)
|
static int ostream_cpp_set_pos(void* cookie, const gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
static_cast<STREAM*>(cookie)->seekp(to_cpp_streampos(pos));
|
static_cast<STREAM*>(cookie)->seekp(to_cpp_streampos(pos));
|
||||||
return 0; // TODO: return error code
|
return 0; // TODO: return error code
|
||||||
|
@ -64,7 +64,7 @@ static gmio_streamsize_t gmio_stream_qiodevice_size(void* cookie)
|
|||||||
return device->size();
|
return device->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_qiodevice_get_pos(void* cookie, struct gmio_stream_pos* pos)
|
static int gmio_stream_qiodevice_get_pos(void* cookie, struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
QIODevice* device = static_cast<QIODevice*>(cookie);
|
QIODevice* device = static_cast<QIODevice*>(cookie);
|
||||||
qint64 qpos = device->pos();
|
qint64 qpos = device->pos();
|
||||||
@ -73,7 +73,7 @@ static int gmio_stream_qiodevice_get_pos(void* cookie, struct gmio_stream_pos* p
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_qiodevice_set_pos(
|
static int gmio_stream_qiodevice_set_pos(
|
||||||
void* cookie, const struct gmio_stream_pos* pos)
|
void* cookie, const struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
QIODevice* device = static_cast<QIODevice*>(cookie);
|
QIODevice* device = static_cast<QIODevice*>(cookie);
|
||||||
qint64 qpos;
|
qint64 qpos;
|
||||||
|
@ -84,14 +84,14 @@ static gmio_streamsize_t gmio_stream_buffer_size(void* cookie)
|
|||||||
return buff->len;
|
return buff->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_buffer_get_pos(void* cookie, struct gmio_stream_pos* pos)
|
static int gmio_stream_buffer_get_pos(void* cookie, struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie;
|
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie;
|
||||||
memcpy(&pos->cookie[0], &buff->pos, sizeof(size_t));
|
memcpy(&pos->cookie[0], &buff->pos, sizeof(size_t));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_buffer_set_pos(void* cookie, const struct gmio_stream_pos* pos)
|
static int gmio_stream_buffer_set_pos(void* cookie, const struct gmio_streampos* pos)
|
||||||
{
|
{
|
||||||
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie;
|
gmio_ro_buffer_t* buff = (gmio_ro_buffer_t*)cookie;
|
||||||
memcpy(&buff->pos, &pos->cookie[0], sizeof(size_t));
|
memcpy(&buff->pos, &pos->cookie[0], sizeof(size_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user