blob: 6058cc43ffbcaac4a62ff235dc2e9af7118f4253 (
plain) (
blame)
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
62
63
|
/*********************************************************************
cstrpool.h
Constant string pool helper class.
*********************************************************************/
#pragma once
#ifndef __CSTRPOOL_H_
#define __CSTRPOOL_H_
#include "coretmpl.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> const_string_pool
// a pool to hold constant strings efficiently
class const_string_pool
{
public:
// construction
const_string_pool();
// operations
void reset() { m_chunklist.reset(); }
const char *add(const char *string);
bool contains(const char *string);
private:
// shared string pool
class pool_chunk
{
static const int POOL_SIZE = 4096;
friend class simple_list<pool_chunk>;
public:
// construction
pool_chunk();
// getters
pool_chunk *next() const { return m_next; }
// operations
const char *add(const char *string);
bool contains(const char *string) const { return (string >= m_buffer && string < &m_buffer[POOL_SIZE]); }
private:
// internal state
pool_chunk * m_next;
UINT32 m_used;
char m_buffer[POOL_SIZE];
};
simple_list<pool_chunk> m_chunklist;
};
#endif
|