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

Comparing trunk/VTBFileUtil2/IndividualClient.cxx (file contents):
Revision 266 by douglas, 2003-08-17T16:39:32-07:00 vs.
Revision 277 by douglas, 2003-08-24T00:31:45-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: IndividualClient.cxx,v 1.3 2003/08/17 23:39:32 douglas Exp $
5 > // $Id: IndividualClient.cxx,v 1.8 2003/08/24 07:31:45 douglas Exp $
6  
7   #include "IndividualClient.h"
8  
9   unsigned IndividualClient::getNumber(void)
10   {
11 <        if (number == 0)
11 >        if (number == 0 && file != "")
12          {
13                  demunge();
14          }
# Line 18 | Line 18 | unsigned IndividualClient::getNumber(voi
18  
19   string IndividualClient::getName(void)
20   {
21 <        if (name == "")
21 >        if (name == "" && file != "")
22          {
23                  demunge();
24          }
# Line 28 | Line 28 | string IndividualClient::getName(void)
28  
29   string IndividualClient::getFile(void)
30   {
31 <        if (file == "")
31 >        if (file == "" && number != 0 && name != "")
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;
# Line 71 | Line 84 | void IndividualClient::setFile(const str
84          name = "";
85   }
86  
87 + string IndividualClient::extension = "pdf";
88 +
89   void IndividualClient::demunge(void)
90   {
91          istringstream file(demunge(this->file));
# Line 88 | Line 103 | void IndividualClient::demunge(void)
103                  file >> word;
104                  file.get();
105  
106 <                if (word.length() == 1 || word == "jr" || word == "sr")
106 >                if (word.length() == 1 && word != "i")
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                  }
# Line 98 | Line 118 | void IndividualClient::demunge(void)
118                  }
119                  else if (word == "ii" || word == "iv" || word == "iv")
120                  {
121 <                        capitalize(word += '.', 0, 2);
121 >                        capitalize(word, 0, 2);
122                  }
123                  else if (word == "iii")
124                  {
125 <                        capitalize(word += '.', 0, 3);
125 >                        capitalize(word, 0, 3);
126                  }
127                  else if (word.length() > 2 && word.find("mc") == 0)
128                  {
# Line 112 | Line 132 | void IndividualClient::demunge(void)
132                  {
133                          capitalize(word, 3);
134                  }
135 <                else if (word.length() > 2 && word.find("o\'") == 0)
135 >                else if (word.length() > word.find_first_of("\'-") + 1 &&
136 >                        word.find_first_not_of("\'-") != string::npos)
137 >                {
138 >                        capitalize(word, word.find_first_of("\'-") + 1);
139 >                }
140 >                else if (word.length() > 1)
141 >                {
142 >                        if (!isalpha(word[0]))
143 >                        {
144 >                                capitalize(word, 1);
145 >                        }
146 >                }
147 >                else if (word == "lefevre")
148                  {
149                          capitalize(word, 2);
150                  }
# Line 144 | Line 176 | string IndividualClient::demunge(const s
176   {
177          string demunged;
178  
179 <        for (unsigned index = 0; index < munged.length(); index++)
179 >        for (unsigned index = 0; index < munged.length() - extension.length() - 1;
180 >                index++)
181          {
182                  if (munged[index] == '_')
183                  {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines