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 265 by douglas, 2003-08-16T20:55:39-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.2 2003/08/17 03:55:39 douglas Exp $
5 > // $Id: IndividualClient.cxx,v 1.4 2003/08/18 22:25:29 douglas Exp $
6  
7   #include "IndividualClient.h"
8  
# Line 32 | Line 32 | string IndividualClient::getFile(void)
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();
63          }
# Line 79 | Line 92 | void IndividualClient::demunge(void)
92          file.get();
93  
94          ostringstream name;
95 <        unsigned count = 0;
95 >        unsigned count = 1;
96  
97          do
98          {
# Line 88 | Line 101 | void IndividualClient::demunge(void)
101                  file >> word;
102                  file.get();
103  
104 <                if (word.length() == 1) word += '.';
105 <
106 <                if (word.length() > 2 && word.find("mc") == 0)
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                  }
# Line 108 | Line 136 | void IndividualClient::demunge(void)
136                  switch (++count)
137                  {
138                  case 1:
139 <                        name << word;
139 >                        name << word << " ";
140                          break;
141                  case 2:
142 +                        name << word;
143 +                        break;
144 +                case 3:
145                          name << ", " << word;
146                          break;
147                  default:
# Line 141 | Line 172 | string IndividualClient::demunge(const s
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