Debian Codegraph @

plugins/dm.editing/MissionInfoTextFile.h

raw
1 #pragma once
2
3 #include <string>
4 #include <memory>
5 #include <stdexcept>
6
7 namespace map
8 {
9
10 /**
11 * Base declaration of a text file containing mission
12 * information such as readme.txt and darkmod.txt.
13 */
14 class MissionInfoTextFile
15 {
16 public:
17 class ParseException :
18 public std::runtime_error
19 {
20 public:
21 ParseException(const std::string& msg) :
22 runtime_error(msg.c_str())
23 {}
24 };
25
26 // The filename of this file, e.g. "darkmod.txt"
27 virtual std::string getFilename() = 0;
28
29 // The full path to the description file
30 virtual std::string getFullOutputPath();
31
32 // Saves the contents of this instance to the path applicable to the current mod
33 // Throws a std::runtime_error if the file couldn't be written
34 virtual void saveToCurrentMod();
35
36 // Retrieves the text representation of this instance, as it will be written to the darkmod.txt file
37 virtual std::string toString() = 0;
38
39 protected:
40 // Returns the mod output path (normalised with trailing slash, without the filename part)
41 static std::string GetOutputPathForCurrentMod();
42 };
43
44 }