2016-04-16 17:51:25 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-16 17:51:25 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-16 17:51:25 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
|
|
|
class QByteArray;
|
|
|
|
|
|
|
|
namespace codegen {
|
|
|
|
namespace common {
|
|
|
|
|
|
|
|
class ConstUtf8String;
|
|
|
|
|
|
|
|
// Parses a char sequence to a QString using UTF-8 codec.
|
|
|
|
// You can check for invalid UTF-8 sequence by isValid() method.
|
|
|
|
class CheckedUtf8String {
|
|
|
|
public:
|
|
|
|
CheckedUtf8String(const CheckedUtf8String &other) = default;
|
|
|
|
CheckedUtf8String &operator=(const CheckedUtf8String &other) = default;
|
|
|
|
|
2016-04-18 20:33:43 +00:00
|
|
|
explicit CheckedUtf8String(const char *string, int size = -1);
|
|
|
|
explicit CheckedUtf8String(const QByteArray &string);
|
|
|
|
explicit CheckedUtf8String(const ConstUtf8String &string);
|
2016-04-16 17:51:25 +00:00
|
|
|
|
|
|
|
bool isValid() const {
|
|
|
|
return valid_;
|
|
|
|
}
|
|
|
|
const QString &toString() const {
|
|
|
|
return string_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString string_;
|
|
|
|
bool valid_ = true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace common
|
|
|
|
} // namespace codegen
|