tdesktop/Telegram/SourceFiles/codegen/lang/generator.h

56 lines
1.5 KiB
C
Raw Normal View History

2017-04-12 22:17:55 +03:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2017-04-12 22:17:55 +03:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2017-04-12 22:17:55 +03:00
*/
#pragma once
#include <memory>
#include <map>
#include <set>
#include <functional>
#include <QtCore/QString>
#include <QtCore/QSet>
#include "codegen/common/cpp_file.h"
#include "codegen/lang/parsed_file.h"
namespace codegen {
namespace lang {
class Generator {
public:
Generator(const LangPack &langpack, const QString &destBasePath, const common::ProjectInfo &project);
2017-04-12 22:17:55 +03:00
Generator(const Generator &other) = delete;
Generator &operator=(const Generator &other) = delete;
bool writeHeader();
bool writeSource();
private:
void writeHeaderForwardDeclarations();
void writeHeaderTagTypes();
void writeHeaderKeyType();
void writeHeaderTaggedMethods();
void writeHeaderInterface();
void writeHeaderTagValueLookup();
void writeHeaderReactiveInterface();
void writeHeaderProducersInterface();
void writeHeaderProducersInstances();
QString getFullKey(const LangPack::Entry &entry);
2017-04-12 22:17:55 +03:00
template <typename ComputeResult>
void writeSetSearch(const std::set<QString, std::greater<>> &set, ComputeResult computeResult, const QString &invalidResult);
2017-04-12 22:17:55 +03:00
const LangPack &langpack_;
2017-04-12 22:17:55 +03:00
QString basePath_, baseName_;
const common::ProjectInfo &project_;
std::unique_ptr<common::CppFile> source_, header_;
};
} // namespace lang
} // namespace codegen