1 #ifndef Header_Latex_Package
2 #define Header_Latex_Package
3 
4 #include "mostQtHeaders.h"
5 #include "codesnippet.h"
6 #include "latexparser/commanddescription.h"
7 
8 typedef QPair<QString, int> QPairQStringInt;
9 class LatexCompleterConfig;
10 
11 /*!
12  * \brief store necessary information for latex package
13  *
14  * Stores commands for completion and syntax check.
15  */
16 class LatexPackage
17 {
18 public:
19 	LatexPackage();
20 
21 	// Temporary solution: keys of LatexDocuments::cachedPackages have become complex. Use these functions to manage them.
22 	// This is a first step for refactoring the existing code. No functionality is changed.
23 	// In the long run, the information should be stored and accessed via the LatexPackage objects, which are referenced by the keys.
24 	static QString makeKey(const QString &cwlFilename, const QString &options);  // TODO not yet used: where are the keys actually created?
25 	static QString keyToCwlFilename(const QString &key);
26 	static QString keyToPackageName(const QString &key);
27 	static QStringList keyToOptions(const QString &key);
28 
29 	bool notFound;  // Workaround: explicit flag better than using a magic value in package name. TODO: Do we need not found packages?
30     bool containsOptionalSections; ///< optimization to not reread for different package options
31 	QString packageName; ///< name of package
32 	QStringList requiredPackages; ///< necessary sub-packages
33 	CodeSnippetList completionWords; ///< list of completion words
34 	QHash<QString, QSet<QString> > possibleCommands; ///< possible commands, info for syntax checking
35 	QHash<QString, QString> specialDefCommands; ///< define special elements, e.g. define color etc
36 	QSet<QString> optionCommands; ///< commands which contain arguments, obsolete
37 	QHash<QString, QSet< QPairQStringInt > > specialTreatmentCommands; ///< special commands, obsolete
38 	QMultiHash<QString, QString> environmentAliases; ///< environment aliases, especially environments which signify math environments concerning syntax check
39 	CommandDescriptionHash commandDescriptions; ///< command definitions
40 	void unite(LatexPackage &add, bool forCompletion = false); ///< merge with LatexPackage \a add
41 };
42 
43 LatexPackage loadCwlFile(const QString fileName, LatexCompleterConfig *config = nullptr, QStringList conditions = QStringList());
44 
45 
46 #endif // LATEXPACKAGE_H
47