Changeset - r10985:c2507f106432
[Not reviewed]
master
0 9 1
smatz - 15 years ago 2009-02-03 18:08:07
smatz@openttd.org
(svn r15324) -Codechange: unify the class used for comparing of strings for std::map
10 files changed with 34 insertions and 28 deletions:
0 comments (0 inline, 0 general)
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -1696,12 +1696,16 @@
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\core\sort_func.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\core\string_compare_type.hpp"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="GUI Source Code"
 
			>
 
			<File
 
				RelativePath=".\..\src\aircraft_gui.cpp"
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -1693,12 +1693,16 @@
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\core\sort_func.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\core\string_compare_type.hpp"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="GUI Source Code"
 
			>
 
			<File
 
				RelativePath=".\..\src\aircraft_gui.cpp"
source.list
Show inline comments
 
@@ -367,12 +367,13 @@ core/mem_func.hpp
 
core/overflowsafe_type.hpp
 
core/random_func.cpp
 
core/random_func.hpp
 
core/smallmap_type.hpp
 
core/smallvec_type.hpp
 
core/sort_func.hpp
 
core/string_compare_type.hpp
 

	
 
# GUI Source Code
 
aircraft_gui.cpp
 
airport_gui.cpp
 
autoreplace_gui.cpp
 
bridge_gui.cpp
src/ai/ai.hpp
Show inline comments
 
@@ -4,17 +4,15 @@
 

	
 
#ifndef AI_HPP
 
#define AI_HPP
 

	
 
#include "api/ai_event_types.hpp"
 
#include "../date_type.h"
 
#include "../core/string_compare_type.hpp"
 

	
 
#ifndef AI_CONFIG_HPP
 
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;
 
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
 

	
 

	
 
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
 
class AI {
 
public:
src/ai/ai_config.hpp
Show inline comments
 
@@ -4,20 +4,17 @@
 

	
 
#ifndef AI_CONFIG_HPP
 
#define AI_CONFIG_HPP
 

	
 
#include <map>
 
#include "ai_info.hpp"
 

	
 
#ifndef AI_HPP
 
struct ltstr { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } };
 
#endif /* AI_HPP */
 
#include "../core/string_compare_type.hpp"
 

	
 
class AIConfig {
 
private:
 
	typedef std::map<const char *, int, ltstr> SettingValueList;
 
	typedef std::map<const char *, int, StringCompare> SettingValueList;
 

	
 
public:
 
	AIConfig() :
 
		name(NULL),
 
		version(-1),
 
		info(NULL),
src/ai/ai_scanner.hpp
Show inline comments
 
@@ -2,12 +2,13 @@
 

	
 
/** @file ai_scanner.hpp declarations of the class for AI scanner */
 

	
 
#ifndef AI_SCANNER_HPP
 
#define AI_SCANNER_HPP
 

	
 
#include "../core/string_compare_type.hpp"
 
#include <map>
 

	
 
class AIScanner {
 
public:
 
	AIScanner();
 
	~AIScanner();
 
@@ -70,13 +71,13 @@ public:
 
	void RescanAIDir();
 

	
 
#if defined(ENABLE_NETWORK)
 
  bool HasAI(const struct ContentInfo *ci, bool md5sum);
 
#endif
 
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.
 
	 */
 
	void ScanAIDir();
 

	
src/ai/api/ai_controller.hpp
Show inline comments
 
@@ -2,16 +2,14 @@
 

	
 
/** @file ai_controller.hpp The controller of the AI. */
 

	
 
#ifndef AI_CONTROLLER_HPP
 
#define AI_CONTROLLER_HPP
 

	
 
#include "../../core/string_compare_type.hpp"
 
#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
 
 *  sure the logic kicks in correctly, and that GetTick() has a valid value.
 
 */
 
class AIController {
 
@@ -82,13 +80,13 @@ public:
 
	 * @param message The message Squirrel logged.
 
	 * @note Use AILog.Info/Warning/Error instead of 'print'.
 
	 */
 
	static void Print(bool error_msg, const char *message);
 

	
 
private:
 
	typedef std::map<const char *, const char *, ltstr> LoadedLibraryList;
 
	typedef std::map<const char *, const char *, StringCompare> LoadedLibraryList;
 

	
 
	uint ticks;
 
	LoadedLibraryList loaded_library;
 
	int loaded_library_count;
 

	
 
	/**
src/blitter/factory.hpp
Show inline comments
 
@@ -5,12 +5,13 @@
 
#ifndef BLITTER_FACTORY_HPP
 
#define BLITTER_FACTORY_HPP
 

	
 
#include "base.hpp"
 
#include "../debug.h"
 
#include "../string_func.h"
 
#include "../core/string_compare_type.hpp"
 
#include <map>
 

	
 
#if defined(WITH_COCOA)
 
bool QZ_CanDisplay8bpp();
 
#endif /* defined(WITH_COCOA) */
 

	
 
@@ -18,19 +19,12 @@ bool QZ_CanDisplay8bpp();
 
 * The base factory, keeping track of all blitters.
 
 */
 
class BlitterFactoryBase {
 
private:
 
	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;
 

	
 
	static Blitters &GetBlitters()
 
	{
 
		static Blitters &s_blitters = *new Blitters();
 
		return s_blitters;
src/core/string_compare_type.hpp
Show inline comments
 
new file 100644
 
/* $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 */
src/driver.h
Show inline comments
 
@@ -3,12 +3,13 @@
 
/** @file driver.h Base for all drivers (video, sound, music, etc). */
 

	
 
#ifndef DRIVER_H
 
#define DRIVER_H
 

	
 
#include "core/enum_type.hpp"
 
#include "core/string_compare_type.hpp"
 
#include "string_func.h"
 
#include <map>
 

	
 
const char *GetDriverParam(const char * const *parm, const char *name);
 
bool GetDriverParamBool(const char * const *parm, const char *name);
 
int GetDriverParamInt(const char * const *parm, const char *name, int def);
 
@@ -36,19 +37,12 @@ DECLARE_POSTFIX_INCREMENT(Driver::Type);
 
class DriverFactoryBase {
 
private:
 
	Driver::Type type;
 
	const char *name;
 
	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;
 

	
 
	static Drivers &GetDrivers()
 
	{
 
		static Drivers &s_drivers = *new Drivers();
 
		return s_drivers;
0 comments (0 inline, 0 general)