OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
41 if (parm.empty())
return nullptr;
43 size_t len = strlen(name);
44 for (
auto &p : parm) {
45 if (p.compare(0, len, name) == 0) {
46 if (p.length() == len)
return "";
47 if (p[len] ==
'=')
return p.c_str() + len + 1;
74 return p !=
nullptr ? atoi(p) : def;
118 const char *err = newd->
Start({});
119 if (err ==
nullptr) {
133 std::istringstream buffer(
name);
135 std::getline(buffer, dname,
':');
138 std::vector<std::string> parms;
139 while (std::getline(buffer, param,
',')) {
140 parms.push_back(param);
152 if (strcasecmp(dname.c_str(), d->
name) != 0)
continue;
157 const char *err = newd->
Start(parms);
158 if (err !=
nullptr) {
160 usererror(
"Unable to load driver '%s'. The error was: %s", d->
name, err);
207 type(type), priority(priority), name(name), description(description)
214 std::pair<Drivers::iterator, bool> P =
GetDrivers().insert(Drivers::value_type(buf,
this));
228 Drivers::iterator it =
GetDrivers().find(buf);
static const char * GetDriverTypeName(Driver::Type type)
Get the driver type name.
static bool SelectDriverImpl(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
static Driver ** GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
Dimensions (a width and height) of a rectangle in 2D.
const char * name
The name of the drivers of this factory.
std::string _ini_blitter
The blitter as stored in the configuration file.
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description)
Construct a new DriverFactory.
virtual Driver * CreateInstance() const =0
Create an instance of this driver-class.
virtual ~DriverFactoryBase()
Frees memory used for this->name.
const char * GetDriverParam(const StringList &parm, const char *name)
Get a string parameter the list of parameters.
static Drivers & GetDrivers()
Get the map with drivers.
std::string _ini_musicdriver
The music driver a stored in the configuration file.
int priority
The priority of this factory.
static char * GetDriversInfo(char *p, const char *last)
Build a human readable list of available drivers, grouped by type.
#define DEBUG(name, level,...)
Output a line of debugging information.
virtual const char * Start(const StringList &parm)=0
Start this driver.
Driver::Type type
The type of driver.
std::vector< std::string > StringList
Type for a list of strings.
std::vector< Dimension > _resolutions
List of resolutions.
@ DT_END
Helper for iteration.
int GetDriverParamInt(const StringList &parm, const char *name, int def)
Get an integer parameter the list of parameters.
bool _rightclick_emulate
Whether right clicking is emulated.
@ DT_BEGIN
Helper for iteration.
bool _blitter_autodetected
Was the blitter autodetected or specified by the user?
std::string _ini_sounddriver
The sound driver a stored in the configuration file.
const char * GetDescription() const
Get a nice description of the driver-class.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
static void SelectDriver(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
A driver for communicating with the user.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
#define lastof(x)
Get the last element of an fixed size array.
bool GetDriverParamBool(const StringList &parm, const char *name)
Get a boolean parameter the list of parameters.
Dimension _cur_resolution
The current resolution.
Base for all driver factories.
std::string _ini_videodriver
The video driver a stored in the configuration file.