2015-03-13 18:04:14 +08:00
|
|
|
/****************************************************************************
|
2015-05-28 15:40:24 +08:00
|
|
|
** gmio
|
2015-05-01 00:19:45 +08:00
|
|
|
** Copyright Fougue (2 Mar. 2015)
|
2015-07-13 17:42:03 +08:00
|
|
|
** contact@fougue.pro
|
2015-03-13 18:04:14 +08:00
|
|
|
**
|
|
|
|
** This software is a reusable library whose purpose is to provide complete
|
|
|
|
** I/O support for various CAD file formats (eg. STL)
|
|
|
|
**
|
|
|
|
** This software is governed by the CeCILL-B license under French law and
|
|
|
|
** abiding by the rules of distribution of free software. You can use,
|
|
|
|
** modify and/ or redistribute the software under the terms of the CeCILL-B
|
|
|
|
** license as circulated by CEA, CNRS and INRIA at the following URL
|
2015-03-30 15:05:25 +08:00
|
|
|
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
2015-03-13 18:04:14 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-03-31 16:10:26 +08:00
|
|
|
#ifndef GMIO_INTERNAL_HELPER_STREAM_H
|
|
|
|
#define GMIO_INTERNAL_HELPER_STREAM_H
|
2015-03-13 18:04:14 +08:00
|
|
|
|
|
|
|
#include "../stream.h"
|
|
|
|
|
2015-07-10 17:33:05 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_at_end() */
|
2015-03-31 16:10:26 +08:00
|
|
|
GMIO_INLINE gmio_bool_t gmio_stream_at_end(gmio_stream_t* stream)
|
2015-03-13 18:04:14 +08:00
|
|
|
{
|
2015-07-10 17:33:05 +08:00
|
|
|
if (stream != NULL && stream->func_at_end != NULL)
|
|
|
|
return stream->func_at_end(stream->cookie);
|
2015-03-13 18:04:14 +08:00
|
|
|
return GMIO_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-07-10 17:33:05 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_error() */
|
2015-03-31 16:10:26 +08:00
|
|
|
GMIO_INLINE int gmio_stream_error(gmio_stream_t* stream)
|
2015-03-13 18:04:14 +08:00
|
|
|
{
|
2015-07-10 17:33:05 +08:00
|
|
|
if (stream != NULL && stream->func_error != NULL)
|
|
|
|
return stream->func_error(stream->cookie);
|
2015-03-13 18:04:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-10 17:33:05 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_read() */
|
2015-03-31 16:10:26 +08:00
|
|
|
GMIO_INLINE size_t gmio_stream_read(
|
2015-03-13 18:04:14 +08:00
|
|
|
gmio_stream_t* stream, void *ptr, size_t size, size_t count)
|
|
|
|
{
|
2015-07-10 17:33:05 +08:00
|
|
|
if (stream != NULL && stream->func_read != NULL)
|
|
|
|
return stream->func_read(stream->cookie, ptr, size, count);
|
2015-03-13 18:04:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-10 17:33:05 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_write() */
|
2015-03-31 16:10:26 +08:00
|
|
|
GMIO_INLINE size_t gmio_stream_write(
|
2015-03-13 18:04:14 +08:00
|
|
|
gmio_stream_t* stream, const void *ptr, size_t size, size_t count)
|
|
|
|
{
|
2015-07-10 17:33:05 +08:00
|
|
|
if (stream != NULL && stream->func_write != NULL)
|
|
|
|
return stream->func_write(stream->cookie, ptr, size, count);
|
2015-03-13 18:04:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2015-03-24 01:15:31 +08:00
|
|
|
|
2015-07-10 17:33:05 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_size() */
|
2015-11-06 20:43:03 +08:00
|
|
|
GMIO_INLINE gmio_streamsize_t gmio_stream_size(gmio_stream_t* stream)
|
2015-03-24 01:15:31 +08:00
|
|
|
{
|
2015-07-10 17:33:05 +08:00
|
|
|
if (stream != NULL && stream->func_size != NULL)
|
|
|
|
return stream->func_size(stream->cookie);
|
2015-03-24 01:15:31 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-18 20:33:23 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_get_pos() */
|
|
|
|
GMIO_INLINE int gmio_stream_get_pos(
|
|
|
|
gmio_stream_t* stream, gmio_stream_pos_t* pos)
|
2015-03-24 01:15:31 +08:00
|
|
|
{
|
2015-09-18 20:33:23 +08:00
|
|
|
if (stream != NULL && stream->func_get_pos != NULL)
|
|
|
|
return stream->func_get_pos(stream->cookie, pos);
|
|
|
|
return -1;
|
2015-03-24 01:15:31 +08:00
|
|
|
}
|
2015-03-31 16:10:26 +08:00
|
|
|
|
2015-09-18 20:33:23 +08:00
|
|
|
/*! Safe and convenient function for gmio_stream::func_set_pos() */
|
|
|
|
GMIO_INLINE int gmio_stream_set_pos(
|
|
|
|
gmio_stream_t* stream, const gmio_stream_pos_t* pos)
|
|
|
|
{
|
|
|
|
if (stream != NULL && stream->func_set_pos != NULL)
|
|
|
|
return stream->func_set_pos(stream->cookie, pos);
|
|
|
|
return -1;
|
|
|
|
}
|
2015-03-31 16:10:26 +08:00
|
|
|
#endif /* GMIO_INTERNAL_HELPER_STREAM_H */
|