-
Notifications
You must be signed in to change notification settings - Fork 1
/
stringtable.h
59 lines (51 loc) · 1.75 KB
/
stringtable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
////////////////////////////////////////////////////////////////////////////////
// DScript Scripting Language
// Copyright (C) 2003 Bryan "daerid" Ross
//
// Permission to copy, use, modify, sell and distribute this software is
// granted provided this copyright notice appears in all copies. This
// software is provided "as is" without express or implied warranty, and
// with no claim as to its suitability for any purpose.
////////////////////////////////////////////////////////////////////////////////
#ifndef __DSCRIPT_STRINGTABLE_H__
#define __DSCRIPT_STRINGTABLE_H__
////////////////////////////////////////////////////////////////////////////////
// Standard Library Includes
#include <string>
#include <set>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// For GCC
#ifdef __GNUC__
#include <strings.h>
#endif
////////////////////////////////////////////////////////////////////////////////
namespace dscript
{
/// Maintains a list of strings in use by the runtime
class string_table
{
public:
typedef const char* entry;
entry insert(const std::string& val);
entry find(const std::string& val);
private:
std::set<std::string> m_strings;
};
/// Used to compare two string_table::entries
struct cmp_ste
{
bool operator()(string_table::entry left,string_table::entry right) const
{
#ifdef _MSC_VER
return _stricmp(left,right) < 0;
#endif
#ifdef __GNUC__
return strcasecmp(left, right) < 0;
#endif
}
};
std::string escape(const std::string& str);
std::string unescape(const std::string& str);
}
#endif//__DSCRIPT_STRINGTABLE_H__