ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/IndividualClient.cxx
(Generate patch)

Comparing trunk/VTBFileUtil2/IndividualClient.cxx (file contents):
Revision 260 by douglas, 2003-08-16T02:08:35-07:00 vs.
Revision 267 by douglas, 2003-08-18T15:25:29-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: IndividualClient.cxx,v 1.1 2003/08/16 09:08:35 douglas Exp $
5 > // $Id: IndividualClient.cxx,v 1.4 2003/08/18 22:25:29 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();
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 + void IndividualClient::demunge(void)
88 + {
89 +        istringstream file(demunge(this->file));
90 +
91 +        file >> number;
92 +        file.get();
93 +
94 +        ostringstream name;
95 +        unsigned count = 1;
96 +
97 +        do
98 +        {
99 +                string word;
100 +
101 +                file >> word;
102 +                file.get();
103 +
104 +                if (word.length() == 1 || word == "jr" || word == "sr" || word == "dr"
105 +                        || word == "mr" || word == "ms" || word == "mrs")
106 +                {
107 +                        word += '.';
108 +                }
109 +                else if (word == "de" && count == 1)
110 +                {
111 +                        --count;
112 +                }
113 +                else if (word == "ii" || word == "iv" || word == "iv")
114 +                {
115 +                        capitalize(word += '.', 0, 2);
116 +                }
117 +                else if (word == "iii")
118 +                {
119 +                        capitalize(word += '.', 0, 3);
120 +                }
121 +                else if (word.length() > 2 && word.find("mc") == 0)
122 +                {
123 +                        capitalize(word, 2);
124 +                }
125 +                else if (word.length() > 3 && word.find("mac") == 0)
126 +                {
127 +                        capitalize(word, 3);
128 +                }
129 +                else if (word.length() > 2 && word.find("o\'") == 0)
130 +                {
131 +                        capitalize(word, 2);
132 +                }
133 +
134 +                capitalize(word);
135 +
136 +                switch (++count)
137 +                {
138 +                case 1:
139 +                        name << word << " ";
140 +                        break;
141 +                case 2:
142 +                        name << word;
143 +                        break;
144 +                case 3:
145 +                        name << ", " << word;
146 +                        break;
147 +                default:
148 +                        name << " " << word;
149 +                        break;
150 +                }
151 +        }
152 +        while (file.good());
153 +
154 +        this->name = name.str();
155 + }
156 +
157 + string IndividualClient::demunge(const string& munged)
158 + {
159 +        string demunged;
160 +
161 +        for (unsigned index = 0; index < munged.length(); index++)
162 +        {
163 +                if (munged[index] == '_')
164 +                {
165 +                        demunged += ' ';
166 +                }
167 +                else
168 +                {
169 +                        demunged += munged[index];
170 +                }
171 +        }
172 +
173 +        return demunged;
174 + }
175 +
176 + void IndividualClient::capitalize(string& word, unsigned index, unsigned count)
177 + {
178 +        for (unsigned number = index; number < index + count; number++)
179 +        {
180 +                word[number] = toupper(word[number]);
181 +        }
182 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines