1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#pragma once
#include <map>
#include "ideclmanager.h"
#include "DeclarationFile.h"
#include "parser/ThreadedDeclParser.h"
#include "string/string.h"
namespace decl
{
class DeclarationManager;
using ParseResult = std::map<Type, std::vector<DeclarationBlockSyntax>>;
// Threaded parser processing all files in the configured decl folder
// Submits all parsed declarations to the IDeclarationManager when finished
class DeclarationFolderParser :
public parser::ThreadedDeclParser<void>
{
private:
DeclarationManager& _owner;
// Maps typename string ("material") to Type enum (Type::Material)
std::map<std::string, Type, string::ILess> _typeMapping;
// Holds all the identified blocks of all visited files
ParseResult _parsedBlocks;
// The default type to assign to untyped blocks
Type _defaultDeclType;
public:
DeclarationFolderParser(DeclarationManager& owner, Type declType,
const std::string& baseDir, const std::string& extension,
const std::map<std::string, Type, string::ILess>& typeMapping);
~DeclarationFolderParser() override
{
// Ensure that reset() is called while this class is still intact
reset();
}
protected:
void parse(std::istream& stream, const vfs::FileInfo& fileInfo, const std::string& modDir) override;
void onFinishParsing() override;
private:
Type determineBlockType(const DeclarationBlockSyntax& block);
};
}
|