The Battle for Wesnoth  1.15.12+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 <string>
18 #include <map>
19 #include <exception>
20 
21 class name_generator_invalid_exception : public std::exception {
22 public:
23  name_generator_invalid_exception(const char* errMessage):errMessage_(errMessage) {}
24  const char* what() const noexcept { return errMessage_; }
25 
26 private:
27  const char* errMessage_;
28 };
29 
30 
32 public:
33  // Defined in name_generator_factory.cpp
34  std::string generate(const std::map<std::string,std::string>& variables) const;
35  virtual std::string generate() const { return ""; }
37  virtual ~name_generator() {}
38 };
39 
42 public:
43  proxy_name_generator(const name_generator& b) : base(b) {}
44  std::string generate() const override { return base.generate(); }
45 };
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