kwave  18.07.70
ID3_QIODeviceReader.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  ID3_QIODeviceReader.cpp - Adapter between QIODevice and ID3_Reader
3  -------------------
4  begin : Wed Aug 14 2002
5  copyright : (C) 2002 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QIODevice>
21 
22 #include "ID3_QIODeviceReader.h"
23 
24 //***************************************************************************
26  :ID3_Reader(), m_source(source)
27 {
28 }
29 
30 //***************************************************************************
32 {
33 }
34 
35 //***************************************************************************
37 {
38 }
39 
40 //***************************************************************************
41 ID3_Reader::pos_type Kwave::ID3_QIODeviceReader::getBeg()
42 {
43  return 0;
44 }
45 
46 //***************************************************************************
47 ID3_Reader::pos_type Kwave::ID3_QIODeviceReader::getEnd()
48 {
49  return static_cast<ID3_Reader::pos_type>(m_source.size());
50 }
51 
52 //***************************************************************************
53 ID3_Reader::pos_type Kwave::ID3_QIODeviceReader::getCur()
54 {
55  return static_cast<ID3_Reader::pos_type>(m_source.pos());
56 }
57 
58 //***************************************************************************
59 ID3_Reader::pos_type Kwave::ID3_QIODeviceReader::setCur(ID3_Reader::pos_type pos)
60 {
61  if (!m_source.seek(static_cast<qint64>(pos)))
62  return static_cast<ID3_Reader::pos_type>(-1);
63  return static_cast<ID3_Reader::pos_type>(m_source.pos());
64 }
65 
66 //***************************************************************************
68 {
69  unsigned char c = 0;
70  m_source.getChar(reinterpret_cast<char *>(&c));
71  return static_cast<ID3_Reader::int_type>(c);
72 }
73 
74 //***************************************************************************
76 {
77  qint64 pos = m_source.pos();
78  ID3_Reader::int_type ch = readChar();
79  m_source.seek(pos);
80  return ch;
81 }
82 
83 //***************************************************************************
85  char_type buf[], size_type len)
86 {
87  qint64 size = m_source.read(
88  reinterpret_cast<char *>(&(buf[0])),
89  static_cast<qint64>(len)
90  );
91  return static_cast<ID3_Reader::size_type>(size);
92 }
93 
94 //***************************************************************************
96  char buf[], size_type len)
97 {
98  return this->readChars(reinterpret_cast<char_type *>(buf), len);
99 }
100 
101 //***************************************************************************
102 //***************************************************************************
virtual ID3_Reader::pos_type setCur(ID3_Reader::pos_type pos=0)
virtual ID3_Reader::pos_type getBeg()
ID3_QIODeviceReader(QIODevice &source)
virtual ID3_Reader::int_type readChar()
virtual size_type readChars(char_type buf[], size_type len)
virtual ID3_Reader::int_type peekChar()
virtual ID3_Reader::pos_type getCur()
virtual ID3_Reader::pos_type getEnd()