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
|
/* Copyright (c) 2021, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */
#pragma once
#include "ScriptJob.h"
/* Parses script files. */
class CScriptParser
{
const std::vector<std::string> m_allKeys{ ScriptInterface::AllScriptKeysStr() }; // All possible script keys.
std::vector<std::unique_ptr<CScriptJob>> m_jobs; // All parsed jobs.
public:
// Opens a _script file and parses it.
CScriptParser(const std::filesystem::path& _script);
// Returns the number of parsed jobs.
[[nodiscard]] size_t JobsCount() const;
// Returns all parsed jobs.
[[nodiscard]] std::vector<const CScriptJob*> Jobs() const;
private:
// Parses the script.
void Parse(const std::filesystem::path& _script);
// Process a single line of a script file, cleared from comments.
void ProcessLine(const std::string& _line);
// Post-process read entries by resolving named variables to their end values.
void NamesToKeys() const;
};
|