lmms
Cross-platform music production software
Toggle main menu visibility
Loading...
Searching...
No Matches
include
base64.h
Go to the documentation of this file.
1
/*
2
* base64.h - namespace base64 with methods for encoding/decoding binary data
3
* to/from base64
4
*
5
* Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6
*
7
* This file is part of LMMS - https://lmms.io
8
*
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public
20
* License along with this program (see COPYING); if not, write to the
21
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
* Boston, MA 02110-1301 USA.
23
*
24
*/
25
26
#ifndef LMMS_BASE64_H
27
#define LMMS_BASE64_H
28
29
#include <QByteArray>
30
#include <QMetaType>
31
#include <QString>
32
#include <QVariant>
33
34
namespace
lmms::base64
35
{
36
37
inline
void
encode
(
const
char
* _data,
const
int
_size,
38
QString & _dst )
39
{
40
_dst = QByteArray( _data, _size ).toBase64();
41
}
42
43
template
<
class
T>
44
inline
void
decode
(
const
QString & _b64, T * * _data,
int
* _size )
45
{
46
QByteArray data = QByteArray::fromBase64( _b64.toUtf8() );
47
*_size = data.size();
48
*_data =
new
T[*_size /
sizeof
(T)];
49
memcpy( *_data, data.constData(), *_size );
50
}
51
52
// for compatibility-code only
53
QVariant
decode
(
const
QString& b64,
54
QMetaType::Type forceType = QMetaType::UnknownType);
55
56
}
// namespace lmms::base64
57
58
#endif
// LMMS_BASE64_H
lmms::base64
Definition
base64.cpp:34
lmms::base64::encode
void encode(const char *_data, const int _size, QString &_dst)
Definition
base64.h:37
lmms::base64::decode
QVariant decode(const QString &b64, QMetaType::Type forceType)
Definition
base64.cpp:37
Generated on
for lmms by
1.18.0