-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.cpp
33 lines (27 loc) · 816 Bytes
/
util.cpp
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
/*************************************************************
*
* Copyright (C) 2010 John O'Laughlin
*
* All rights reserved.
*
*************************************************************
*/
#include "util.h"
using namespace std;
void Util::writeBlankLetter(ostream &o, uchar letter) {
o << (char)(letter - FIRST_LETTER + 'a');
}
void Util::writeLetter(ostream &o, uchar letter) {
o << (char)(letter - FIRST_LETTER + 'A');
}
void Util::writeTile(ostream &o, uchar tile) {
if (tile == BLANK) o << '?';
else writeLetter(o, tile);
}
uint Util::charToIndex(uchar c) {
int i;
if ((c >= 'a') && (c <= 'z')) return c + FIRST_LETTER - 'a';
if ((c >= 'A') && (c <= 'Z')) return c + FIRST_LETTER - 'A';
if ((c == '?') || (c == '.')) return i = BLANK;
return EMPTY_SQUARE;
}