TagLib API Documentation
ebmlutils.h
Go to the documentation of this file.
1/***************************************************************************
2 * This library is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU Lesser General Public License version *
4 * 2.1 as published by the Free Software Foundation. *
5 * *
6 * This library is distributed in the hope that it will be useful, but *
7 * WITHOUT ANY WARRANTY; without even the implied warranty of *
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
9 * Lesser General Public License for more details. *
10 * *
11 * You should have received a copy of the GNU Lesser General Public *
12 * License along with this library; if not, write to the Free Software *
13 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
14 * 02110-1301 USA *
15 * *
16 * Alternatively, this file is available under the Mozilla Public *
17 * License Version 1.1. You may obtain a copy of the License at *
18 * http://www.mozilla.org/MPL/ *
19 ***************************************************************************/
20
21#ifndef TAGLIB_EBMLUTILS_H
22#define TAGLIB_EBMLUTILS_H
23#ifndef DO_NOT_DOCUMENT
24
25#include <utility>
26#include "taglib.h"
27#include "ebmlelement.h"
28
29namespace TagLib {
30 class File;
31 class ByteVector;
32
33 namespace EBML {
34 std::unique_ptr<Element> findElement(File &file, Element::Id id, offset_t maxOffset);
35 std::unique_ptr<Element> findNextElement(File &file, offset_t maxOffset);
36
37 template <int maxSizeLength>
38 unsigned int VINTSizeLength(uint8_t firstByte);
39
40 std::pair<unsigned int, uint64_t> readVINT(File &file);
41
42 std::pair<unsigned int, uint64_t> parseVINT(const ByteVector &buffer);
43
44 ByteVector renderVINT(uint64_t number, int minSizeLength);
45
46 unsigned long long randomUID();
47
48 constexpr int minSize(uint64_t data)
49 {
50 if(data <= 0x7Fu)
51 return 1;
52 if(data <= 0x3FFFu)
53 return 2;
54 if(data <= 0x1FFFFFu)
55 return 3;
56 if(data <= 0xFFFFFFFu)
57 return 4;
58 if(data <= 0x7FFFFFFFFu)
59 return 5;
60 return 0;
61 }
62
63 constexpr int idSize(Element::Id id)
64 {
65 const auto uintId = static_cast<unsigned int>(id);
66 if(uintId <= 0xFF)
67 return 1;
68 if(uintId <= 0xFFFF)
69 return 2;
70 if(uintId <= 0xFFFFFF)
71 return 3;
72 return 4;
73 }
74 }
75}
76
77#endif
78#endif
A namespace for all TagLib related classes and functions.
Definition apefile.h:41
off_t offset_t
Definition taglib.h:64