2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: IndividualClient.cxx,v 1.2 2003/08/17 03:55:39 douglas Exp $ |
5 |
> |
// $Id: IndividualClient.cxx,v 1.6 2003/08/21 06:29:24 douglas Exp $ |
6 |
|
|
7 |
|
#include "IndividualClient.h" |
8 |
|
|
32 |
|
{ |
33 |
|
ostringstream file; |
34 |
|
|
35 |
< |
file << number << "_"; |
35 |
> |
file << number; |
36 |
|
|
37 |
< |
for (unsigned index = 0; index < name.length(); index++) |
37 |
> |
istringstream name(this->name); |
38 |
> |
|
39 |
> |
do |
40 |
|
{ |
41 |
< |
if (isspace(name[index])) |
42 |
< |
{ |
43 |
< |
file << '_'; |
44 |
< |
} |
45 |
< |
else if (name[index] != ',' && name[index] != '.') |
41 |
> |
string word; |
42 |
> |
|
43 |
> |
name >> word; |
44 |
> |
name.get(); |
45 |
> |
|
46 |
> |
unsigned punk; |
47 |
> |
|
48 |
> |
do |
49 |
|
{ |
50 |
< |
file << char(tolower(name[index])); |
50 |
> |
punk = word.find_first_of(",."); |
51 |
> |
|
52 |
> |
if (punk != string::npos) word.erase(punk, 1); |
53 |
|
} |
54 |
+ |
while (punk != string::npos); |
55 |
+ |
|
56 |
+ |
lowercase(word); |
57 |
+ |
|
58 |
+ |
file << "_" << word; |
59 |
|
} |
60 |
+ |
while (name.good()); |
61 |
|
|
62 |
< |
this->file = file.str(); |
62 |
> |
this->file = file.str() + '.' + extension; |
63 |
|
} |
64 |
|
|
65 |
|
return file; |
84 |
|
name = ""; |
85 |
|
} |
86 |
|
|
87 |
+ |
string IndividualClient::extension = "pdf"; |
88 |
+ |
|
89 |
|
void IndividualClient::demunge(void) |
90 |
|
{ |
91 |
|
istringstream file(demunge(this->file)); |
94 |
|
file.get(); |
95 |
|
|
96 |
|
ostringstream name; |
97 |
< |
unsigned count = 0; |
97 |
> |
unsigned count = 1; |
98 |
|
|
99 |
|
do |
100 |
|
{ |
103 |
|
file >> word; |
104 |
|
file.get(); |
105 |
|
|
106 |
< |
if (word.length() == 1) word += '.'; |
107 |
< |
|
108 |
< |
if (word.length() > 2 && word.find("mc") == 0) |
106 |
> |
if (word.length() == 1) |
107 |
> |
{ |
108 |
> |
if (isalpha(word[0])) word += '.'; |
109 |
> |
} |
110 |
> |
else if (word == "jr" || word == "sr" || word == "dr" || word == "mr" |
111 |
> |
|| word == "ms" || word == "mrs") |
112 |
> |
{ |
113 |
> |
word += '.'; |
114 |
> |
} |
115 |
> |
else if (word == "de" && count == 1) |
116 |
> |
{ |
117 |
> |
--count; |
118 |
> |
} |
119 |
> |
else if (word == "ii" || word == "iv" || word == "iv") |
120 |
> |
{ |
121 |
> |
capitalize(word += '.', 0, 2); |
122 |
> |
} |
123 |
> |
else if (word == "iii") |
124 |
> |
{ |
125 |
> |
capitalize(word += '.', 0, 3); |
126 |
> |
} |
127 |
> |
else if (word.length() > 2 && word.find("mc") == 0) |
128 |
|
{ |
129 |
|
capitalize(word, 2); |
130 |
|
} |
136 |
|
{ |
137 |
|
capitalize(word, 2); |
138 |
|
} |
139 |
+ |
else if (word.length() > 1) |
140 |
+ |
{ |
141 |
+ |
if (!isalpha(word[0])) |
142 |
+ |
{ |
143 |
+ |
capitalize(word, 1); |
144 |
+ |
} |
145 |
+ |
} |
146 |
|
|
147 |
|
capitalize(word); |
148 |
|
|
149 |
|
switch (++count) |
150 |
|
{ |
151 |
|
case 1: |
152 |
< |
name << word; |
152 |
> |
name << word << " "; |
153 |
|
break; |
154 |
|
case 2: |
155 |
+ |
name << word; |
156 |
+ |
break; |
157 |
+ |
case 3: |
158 |
|
name << ", " << word; |
159 |
|
break; |
160 |
|
default: |
171 |
|
{ |
172 |
|
string demunged; |
173 |
|
|
174 |
< |
for (unsigned index = 0; index < munged.length(); index++) |
174 |
> |
for (unsigned index = 0; index < munged.length() - extension.length() - 1; |
175 |
> |
index++) |
176 |
|
{ |
177 |
|
if (munged[index] == '_') |
178 |
|
{ |
186 |
|
|
187 |
|
return demunged; |
188 |
|
} |
189 |
+ |
|
190 |
+ |
void IndividualClient::capitalize(string& word, unsigned index, unsigned count) |
191 |
+ |
{ |
192 |
+ |
for (unsigned number = index; number < index + count; number++) |
193 |
+ |
{ |
194 |
+ |
word[number] = toupper(word[number]); |
195 |
+ |
} |
196 |
+ |
} |