1 |
douglas |
260 |
// Vance Thrift and Biller File Utility 2 |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
douglas |
265 |
// $Id: IndividualClient.cxx,v 1.2 2003/08/17 03:55:39 douglas Exp $ |
6 |
douglas |
260 |
|
7 |
|
|
#include "IndividualClient.h" |
8 |
douglas |
265 |
|
9 |
|
|
unsigned IndividualClient::getNumber(void) |
10 |
|
|
{ |
11 |
|
|
if (number == 0) |
12 |
|
|
{ |
13 |
|
|
demunge(); |
14 |
|
|
} |
15 |
|
|
|
16 |
|
|
return number; |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
string IndividualClient::getName(void) |
20 |
|
|
{ |
21 |
|
|
if (name == "") |
22 |
|
|
{ |
23 |
|
|
demunge(); |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
return name; |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
string IndividualClient::getFile(void) |
30 |
|
|
{ |
31 |
|
|
if (file == "") |
32 |
|
|
{ |
33 |
|
|
ostringstream file; |
34 |
|
|
|
35 |
|
|
file << number << "_"; |
36 |
|
|
|
37 |
|
|
for (unsigned index = 0; index < name.length(); index++) |
38 |
|
|
{ |
39 |
|
|
if (isspace(name[index])) |
40 |
|
|
{ |
41 |
|
|
file << '_'; |
42 |
|
|
} |
43 |
|
|
else if (name[index] != ',' && name[index] != '.') |
44 |
|
|
{ |
45 |
|
|
file << char(tolower(name[index])); |
46 |
|
|
} |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
this->file = file.str(); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
return file; |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
void IndividualClient::setNumber(unsigned number) |
56 |
|
|
{ |
57 |
|
|
this->number = number; |
58 |
|
|
file = ""; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
void IndividualClient::setName(const string& name) |
62 |
|
|
{ |
63 |
|
|
this->name = name; |
64 |
|
|
file = ""; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
void IndividualClient::setFile(const string& file) |
68 |
|
|
{ |
69 |
|
|
this->file = file; |
70 |
|
|
number = 0; |
71 |
|
|
name = ""; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
void IndividualClient::demunge(void) |
75 |
|
|
{ |
76 |
|
|
istringstream file(demunge(this->file)); |
77 |
|
|
|
78 |
|
|
file >> number; |
79 |
|
|
file.get(); |
80 |
|
|
|
81 |
|
|
ostringstream name; |
82 |
|
|
unsigned count = 0; |
83 |
|
|
|
84 |
|
|
do |
85 |
|
|
{ |
86 |
|
|
string word; |
87 |
|
|
|
88 |
|
|
file >> word; |
89 |
|
|
file.get(); |
90 |
|
|
|
91 |
|
|
if (word.length() == 1) word += '.'; |
92 |
|
|
|
93 |
|
|
if (word.length() > 2 && word.find("mc") == 0) |
94 |
|
|
{ |
95 |
|
|
capitalize(word, 2); |
96 |
|
|
} |
97 |
|
|
else if (word.length() > 3 && word.find("mac") == 0) |
98 |
|
|
{ |
99 |
|
|
capitalize(word, 3); |
100 |
|
|
} |
101 |
|
|
else if (word.length() > 2 && word.find("o\'") == 0) |
102 |
|
|
{ |
103 |
|
|
capitalize(word, 2); |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
capitalize(word); |
107 |
|
|
|
108 |
|
|
switch (++count) |
109 |
|
|
{ |
110 |
|
|
case 1: |
111 |
|
|
name << word; |
112 |
|
|
break; |
113 |
|
|
case 2: |
114 |
|
|
name << ", " << word; |
115 |
|
|
break; |
116 |
|
|
default: |
117 |
|
|
name << " " << word; |
118 |
|
|
break; |
119 |
|
|
} |
120 |
|
|
} |
121 |
|
|
while (file.good()); |
122 |
|
|
|
123 |
|
|
this->name = name.str(); |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
string IndividualClient::demunge(const string& munged) |
127 |
|
|
{ |
128 |
|
|
string demunged; |
129 |
|
|
|
130 |
|
|
for (unsigned index = 0; index < munged.length(); index++) |
131 |
|
|
{ |
132 |
|
|
if (munged[index] == '_') |
133 |
|
|
{ |
134 |
|
|
demunged += ' '; |
135 |
|
|
} |
136 |
|
|
else |
137 |
|
|
{ |
138 |
|
|
demunged += munged[index]; |
139 |
|
|
} |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
return demunged; |
143 |
|
|
} |