qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
toxstring.h
Go to the documentation of this file.
1 /*
2  Copyright © 2017-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <QByteArray>
23 #include <QString>
24 
25 #include <cstdint>
26 
27 class ToxString
28 {
29 public:
30  explicit ToxString(const QString& text);
31  explicit ToxString(const QByteArray& text);
32  ToxString(const uint8_t* text, size_t length);
33 
34  const uint8_t* data() const;
35  size_t size() const;
36  QString getQString() const;
37  QByteArray getBytes() const;
38 
39 private:
40  QByteArray string;
41 };
ToxString::getQString
QString getQString() const
Gets the string as QString.
Definition: toxstring.cpp:84
ToxString::getBytes
QByteArray getBytes() const
getBytes Gets the bytes of the string.
Definition: toxstring.cpp:93
ToxString
Helper to convert safely between strings in the c-toxcore representation and QString.
Definition: toxstring.h:27
ToxString::string
QByteArray string
Definition: toxstring.h:40
ToxString::size
size_t size() const
Get the number of bytes in the string.
Definition: toxstring.cpp:75
ToxString::ToxString
ToxString(const QString &text)
Creates a ToxString from a QString.
Definition: toxstring.cpp:37
ToxString::data
const uint8_t * data() const
Returns a pointer to the beginning of the string data.
Definition: toxstring.cpp:66