Crossfire Server, Trunk
WrapperLoader.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2020-2021 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #ifndef WRAPPERLOADER_H
14 #define WRAPPERLOADER_H
15 
16 #include "AssetLoader.h"
17 #include "Utils.h"
18 #include <functional>
19 #include <string>
20 extern "C" {
21 #include "global.h"
22 }
23 
27 class WrapperLoader : public AssetLoader {
28 public:
30  typedef std::function<void(BufferReader *, const char *)> wrapped;
31 
37  WrapperLoader(const std::string& name, wrapped fct) : m_name(name), m_function(fct) {
38  };
39 
40  virtual bool willLoad(const std::string &filename) override {
42  }
43 
44  virtual void load(BufferReader *reader, const std::string &filename) override {
45  m_function(reader, filename.c_str());
46  }
47 
48 private:
49  std::string m_name;
51 };
52 
53 #endif /* WRAPPERLOADER_H */
54 
global.h
AssetLoader
Definition: AssetLoader.h:24
npc_dialog.filename
filename
Definition: npc_dialog.py:99
WrapperLoader::m_function
wrapped m_function
Definition: WrapperLoader.h:50
Utils.h
WrapperLoader::wrapped
std::function< void(BufferReader *, const char *)> wrapped
Definition: WrapperLoader.h:30
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
WrapperLoader::WrapperLoader
WrapperLoader(const std::string &name, wrapped fct)
Definition: WrapperLoader.h:37
WrapperLoader::load
virtual void load(BufferReader *reader, const std::string &filename) override
Definition: WrapperLoader.h:44
Utils::endsWith
static bool endsWith(const std::string &str, const std::string &with)
Definition: Utils.cpp:16
WrapperLoader::m_name
std::string m_name
Definition: WrapperLoader.h:49
WrapperLoader::willLoad
virtual bool willLoad(const std::string &filename) override
Definition: WrapperLoader.h:40
WrapperLoader
Definition: WrapperLoader.h:27
BufferReader
Definition: bufferreader.c:21
AssetLoader.h
give.name
name
Definition: give.py:27