1 // This is a simple class to handle character maps
2 // (Paul Brannan 6/25/98)
3 
4 #pragma once
5 
6 class TCharmap {
7 private:
8 	char *map[256];
9 	char *current_map;
10 public:
11 	TCharmap();
12 	~TCharmap();
13 
14 	void init() {}
15 
16 	char translate(char c, char mapchar) {
17 		if(map[(unsigned char)mapchar]) return map[(unsigned char)mapchar][(unsigned char)c];
18 		return c;
19 	}
20 	char translate(char c) {
21 		return current_map[(unsigned char)c];
22 	}
23 
24 	void setmap(char mapchar) {
25 		if(map[(unsigned char)mapchar]) current_map = map[(unsigned char)mapchar];
26 	}
27 
28 	void translate_buffer(char *start, char *end) {
29 		while(start < end) {
30 			*start = translate(*start);
31 			start++;
32 		}
33 	}
34 
35 	void modmap(char pos, char mapchar, char c);
36 
37 	int enabled;
38 };
39