xconfig.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <sstream>
4 #include <string>
5 
6 namespace nmx::settings {
7 
11 struct Config {
12 private:
13  //in diesem Verzeichnis werden Dateien mit Daten geschrieben
14  inline static std::string current_directory;
15 
16 public:
17  // Basisverzeichnis, alle anderen
18  // Verzeichnisse befinden sich in diesem Verzeichnis
19  inline static const std::string home_directory = ".";
20 
21  // Daten werden in Unterverzeichnisse dieses
22  // Verzeichnisses kopiert
23  inline static const std::string data_directory = home_directory + "/data";
24 
30  inline static void set_current_dir(const std::string &dirname) { //
31  current_directory = dirname;
32  }
33 
39  inline static std::string get_current_dir(bool flag = true) { //
40  return flag ? (data_directory + "/" + current_directory) : current_directory;
41  }
42 
48  inline static std::string get_current_file(const std::string &fname) { //
49  return get_current_dir() + "/" + fname;
50  }
51 
59  inline static std::string get_current_file(const char *fname, const char *ext) { //
60  std::stringstream sstream;
61  sstream << fname << "." << ext;
62  return get_current_file(sstream.str());
63  }
64 }; //Config
65 
66 } // namespace nmx::settings
static void set_current_dir(const std::string &dirname)
set_current_dir setze Namen des aktuellen Datenverzeichnisses
Definition: xconfig.h:30
static std::string get_current_file(const std::string &fname)
get_current_file gebe vollständigen Pfad zu einer Datei
Definition: xconfig.h:48
static const std::string home_directory
Definition: xconfig.h:19
The Config struct Speicherung von Konfigurationsdaten.
Definition: xconfig.h:11
static std::string get_current_file(const char *fname, const char *ext)
get_current_file gebe vollständigen Pfad zu einer Datei kann mit der Compiler-Variablen func genutzt ...
Definition: xconfig.h:59
const std::string dirname
Definition: x006.h:19
static const std::string data_directory
Definition: xconfig.h:23
static std::string get_current_dir(bool flag=true)
get_current_dir gebe aktuelles Datenverzeichnis
Definition: xconfig.h:39