id3lib  3.8.3
writer.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: writer.h,v 1.8 2002/07/02 22:11:10 t1mpy Exp $
3 
4 // id3lib: a software library for creating and manipulating id3v1/v2 tags
5 // Copyright 1999, 2000 Scott Thomas Haug
6 
7 // This library is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU Library General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or (at your
10 // option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with this library; if not, write to the Free Software Foundation,
19 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 
21 // The id3lib authors encourage improvements and optimisations to be sent to
22 // the id3lib coordinator. Please see the README file for details on where to
23 // send such submissions. See the AUTHORS file for a list of people who have
24 // contributed to id3lib. See the ChangeLog file for a list of changes to
25 // id3lib. These files are distributed with id3lib at
26 // http://download.sourceforge.net/id3lib/
27 
28 #ifndef _ID3LIB_WRITER_H_
29 #define _ID3LIB_WRITER_H_
30 
31 #include "id3/globals.h" //has <stdlib.h> "id3/sized_types.h"
32 
34 {
35  public:
36  typedef uint32 size_type;
37  typedef uint8 char_type;
38  typedef uint32 pos_type;
39  typedef int32 off_type;
40  typedef int16 int_type;
41  static const int_type END_OF_WRITER;
42 
44  virtual void close() = 0;
45 
47  virtual void flush() = 0;
48 
50  virtual pos_type getBeg() { return static_cast<pos_type>(0); }
51 
55  virtual pos_type getEnd() { return static_cast<pos_type>(-1); }
56 
58  virtual pos_type getCur() = 0;
59 
61  virtual size_type getSize() { return this->getCur() - this->getBeg(); }
62 
64  virtual size_type getMaxSize() { return this->getEnd() - this->getBeg(); }
65 
72  {
73  if (this->atEnd())
74  {
75  return END_OF_WRITER;
76  }
77  this->writeChars(&ch, 1);
78  return ch;
79  }
80 
86  virtual size_type writeChars(const char_type buf[], size_type len) = 0;
87  virtual size_type writeChars(const char buf[], size_type len)
88  {
89  return this->writeChars(reinterpret_cast<const char_type *>(buf), len);
90  }
91 
92  virtual bool atEnd()
93  {
94  return this->getCur() >= this->getEnd();
95  }
96 };
97 
98 #endif /* _ID3LIB_WRITER_H_ */
99 
virtual size_type getMaxSize()
Return the maximum number of bytes that can be written.
Definition: writer.h:64
virtual size_type writeChars(const char_type buf[], size_type len)=0
Write up to len characters into buf and advance the internal position accordingly.
int16 int_type
Definition: writer.h:40
virtual int_type writeChar(char_type ch)
Write a single character and advance the internal position.
Definition: writer.h:71
virtual size_type getSize()
Return the number of bytes written.
Definition: writer.h:61
virtual pos_type getEnd()
Return the first position that can't be written to.
Definition: writer.h:55
virtual void close()=0
Close the writer.
virtual bool atEnd()
Definition: writer.h:92
virtual pos_type getBeg()
Return the beginning position in the writer.
Definition: writer.h:50
uint8 char_type
Definition: writer.h:37
virtual pos_type getCur()=0
Return the next position that will be written to.
uint32 pos_type
Definition: writer.h:38
static const int_type END_OF_WRITER
Definition: writer.h:41
virtual void flush()=0
Flush the writer.
int32 off_type
Definition: writer.h:39
virtual size_type writeChars(const char buf[], size_type len)
Definition: writer.h:87
uint32 size_type
Definition: writer.h:36
#define ID3_CPP_EXPORT
Definition: globals.h:79