The Battle for Wesnoth  1.15.2+dev
name_generator.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "global.hpp"
18 
19 #include <string>
20 #include <map>
21 #include <exception>
22 
23 class name_generator_invalid_exception : public std::exception {
24 public:
25  name_generator_invalid_exception(const char* errMessage):errMessage_(errMessage) {}
26  const char* what() const noexcept { return errMessage_; }
27 
28 private:
29  const char* errMessage_;
30 };
31 
32 
34 public:
35  // Defined in name_generator_factory.cpp
36  std::string generate(const std::map<std::string,std::string>& variables) const;
37  virtual std::string generate() const { return ""; }
39  virtual ~name_generator() {}
40 };
41 
44 public:
45  proxy_name_generator(const name_generator& b) : base(b) {}
46  std::string generate() const override { return base.generate(); }
47 };
std::string generate(const std::map< std::string, std::string > &variables) const
virtual std::string generate() const
#define b
const name_generator & base
virtual ~name_generator()
proxy_name_generator(const name_generator &b)
name_generator_invalid_exception(const char *errMessage)
std::string generate() const override
const char * what() const noexcept