1 /*
2 ===========================================================================
3 Copyright (C) 2000 - 2013, Raven Software, Inc.
4 Copyright (C) 2001 - 2013, Activision, Inc.
5 Copyright (C) 2013 - 2015, OpenJK contributors
6 
7 This file is part of the OpenJK source code.
8 
9 OpenJK is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 ===========================================================================
21 */
22 
23 #include "../server/exe_headers.h"
24 
25 // Filename:-	tr_stl.cpp
26 //
27 // I mainly made this file because I was getting sick of all the stupid error messages in MS's STL implementation,
28 //	and didn't want them showing up in the renderer files they were used in. This way keeps them more or less invisible
29 //	because of minimal dependancies
30 //
31 #include "tr_local.h"	// this isn't actually needed other than getting rid of warnings via pragmas
32 #include "tr_stl.h"
33 
34 #include <map>
35 #include "../qcommon/sstring.h"	// #include <string>
36 
37 typedef std::map<sstring_t, const char *>	ShaderEntryPtrs_t;
38 typedef ShaderEntryPtrs_t::size_type	ShaderEntryPtr_size;
39 										ShaderEntryPtrs_t ShaderEntryPtrs;
40 
ShaderEntryPtrs_Clear(void)41 void ShaderEntryPtrs_Clear(void)
42 {
43 	ShaderEntryPtrs.clear();
44 }
45 
46 
ShaderEntryPtrs_Size(void)47 int ShaderEntryPtrs_Size(void)
48 {
49 	return ShaderEntryPtrs.size();
50 }
51 
ShaderEntryPtrs_Insert(const char * token,const char * p)52 void ShaderEntryPtrs_Insert(const char *token, const char *p)
53 {
54 	ShaderEntryPtrs_t::iterator it = ShaderEntryPtrs.find(token);
55 
56 	if (it == ShaderEntryPtrs.end())
57 	{
58 		ShaderEntryPtrs[token] = p;
59 	}
60 	else
61 	{
62 		ri.Printf( PRINT_DEVELOPER, "Duplicate shader entry %s!\n",token );
63 	}
64 }
65 
66 // returns NULL if not found...
67 //
ShaderEntryPtrs_Lookup(const char * psShaderName)68 const char *ShaderEntryPtrs_Lookup(const char *psShaderName)
69 {
70 	ShaderEntryPtrs_t::iterator it = ShaderEntryPtrs.find(psShaderName);
71 	if (it != ShaderEntryPtrs.end())
72 	{
73 		const char *p = (*it).second;
74 		return p;
75 	}
76 
77 	return NULL;
78 }
79