ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/IndividualClient.cxx
Revision: 271
Committed: 2003-08-19T22:49:34-07:00 (21 years, 10 months ago) by douglas
File size: 2890 byte(s)
Log Message:
Start page of ScanUtility pretty much works.

File Contents

# Content
1 // Vance Thrift and Biller File Utility 2
2 //
3 // Douglas Thrift
4 //
5 // $Id: IndividualClient.cxx,v 1.5 2003/08/20 05:49:34 douglas Exp $
6
7 #include "IndividualClient.h"
8
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 istringstream name(this->name);
38
39 do
40 {
41 string word;
42
43 name >> word;
44 name.get();
45
46 unsigned punk;
47
48 do
49 {
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() + '.' + extension;
63 }
64
65 return file;
66 }
67
68 void IndividualClient::setNumber(unsigned number)
69 {
70 this->number = number;
71 file = "";
72 }
73
74 void IndividualClient::setName(const string& name)
75 {
76 this->name = name;
77 file = "";
78 }
79
80 void IndividualClient::setFile(const string& file)
81 {
82 this->file = file;
83 number = 0;
84 name = "";
85 }
86
87 string IndividualClient::extension = "pdf";
88
89 void IndividualClient::demunge(void)
90 {
91 istringstream file(demunge(this->file));
92
93 file >> number;
94 file.get();
95
96 ostringstream name;
97 unsigned count = 1;
98
99 do
100 {
101 string word;
102
103 file >> word;
104 file.get();
105
106 if (word.length() == 1 || word == "jr" || word == "sr" || word == "dr"
107 || word == "mr" || word == "ms" || word == "mrs")
108 {
109 word += '.';
110 }
111 else if (word == "de" && count == 1)
112 {
113 --count;
114 }
115 else if (word == "ii" || word == "iv" || word == "iv")
116 {
117 capitalize(word += '.', 0, 2);
118 }
119 else if (word == "iii")
120 {
121 capitalize(word += '.', 0, 3);
122 }
123 else if (word.length() > 2 && word.find("mc") == 0)
124 {
125 capitalize(word, 2);
126 }
127 else if (word.length() > 3 && word.find("mac") == 0)
128 {
129 capitalize(word, 3);
130 }
131 else if (word.length() > 2 && word.find("o\'") == 0)
132 {
133 capitalize(word, 2);
134 }
135 else if (word.length() > 1)
136 {
137 if (!isalpha(word[0]))
138 {
139 capitalize(word, 1);
140 }
141 }
142
143 capitalize(word);
144
145 switch (++count)
146 {
147 case 1:
148 name << word << " ";
149 break;
150 case 2:
151 name << word;
152 break;
153 case 3:
154 name << ", " << word;
155 break;
156 default:
157 name << " " << word;
158 break;
159 }
160 }
161 while (file.good());
162
163 this->name = name.str();
164 }
165
166 string IndividualClient::demunge(const string& munged)
167 {
168 string demunged;
169
170 for (unsigned index = 0; index < munged.length() - extension.length() - 1;
171 index++)
172 {
173 if (munged[index] == '_')
174 {
175 demunged += ' ';
176 }
177 else
178 {
179 demunged += munged[index];
180 }
181 }
182
183 return demunged;
184 }
185
186 void IndividualClient::capitalize(string& word, unsigned index, unsigned count)
187 {
188 for (unsigned number = index; number < index + count; number++)
189 {
190 word[number] = toupper(word[number]);
191 }
192 }