summaryrefslogtreecommitdiffstats
path: root/3rdparty/clucene/src/CLucene/util/StringIntern.h
blob: ded060c6493be0140a05967874a74ebc97318fac (plain)
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
60
61
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#ifndef _lucene_util_StringIntern_H
#define _lucene_util_StringIntern_H

#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif

#include "VoidMap.h"
CL_NS_DEF(util)
typedef CL_NS(util)::CLHashMap<const TCHAR*,int,CL_NS(util)::Compare::TChar,CL_NS(util)::Equals::TChar,CL_NS(util)::Deletor::tcArray, CL_NS(util)::Deletor::DummyInt32 > __wcsintrntype;
typedef CL_NS(util)::CLHashMap<const char*,int,CL_NS(util)::Compare::Char,CL_NS(util)::Equals::Char,CL_NS(util)::Deletor::acArray, CL_NS(util)::Deletor::DummyInt32 > __strintrntype;

  /** Functions for intern'ing strings. This
  * is a process of pooling strings thus using less memory,
  * and furthermore allows intern'd strings to be directly
  * compared:
  * string1==string2, rather than _tcscmp(string1,string2)
  */
  class CLStringIntern{
	  static __wcsintrntype stringPool;
	  static __strintrntype stringaPool;
	  STATIC_DEFINE_MUTEX(THIS_LOCK)
  public:
	/** 
	* Internalise the specified string.
	* \return Returns a pointer to the internalised string
	*/
	static const char* internA(const char* str CL_FILELINEPARAM);
	/** 
	* Uninternalise the specified string. Decreases
	* the reference count and frees the string if 
	* reference count is zero
	* \returns true if string was destroyed, otherwise false
	*/
	static bool uninternA(const char* str);

	/** 
	* Internalise the specified string.
	* \return Returns a pointer to the internalised string
	*/
	static const TCHAR* intern(const TCHAR* str CL_FILELINEPARAM);
	
	/** 
	* Uninternalise the specified string. Decreases
	* the reference count and frees the string if 
	* reference count is zero
	* \returns true if string was destroyed, otherwise false
	*/
	static bool unintern(const TCHAR* str);

    static void shutdown();
  };

CL_NS_END
#endif