Skip to content

dragokas/SourceMod-StringMapI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

SourceMod-StringMapI

Case insensitive version of StringMap

A wrapper over original SourceMod StringMap allowing to compare keys as case insensitive.

It's done temporarily until the appropriate Issue#1716 in SM Core not fulfilled.

Using

Connect the include

#include <stringmapi>

Replace by StringMapI

Just replace all "StringMap" with "StringMapI". StringMapI inherits StringMap methodmap, so it supports same functions.

Usage example:

#include <sourcemod>
#include <stringmapi>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
	name = "StringMapI use test",
	author = "Dragokas",
	description = "Case insensitive StringMap",
	version = "1.0",
	url = "http://www.sourcemod.net/"
};

public void OnPluginStart()
{
	RegConsoleCmd("sm_smi", CmdTest);
}

public Action CmdTest(int client, int args)
{
	StringMapI map = new StringMapI();

	map.SetString("UserName", "Alex");
	map.SetValue("SCORE", 100);

	int score;
	map.GetValue("score", score);

	char name[32];
	map.GetString("USERNAME", name, sizeof(name)); // OK
	
	// test case insensitive
	PrintToServer("MethodMapI 'USERNAME' value: %s", name);
	PrintToServer("MethodMapI 'score' value: %i", score);
	
	// test inherited members
	PrintToServer("MethodMapI size: %i", map.Size);
	return Plugin_Handled;
}

Limitation

Case sensitivity is only applicable for latin characters. Atm, there is no support for Russian and other non-English specific characters.

About

Case insensitive version of StringMap

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors