2017-02-15 08:50:11 +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.
|
2017-02-15 08:50:11 +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
|
2017-02-15 08:50:11 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <QtCore/QString>
|
|
|
|
#include <QtCore/QSet>
|
|
|
|
#include "codegen/common/cpp_file.h"
|
|
|
|
#include "codegen/emoji/options.h"
|
|
|
|
#include "codegen/emoji/data.h"
|
2017-07-19 18:37:49 +00:00
|
|
|
#include "codegen/emoji/replaces.h"
|
2017-02-15 08:50:11 +00:00
|
|
|
|
|
|
|
namespace codegen {
|
|
|
|
namespace emoji {
|
|
|
|
|
2017-07-24 16:18:39 +00:00
|
|
|
using uint32 = unsigned int;
|
|
|
|
|
2017-02-15 08:50:11 +00:00
|
|
|
class Generator {
|
|
|
|
public:
|
|
|
|
Generator(const Options &options);
|
|
|
|
Generator(const Generator &other) = delete;
|
|
|
|
Generator &operator=(const Generator &other) = delete;
|
|
|
|
|
|
|
|
int generate();
|
|
|
|
|
|
|
|
private:
|
2017-04-03 18:49:07 +00:00
|
|
|
#ifdef SUPPORT_IMAGE_GENERATION
|
2018-10-13 14:51:16 +00:00
|
|
|
QImage generateImage(int imageIndex);
|
2017-02-15 08:50:11 +00:00
|
|
|
bool writeImages();
|
2017-04-03 18:49:07 +00:00
|
|
|
#endif // SUPPORT_IMAGE_GENERATION
|
|
|
|
|
2017-02-15 08:50:11 +00:00
|
|
|
bool writeSource();
|
2017-03-31 19:08:25 +00:00
|
|
|
bool writeHeader();
|
2017-07-24 16:18:39 +00:00
|
|
|
bool writeSuggestionsSource();
|
|
|
|
bool writeSuggestionsHeader();
|
2017-03-31 19:08:25 +00:00
|
|
|
|
|
|
|
template <typename Callback>
|
|
|
|
bool enumerateWholeList(Callback callback);
|
2017-02-15 08:50:11 +00:00
|
|
|
|
|
|
|
bool writeInitCode();
|
2017-03-29 15:09:16 +00:00
|
|
|
bool writeSections();
|
2017-07-19 18:37:49 +00:00
|
|
|
bool writeReplacements();
|
2017-03-31 19:08:25 +00:00
|
|
|
bool writeGetSections();
|
2017-02-15 08:50:11 +00:00
|
|
|
bool writeFindReplace();
|
|
|
|
bool writeFind();
|
2018-10-24 09:35:53 +00:00
|
|
|
bool writeFindFromDictionary(
|
|
|
|
const std::map<QString, int, std::greater<QString>> &dictionary,
|
|
|
|
bool skipPostfixes = false,
|
|
|
|
const std::set<int> &postfixRequired = {});
|
2017-07-19 18:37:49 +00:00
|
|
|
bool writeGetReplacements();
|
|
|
|
void startBinary();
|
2017-07-24 16:18:39 +00:00
|
|
|
bool writeStringBinary(common::CppFile *source, const QString &string);
|
|
|
|
void writeIntBinary(common::CppFile *source, int data);
|
|
|
|
void writeUintBinary(common::CppFile *source, uint32 data);
|
2017-02-15 08:50:11 +00:00
|
|
|
|
|
|
|
const common::ProjectInfo &project_;
|
|
|
|
int colorsCount_ = 0;
|
2017-04-03 18:49:07 +00:00
|
|
|
#ifdef SUPPORT_IMAGE_GENERATION
|
2017-03-31 19:08:25 +00:00
|
|
|
bool writeImages_ = false;
|
2017-04-03 18:49:07 +00:00
|
|
|
#endif // SUPPORT_IMAGE_GENERATION
|
2017-02-15 08:50:11 +00:00
|
|
|
QString outputPath_;
|
|
|
|
QString spritePath_;
|
|
|
|
std::unique_ptr<common::CppFile> source_;
|
|
|
|
Data data_;
|
2017-07-24 16:18:39 +00:00
|
|
|
|
|
|
|
QString suggestionsPath_;
|
|
|
|
std::unique_ptr<common::CppFile> suggestionsSource_;
|
2017-07-19 18:37:49 +00:00
|
|
|
Replaces replaces_;
|
|
|
|
|
|
|
|
int _binaryFullLength = 0;
|
|
|
|
int _binaryCount = 0;
|
2017-02-15 08:50:11 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace emoji
|
|
|
|
} // namespace codegen
|