File: MissionInfoTextFile.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (44 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download | duplicates (5)
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
#pragma once

#include <string>
#include <memory>
#include <stdexcept>

namespace map
{

/**
* Base declaration of a text file containing mission
* information such as readme.txt and darkmod.txt.
*/
class MissionInfoTextFile
{
public:
	class ParseException :
		public std::runtime_error
	{
	public:
		ParseException(const std::string& msg) :
			runtime_error(msg.c_str())
		{}
	};

	// The filename of this file, e.g. "darkmod.txt"
	virtual std::string getFilename() = 0;

	// The full path to the description file
	virtual std::string getFullOutputPath();

	// Saves the contents of this instance to the path applicable to the current mod
	// Throws a std::runtime_error if the file couldn't be written
	virtual void saveToCurrentMod();

	// Retrieves the text representation of this instance, as it will be written to the darkmod.txt file
	virtual std::string toString() = 0;

protected:
	// Returns the mod output path (normalised with trailing slash, without the filename part)
	static std::string GetOutputPathForCurrentMod();
};

}