InputStream: move typedef offset_type to Offset.hxx
Reduce header dependencies.
This commit is contained in:
parent
d87cf5146e
commit
bb472206de
@ -1090,6 +1090,7 @@ libinput_a_SOURCES = \
|
|||||||
src/input/Init.cxx src/input/Init.hxx \
|
src/input/Init.cxx src/input/Init.hxx \
|
||||||
src/input/Registry.cxx src/input/Registry.hxx \
|
src/input/Registry.cxx src/input/Registry.hxx \
|
||||||
src/input/Open.cxx \
|
src/input/Open.cxx \
|
||||||
|
src/input/Offset.hxx \
|
||||||
src/input/InputStream.cxx src/input/InputStream.hxx \
|
src/input/InputStream.cxx src/input/InputStream.hxx \
|
||||||
src/input/InputPlugin.hxx \
|
src/input/InputPlugin.hxx \
|
||||||
src/input/TextInputStream.cxx src/input/TextInputStream.hxx \
|
src/input/TextInputStream.cxx src/input/TextInputStream.hxx \
|
||||||
|
@ -114,7 +114,7 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset _offset,
|
|||||||
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
|
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
|
||||||
InputStream &is = afis.is;
|
InputStream &is = afis.is;
|
||||||
|
|
||||||
InputStream::offset_type offset = _offset;
|
offset_type offset = _offset;
|
||||||
if (is_relative)
|
if (is_relative)
|
||||||
offset += is.GetOffset();
|
offset += is.GetOffset();
|
||||||
|
|
||||||
|
@ -110,14 +110,14 @@ dsdiff_read_payload(Decoder *decoder, InputStream &is,
|
|||||||
static bool
|
static bool
|
||||||
dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
|
dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
|
||||||
DsdiffMetaData *metadata,
|
DsdiffMetaData *metadata,
|
||||||
InputStream::offset_type end_offset)
|
offset_type end_offset)
|
||||||
{
|
{
|
||||||
DsdiffChunkHeader header;
|
DsdiffChunkHeader header;
|
||||||
while ((InputStream::offset_type)(is.GetOffset() + sizeof(header)) <= end_offset) {
|
while (offset_type(is.GetOffset() + sizeof(header)) <= end_offset) {
|
||||||
if (!dsdiff_read_chunk_header(decoder, is, &header))
|
if (!dsdiff_read_chunk_header(decoder, is, &header))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InputStream::offset_type chunk_end_offset = is.GetOffset()
|
offset_type chunk_end_offset = is.GetOffset()
|
||||||
+ header.GetSize();
|
+ header.GetSize();
|
||||||
if (chunk_end_offset > end_offset)
|
if (chunk_end_offset > end_offset)
|
||||||
return false;
|
return false;
|
||||||
@ -171,7 +171,7 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
|
|||||||
const DsdiffChunkHeader *prop_header)
|
const DsdiffChunkHeader *prop_header)
|
||||||
{
|
{
|
||||||
uint64_t prop_size = prop_header->GetSize();
|
uint64_t prop_size = prop_header->GetSize();
|
||||||
InputStream::offset_type end_offset = is.GetOffset() + prop_size;
|
const offset_type end_offset = is.GetOffset() + prop_size;
|
||||||
|
|
||||||
DsdId prop_id;
|
DsdId prop_id;
|
||||||
if (prop_size < sizeof(prop_id) ||
|
if (prop_size < sizeof(prop_id) ||
|
||||||
@ -188,7 +188,7 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
|
|||||||
static void
|
static void
|
||||||
dsdiff_handle_native_tag(InputStream &is,
|
dsdiff_handle_native_tag(InputStream &is,
|
||||||
const struct tag_handler *handler,
|
const struct tag_handler *handler,
|
||||||
void *handler_ctx, InputStream::offset_type tagoffset,
|
void *handler_ctx, offset_type tagoffset,
|
||||||
TagType type)
|
TagType type)
|
||||||
{
|
{
|
||||||
if (!dsdlib_skip_to(nullptr, is, tagoffset))
|
if (!dsdlib_skip_to(nullptr, is, tagoffset))
|
||||||
@ -240,12 +240,12 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/** offset for artist tag */
|
/** offset for artist tag */
|
||||||
InputStream::offset_type artist_offset = 0;
|
offset_type artist_offset = 0;
|
||||||
/** offset for title tag */
|
/** offset for title tag */
|
||||||
InputStream::offset_type title_offset = 0;
|
offset_type title_offset = 0;
|
||||||
|
|
||||||
#ifdef HAVE_ID3TAG
|
#ifdef HAVE_ID3TAG
|
||||||
InputStream::offset_type id3_offset = 0;
|
offset_type id3_offset = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Now process all the remaining chunk headers in the stream
|
/* Now process all the remaining chunk headers in the stream
|
||||||
@ -334,7 +334,7 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
|
|||||||
} else {
|
} else {
|
||||||
/* ignore unknown chunk */
|
/* ignore unknown chunk */
|
||||||
const uint64_t chunk_size = chunk_header->GetSize();
|
const uint64_t chunk_size = chunk_header->GetSize();
|
||||||
InputStream::offset_type chunk_end_offset =
|
const offset_type chunk_end_offset =
|
||||||
is.GetOffset() + chunk_size;
|
is.GetOffset() + chunk_size;
|
||||||
|
|
||||||
if (!dsdlib_skip_to(decoder, is, chunk_end_offset))
|
if (!dsdlib_skip_to(decoder, is, chunk_end_offset))
|
||||||
|
@ -44,7 +44,7 @@ struct DsfMetaData {
|
|||||||
bool bitreverse;
|
bool bitreverse;
|
||||||
uint64_t chunk_size;
|
uint64_t chunk_size;
|
||||||
#ifdef HAVE_ID3TAG
|
#ifdef HAVE_ID3TAG
|
||||||
InputStream::offset_type id3_offset;
|
offset_type id3_offset;
|
||||||
uint64_t id3_size;
|
uint64_t id3_size;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -173,7 +173,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
|
|||||||
metadata->channels = (unsigned) dsf_fmt_chunk.channelnum;
|
metadata->channels = (unsigned) dsf_fmt_chunk.channelnum;
|
||||||
metadata->sample_rate = samplefreq;
|
metadata->sample_rate = samplefreq;
|
||||||
#ifdef HAVE_ID3TAG
|
#ifdef HAVE_ID3TAG
|
||||||
metadata->id3_offset = (InputStream::offset_type)metadata_offset;
|
metadata->id3_offset = (offset_type)metadata_offset;
|
||||||
#endif
|
#endif
|
||||||
/* check bits per sample format, determine if bitreverse is needed */
|
/* check bits per sample format, determine if bitreverse is needed */
|
||||||
metadata->bitreverse = dsf_fmt_chunk.bitssample == 1;
|
metadata->bitreverse = dsf_fmt_chunk.bitssample == 1;
|
||||||
|
@ -67,7 +67,7 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 _offset, int whence)
|
|||||||
{
|
{
|
||||||
InputStream *is = (InputStream *)handle;
|
InputStream *is = (InputStream *)handle;
|
||||||
|
|
||||||
InputStream::offset_type offset = _offset;
|
offset_type offset = _offset;
|
||||||
switch (whence) {
|
switch (whence) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
break;
|
break;
|
||||||
|
@ -153,10 +153,10 @@ struct MadDecoder {
|
|||||||
enum mp3_action DecodeNextFrame();
|
enum mp3_action DecodeNextFrame();
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
InputStream::offset_type ThisFrameOffset() const;
|
offset_type ThisFrameOffset() const;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
InputStream::offset_type RestIncludingThisFrame() const;
|
offset_type RestIncludingThisFrame() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to calulcate the length of the song from filesize
|
* Attempt to calulcate the length of the song from filesize
|
||||||
@ -747,7 +747,7 @@ mp3_frame_duration(const struct mad_frame *frame)
|
|||||||
MAD_UNITS_MILLISECONDS) / 1000.0;
|
MAD_UNITS_MILLISECONDS) / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline InputStream::offset_type
|
inline offset_type
|
||||||
MadDecoder::ThisFrameOffset() const
|
MadDecoder::ThisFrameOffset() const
|
||||||
{
|
{
|
||||||
auto offset = input_stream.GetOffset();
|
auto offset = input_stream.GetOffset();
|
||||||
@ -760,7 +760,7 @@ MadDecoder::ThisFrameOffset() const
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline InputStream::offset_type
|
inline offset_type
|
||||||
MadDecoder::RestIncludingThisFrame() const
|
MadDecoder::RestIncludingThisFrame() const
|
||||||
{
|
{
|
||||||
return input_stream.GetSize() - ThisFrameOffset();
|
return input_stream.GetSize() - ThisFrameOffset();
|
||||||
@ -770,7 +770,7 @@ inline void
|
|||||||
MadDecoder::FileSizeToSongLength()
|
MadDecoder::FileSizeToSongLength()
|
||||||
{
|
{
|
||||||
if (input_stream.KnownSize()) {
|
if (input_stream.KnownSize()) {
|
||||||
InputStream::offset_type rest = RestIncludingThisFrame();
|
offset_type rest = RestIncludingThisFrame();
|
||||||
|
|
||||||
float frame_duration = mp3_frame_duration(&frame);
|
float frame_duration = mp3_frame_duration(&frame);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ static constexpr Domain modplug_domain("modplug");
|
|||||||
|
|
||||||
static constexpr size_t MODPLUG_FRAME_SIZE = 4096;
|
static constexpr size_t MODPLUG_FRAME_SIZE = 4096;
|
||||||
static constexpr size_t MODPLUG_PREALLOC_BLOCK = 256 * 1024;
|
static constexpr size_t MODPLUG_PREALLOC_BLOCK = 256 * 1024;
|
||||||
static constexpr InputStream::offset_type MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
|
static constexpr offset_type MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
|
||||||
|
|
||||||
static int modplug_loop_count;
|
static int modplug_loop_count;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "OggFind.hxx"
|
#include "OggFind.hxx"
|
||||||
#include "OggSyncState.hxx"
|
#include "OggSyncState.hxx"
|
||||||
|
#include "input/InputStream.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -39,7 +40,7 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
|
OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
|
||||||
InputStream::offset_type offset)
|
offset_type offset)
|
||||||
{
|
{
|
||||||
oy.Reset();
|
oy.Reset();
|
||||||
|
|
||||||
|
@ -21,11 +21,12 @@
|
|||||||
#define MPD_OGG_FIND_HXX
|
#define MPD_OGG_FIND_HXX
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/Offset.hxx"
|
||||||
|
|
||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
|
|
||||||
class OggSyncState;
|
class OggSyncState;
|
||||||
|
class InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skip all pages/packets until an end-of-stream (EOS) packet for the
|
* Skip all pages/packets until an end-of-stream (EOS) packet for the
|
||||||
@ -41,7 +42,7 @@ OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet);
|
|||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
|
OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
|
||||||
InputStream::offset_type offset);
|
offset_type offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to find the end-of-stream (EOS) packet. Seek to the end of the
|
* Try to find the end-of-stream (EOS) packet. Seek to the end of the
|
||||||
|
@ -339,8 +339,8 @@ MPDOpusDecoder::Seek(OggSyncState &oy, double where_s)
|
|||||||
/* interpolate the file offset where we expect to find the
|
/* interpolate the file offset where we expect to find the
|
||||||
given granule position */
|
given granule position */
|
||||||
/* TODO: implement binary search */
|
/* TODO: implement binary search */
|
||||||
InputStream::offset_type offset(where_granulepos * input_stream.GetSize()
|
offset_type offset(where_granulepos * input_stream.GetSize()
|
||||||
/ eos_granulepos);
|
/ eos_granulepos);
|
||||||
|
|
||||||
if (!OggSeekPageAtOffset(oy, os, input_stream, offset))
|
if (!OggSeekPageAtOffset(oy, os, input_stream, offset))
|
||||||
return false;
|
return false;
|
||||||
|
@ -70,8 +70,8 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
|
|||||||
buffer, nbytes, 0)
|
buffer, nbytes, 0)
|
||||||
: decoder_get_command(decoder);
|
: decoder_get_command(decoder);
|
||||||
if (cmd == DecoderCommand::SEEK) {
|
if (cmd == DecoderCommand::SEEK) {
|
||||||
InputStream::offset_type offset(time_to_size *
|
offset_type offset(time_to_size *
|
||||||
decoder_seek_where(decoder));
|
decoder_seek_where(decoder));
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
if (is.LockSeek(offset, error)) {
|
if (is.LockSeek(offset, error)) {
|
||||||
|
@ -70,7 +70,7 @@ sndfile_vio_seek(sf_count_t _offset, int whence, void *user_data)
|
|||||||
SndfileInputStream &sis = *(SndfileInputStream *)user_data;
|
SndfileInputStream &sis = *(SndfileInputStream *)user_data;
|
||||||
InputStream &is = sis.is;
|
InputStream &is = sis.is;
|
||||||
|
|
||||||
InputStream::offset_type offset = _offset;
|
offset_type offset = _offset;
|
||||||
switch (whence) {
|
switch (whence) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
break;
|
break;
|
||||||
|
@ -80,7 +80,7 @@ static int ogg_seek_cb(void *data, ogg_int64_t _offset, int whence)
|
|||||||
decoder_get_command(*vis->decoder) == DecoderCommand::STOP))
|
decoder_get_command(*vis->decoder) == DecoderCommand::STOP))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
InputStream::offset_type offset = _offset;
|
offset_type offset = _offset;
|
||||||
switch (whence) {
|
switch (whence) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
break;
|
break;
|
||||||
|
@ -405,7 +405,7 @@ wavpack_input_set_pos_rel(void *id, int32_t delta, int mode)
|
|||||||
WavpackInput &wpi = *wpin(id);
|
WavpackInput &wpi = *wpin(id);
|
||||||
InputStream &is = wpi.is;
|
InputStream &is = wpi.is;
|
||||||
|
|
||||||
InputStream::offset_type offset = delta;
|
offset_type offset = delta;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
break;
|
break;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MPD_INPUT_STREAM_HXX
|
#define MPD_INPUT_STREAM_HXX
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
#include "Offset.hxx"
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ struct Tag;
|
|||||||
|
|
||||||
class InputStream {
|
class InputStream {
|
||||||
public:
|
public:
|
||||||
typedef uint64_t offset_type;
|
typedef ::offset_type offset_type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
32
src/input/Offset.hxx
Normal file
32
src/input/Offset.hxx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2014 The Music Player Daemon Project
|
||||||
|
* http://www.musicpd.org
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MPD_OFFSET_HXX
|
||||||
|
#define MPD_OFFSET_HXX
|
||||||
|
|
||||||
|
#include "check.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type for absolute offsets in a file.
|
||||||
|
*/
|
||||||
|
typedef uint64_t offset_type;
|
||||||
|
|
||||||
|
#endif
|
@ -72,8 +72,7 @@ public:
|
|||||||
ris->Update();
|
ris->Update();
|
||||||
CPPUNIT_ASSERT(ris->IsReady());
|
CPPUNIT_ASSERT(ris->IsReady());
|
||||||
CPPUNIT_ASSERT(!ris->KnownSize());
|
CPPUNIT_ASSERT(!ris->KnownSize());
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(0),
|
CPPUNIT_ASSERT_EQUAL(offset_type(0), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
@ -81,50 +80,43 @@ public:
|
|||||||
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
||||||
CPPUNIT_ASSERT_EQUAL('f', buffer[0]);
|
CPPUNIT_ASSERT_EQUAL('f', buffer[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL('o', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL('o', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(2),
|
CPPUNIT_ASSERT_EQUAL(offset_type(2), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
nbytes = ris->Read(buffer, 2, error);
|
nbytes = ris->Read(buffer, 2, error);
|
||||||
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
||||||
CPPUNIT_ASSERT_EQUAL('o', buffer[0]);
|
CPPUNIT_ASSERT_EQUAL('o', buffer[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(' ', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL(' ', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(4),
|
CPPUNIT_ASSERT_EQUAL(offset_type(4), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
CPPUNIT_ASSERT(ris->Seek(1, error));
|
CPPUNIT_ASSERT(ris->Seek(1, error));
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(1),
|
CPPUNIT_ASSERT_EQUAL(offset_type(1), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
nbytes = ris->Read(buffer, 2, error);
|
nbytes = ris->Read(buffer, 2, error);
|
||||||
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
||||||
CPPUNIT_ASSERT_EQUAL('o', buffer[0]);
|
CPPUNIT_ASSERT_EQUAL('o', buffer[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL('o', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL('o', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(3),
|
CPPUNIT_ASSERT_EQUAL(offset_type(3), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
CPPUNIT_ASSERT(ris->Seek(0, error));
|
CPPUNIT_ASSERT(ris->Seek(0, error));
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(0),
|
CPPUNIT_ASSERT_EQUAL(offset_type(0), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
nbytes = ris->Read(buffer, 2, error);
|
nbytes = ris->Read(buffer, 2, error);
|
||||||
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
||||||
CPPUNIT_ASSERT_EQUAL('f', buffer[0]);
|
CPPUNIT_ASSERT_EQUAL('f', buffer[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL('o', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL('o', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(2),
|
CPPUNIT_ASSERT_EQUAL(offset_type(2), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
nbytes = ris->Read(buffer, sizeof(buffer), error);
|
nbytes = ris->Read(buffer, sizeof(buffer), error);
|
||||||
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
CPPUNIT_ASSERT_EQUAL(size_t(2), nbytes);
|
||||||
CPPUNIT_ASSERT_EQUAL('o', buffer[0]);
|
CPPUNIT_ASSERT_EQUAL('o', buffer[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(' ', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL(' ', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(4),
|
CPPUNIT_ASSERT_EQUAL(offset_type(4), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
nbytes = ris->Read(buffer, sizeof(buffer), error);
|
nbytes = ris->Read(buffer, sizeof(buffer), error);
|
||||||
@ -132,13 +124,11 @@ public:
|
|||||||
CPPUNIT_ASSERT_EQUAL('b', buffer[0]);
|
CPPUNIT_ASSERT_EQUAL('b', buffer[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL('a', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL('a', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL('r', buffer[2]);
|
CPPUNIT_ASSERT_EQUAL('r', buffer[2]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(7),
|
CPPUNIT_ASSERT_EQUAL(offset_type(7), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(ris->IsEOF());
|
CPPUNIT_ASSERT(ris->IsEOF());
|
||||||
|
|
||||||
CPPUNIT_ASSERT(ris->Seek(3, error));
|
CPPUNIT_ASSERT(ris->Seek(3, error));
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(3),
|
CPPUNIT_ASSERT_EQUAL(offset_type(3), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(!ris->IsEOF());
|
CPPUNIT_ASSERT(!ris->IsEOF());
|
||||||
|
|
||||||
nbytes = ris->Read(buffer, sizeof(buffer), error);
|
nbytes = ris->Read(buffer, sizeof(buffer), error);
|
||||||
@ -147,8 +137,7 @@ public:
|
|||||||
CPPUNIT_ASSERT_EQUAL('b', buffer[1]);
|
CPPUNIT_ASSERT_EQUAL('b', buffer[1]);
|
||||||
CPPUNIT_ASSERT_EQUAL('a', buffer[2]);
|
CPPUNIT_ASSERT_EQUAL('a', buffer[2]);
|
||||||
CPPUNIT_ASSERT_EQUAL('r', buffer[3]);
|
CPPUNIT_ASSERT_EQUAL('r', buffer[3]);
|
||||||
CPPUNIT_ASSERT_EQUAL(InputStream::offset_type(7),
|
CPPUNIT_ASSERT_EQUAL(offset_type(7), ris->GetOffset());
|
||||||
ris->GetOffset());
|
|
||||||
CPPUNIT_ASSERT(ris->IsEOF());
|
CPPUNIT_ASSERT(ris->IsEOF());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user