mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r15324) -Codechange: unify the class used for comparing of strings for std::map
This commit is contained in:
parent
d23db8306e
commit
5ad1cd32b2
@ -1699,6 +1699,10 @@
|
|||||||
RelativePath=".\..\src\core\sort_func.hpp"
|
RelativePath=".\..\src\core\sort_func.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\core\string_compare_type.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="GUI Source Code"
|
Name="GUI Source Code"
|
||||||
|
@ -1696,6 +1696,10 @@
|
|||||||
RelativePath=".\..\src\core\sort_func.hpp"
|
RelativePath=".\..\src\core\sort_func.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\core\string_compare_type.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="GUI Source Code"
|
Name="GUI Source Code"
|
||||||
|
@ -370,6 +370,7 @@ core/random_func.hpp
|
|||||||
core/smallmap_type.hpp
|
core/smallmap_type.hpp
|
||||||
core/smallvec_type.hpp
|
core/smallvec_type.hpp
|
||||||
core/sort_func.hpp
|
core/sort_func.hpp
|
||||||
|
core/string_compare_type.hpp
|
||||||
|
|
||||||
# GUI Source Code
|
# GUI Source Code
|
||||||
aircraft_gui.cpp
|
aircraft_gui.cpp
|
||||||
|
@ -7,11 +7,9 @@
|
|||||||
|
|
||||||
#include "api/ai_event_types.hpp"
|
#include "api/ai_event_types.hpp"
|
||||||
#include "../date_type.h"
|
#include "../date_type.h"
|
||||||
|
#include "../core/string_compare_type.hpp"
|
||||||
|
|
||||||
#ifndef AI_CONFIG_HPP
|
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
|
||||||
struct ltstr { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } };
|
|
||||||
#endif /* AI_CONFIG_HPP */
|
|
||||||
typedef std::map<const char *, class AIInfo *, ltstr> AIInfoList;
|
|
||||||
|
|
||||||
|
|
||||||
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||||
|
@ -7,14 +7,11 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "ai_info.hpp"
|
#include "ai_info.hpp"
|
||||||
|
#include "../core/string_compare_type.hpp"
|
||||||
#ifndef AI_HPP
|
|
||||||
struct ltstr { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } };
|
|
||||||
#endif /* AI_HPP */
|
|
||||||
|
|
||||||
class AIConfig {
|
class AIConfig {
|
||||||
private:
|
private:
|
||||||
typedef std::map<const char *, int, ltstr> SettingValueList;
|
typedef std::map<const char *, int, StringCompare> SettingValueList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AIConfig() :
|
AIConfig() :
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#ifndef AI_SCANNER_HPP
|
#ifndef AI_SCANNER_HPP
|
||||||
#define AI_SCANNER_HPP
|
#define AI_SCANNER_HPP
|
||||||
|
|
||||||
|
#include "../core/string_compare_type.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class AIScanner {
|
class AIScanner {
|
||||||
@ -73,7 +74,7 @@ public:
|
|||||||
bool HasAI(const struct ContentInfo *ci, bool md5sum);
|
bool HasAI(const struct ContentInfo *ci, bool md5sum);
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
typedef std::map<const char *, class AILibrary *, ltstr> AILibraryList;
|
typedef std::map<const char *, class AILibrary *, StringCompare> AILibraryList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan the AI dir for scripts.
|
* Scan the AI dir for scripts.
|
||||||
|
@ -5,10 +5,8 @@
|
|||||||
#ifndef AI_CONTROLLER_HPP
|
#ifndef AI_CONTROLLER_HPP
|
||||||
#define AI_CONTROLLER_HPP
|
#define AI_CONTROLLER_HPP
|
||||||
|
|
||||||
|
#include "../../core/string_compare_type.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
#ifndef AI_HPP
|
|
||||||
struct ltstr { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } };
|
|
||||||
#endif /* AI_HPP */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Controller, the class each AI should extend. It creates the AI, makes
|
* The Controller, the class each AI should extend. It creates the AI, makes
|
||||||
@ -85,7 +83,7 @@ public:
|
|||||||
static void Print(bool error_msg, const char *message);
|
static void Print(bool error_msg, const char *message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<const char *, const char *, ltstr> LoadedLibraryList;
|
typedef std::map<const char *, const char *, StringCompare> LoadedLibraryList;
|
||||||
|
|
||||||
uint ticks;
|
uint ticks;
|
||||||
LoadedLibraryList loaded_library;
|
LoadedLibraryList loaded_library;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "base.hpp"
|
#include "base.hpp"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
#include "../string_func.h"
|
#include "../string_func.h"
|
||||||
|
#include "../core/string_compare_type.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if defined(WITH_COCOA)
|
#if defined(WITH_COCOA)
|
||||||
@ -21,13 +22,6 @@ class BlitterFactoryBase {
|
|||||||
private:
|
private:
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
struct StringCompare {
|
|
||||||
bool operator () (const char *a, const char *b) const
|
|
||||||
{
|
|
||||||
return strcmp(a, b) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<const char *, BlitterFactoryBase *, StringCompare> Blitters;
|
typedef std::map<const char *, BlitterFactoryBase *, StringCompare> Blitters;
|
||||||
|
|
||||||
static Blitters &GetBlitters()
|
static Blitters &GetBlitters()
|
||||||
|
15
src/core/string_compare_type.hpp
Normal file
15
src/core/string_compare_type.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file string_compare_type.hpp Comparator class for "const char *" so it can be used as a key for std::map */
|
||||||
|
|
||||||
|
#ifndef STRING_COMPARE_TYPE_HPP
|
||||||
|
#define STRING_COMPARE_TYPE_HPP
|
||||||
|
|
||||||
|
struct StringCompare {
|
||||||
|
bool operator () (const char *a, const char *b) const
|
||||||
|
{
|
||||||
|
return strcmp(a, b) < 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* STRING_COMPARE_TYPE_HPP */
|
@ -6,6 +6,7 @@
|
|||||||
#define DRIVER_H
|
#define DRIVER_H
|
||||||
|
|
||||||
#include "core/enum_type.hpp"
|
#include "core/enum_type.hpp"
|
||||||
|
#include "core/string_compare_type.hpp"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -39,13 +40,6 @@ private:
|
|||||||
const char *name;
|
const char *name;
|
||||||
int priority;
|
int priority;
|
||||||
|
|
||||||
struct StringCompare {
|
|
||||||
bool operator () (const char *a, const char *b) const
|
|
||||||
{
|
|
||||||
return strcmp(a, b) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers;
|
typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers;
|
||||||
|
|
||||||
static Drivers &GetDrivers()
|
static Drivers &GetDrivers()
|
||||||
|
Loading…
Reference in New Issue
Block a user