27#if defined HAVE_CONFIG_H
38 while (!reader.
atEnd())
45 str +=
static_cast<char>(ch);
54 const size_t SIZE = 1024;
56 size_t remaining = len;
57 while (remaining > 0 && !reader.
atEnd())
59 size_t numRead = reader.
readChars(buf,
min(remaining, SIZE));
61 str.append(
reinterpret_cast<String::value_type *
>(buf), numRead);
68 bool isNull(
unsigned char ch1,
unsigned char ch2)
70 return ch1 ==
'\0' && ch2 ==
'\0';
73 int isBOM(
unsigned char ch1,
unsigned char ch2)
94 if (ch1 == 0xFE && ch2 == 0xFF)
98 else if (ch1 == 0xFF && ch2 == 0xFE)
129 if (!readTwoChars(reader, ch1, ch2) || isNull(ch1, ch2))
133 int bom = isBOM(ch1, ch2);
136 unicode +=
static_cast<char>(ch1);
137 unicode +=
static_cast<char>(ch2);
139 while (!reader.
atEnd())
141 if (!readTwoChars(reader, ch1, ch2) || isNull(ch1, ch2))
147 unicode +=
static_cast<char>(ch2);
148 unicode +=
static_cast<char>(ch1);
152 unicode +=
static_cast<char>(ch1);
153 unicode +=
static_cast<char>(ch2);
163 if (!readTwoChars(reader, ch1, ch2))
168 int bom = isBOM(ch1, ch2);
181 for (
size_t i = 0; i < len; i += 2)
183 if (!readTwoChars(reader, ch1, ch2))
204 size_t remaining = len;
205 const size_t SIZE = 1024;
207 while (!reader.
atEnd() && remaining > 0)
209 size_t numRead = reader.
readChars(buf,
min(remaining, SIZE));
210 remaining -= numRead;
211 binary.append(
reinterpret_cast<BString::value_type *
>(buf), numRead);
220 for (
size_t i = 0; i < len; i++)
226 val += (
static_cast<uint32
>(0xFF & reader.
readChar()) << (i * 8));
238 val +=
static_cast<uint32
>(0xFF & reader.
readChar());
253 if (ch ==
'\0' || ch ==
' ')
259 str += spaces + (char) ch;
269 const unsigned short BITSUSED = 7;
270 const uint32 MAXVAL =
MASK(BITSUSED *
sizeof(uint32));
272 for (
size_t i = 0; i <
sizeof(uint32); ++i)
279 val = (val << BITSUSED) | static_cast<uint32>(reader.
readChar()) &
MASK(BITSUSED);
283 return min(val, MAXVAL);
290 renderNumber(bytes, val, size);
300 for (; size < len; ++size)
304 return writer.
getCur() - beg;
309 uchar data[
sizeof(uint32)];
310 const unsigned short BITSUSED = 7;
311 const uint32 MAXVAL =
MASK(BITSUSED *
sizeof(uint32));
312 val =
min(val, MAXVAL);
316 for (
size_t i = 0; i <
sizeof(uint32); ++i)
320 data[
sizeof(uint32) - i - 1] =
static_cast<uchar>(val &
MASK(BITSUSED));
328 return writer.
writeChars(data,
sizeof(uint32));
342 return writer.
getCur() - beg;
349 writer.
writeChars((
const unsigned char*) &null, 2);
356 size_t size = (data.size() / 2) * 2;
365 writer.
writeChars((
const unsigned char*) &BOM, 2);
366 unsigned char *pdata = (
unsigned char *) data.c_str();
367 for (
size_t i = 0; i < size; i += 2)
369 unicode_t ch = (pdata[i] << 8) | pdata[i+1];
370 writer.
writeChars((
const unsigned char*) &ch, 2);
373 return writer.
getCur() - beg;
virtual size_type readChars(char_type buf[], size_type len)=0
Read up to len characters into buf and advance the internal position accordingly.
virtual int_type readChar()
Read a single character and advance the internal position.
virtual size_type remainingBytes()
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.
virtual int_type writeChar(char_type ch)
Write a single character and advance the internal position.
virtual pos_type getCur()=0
Return the next position that will be written to.
Set a window on the buffer.
int_type readChar()
Read a single character and advance the internal position.
ID3_C_EXPORT size_t writeUInt28(ID3_Writer &, uint32)
ID3_C_EXPORT BString readAllBinary(ID3_Reader &)
ID3_C_EXPORT uint32 readLENumber(ID3_Reader &, size_t)
ID3_C_EXPORT uint32 readUInt28(ID3_Reader &)
ID3_C_EXPORT uint32 readBENumber(ID3_Reader &, size_t)
ID3_C_EXPORT size_t writeTrailingSpaces(ID3_Writer &, String, size_t)
ID3_C_EXPORT BString readBinary(ID3_Reader &, size_t)
ID3_C_EXPORT String readText(ID3_Reader &, size_t)
ID3_C_EXPORT String readUnicodeString(ID3_Reader &)
ID3_C_EXPORT size_t writeString(ID3_Writer &, String)
ID3_C_EXPORT size_t writeText(ID3_Writer &, String)
ID3_C_EXPORT String readString(ID3_Reader &)
ID3_C_EXPORT size_t writeUnicodeString(ID3_Writer &, String, bool=true)
ID3_C_EXPORT size_t writeBENumber(ID3_Writer &, uint32 val, size_t)
ID3_C_EXPORT String readUnicodeText(ID3_Reader &, size_t)
ID3_C_EXPORT String readTrailingSpaces(ID3_Reader &, size_t)
ID3_C_EXPORT size_t writeUnicodeText(ID3_Writer &, String, bool=true)