ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/shapes/PDBReader.cpp
(Generate patch)

Comparing trunk/OOPSE/shapes/PDBReader.cpp (file contents):
Revision 1182 by gezelter, Fri May 21 14:23:20 2004 UTC vs.
Revision 1184 by gezelter, Fri May 21 18:34:52 2004 UTC

# Line 22 | Line 22 | vector<VDWAtom*> PDBReader::getAtomList() {
22    char resIDstr[6];
23    char buf[150];
24    double pos[3];
25 <  char aType[4];
25 >  char aType[5];
26 >  char aBase[2];
27    char resName[3];
28    int id, resID, ta;
29    VDWAtom* atom;
# Line 56 | Line 57 | vector<VDWAtom*> PDBReader::getAtomList() {
57  
58        atom->setPos(pos);
59  
60 <      memset(aType, 0, 4 * sizeof(char));
61 <      strncpy(aType, buf + 12, 3);
62 <      printf("string in aType = %s\n", aType);
63 <      atom->setType(aType);
60 >      memset(aType, 0, 5 * sizeof(char));
61 >      strncpy(aType, buf + 12, 4);
62 >      memset(aBase, 0, 2 * sizeof(char));
63 >      strncpy(aBase, buf + 13, 1);
64 >
65 >      atom->setType(TrimSpaces(aType));
66 >      atom->setBase(TrimSpaces(aBase));
67        
68        memset(resName, 0, 3 * sizeof(char));
69        strncpy(resName, buf + 17, 2);
# Line 72 | Line 76 | vector<VDWAtom*> PDBReader::getAtomList() {
76        
77        theAtoms.push_back(atom);
78  
75      printf("%s\t%lf\t%lf\t%lf\n", atom->getType(), pos[0], pos[1], pos[2]);
76
79      }
80    } // while
81    return theAtoms;
# Line 94 | Line 96 | unsigned int PDBReader::getTotAtoms(void) {
96    }
97    return ta;
98   }
99 +
100 + /**
101 + * Removes left and right spaces from a string
102 + *
103 + * @param str  String to trim
104 + *
105 + * @return  char* to the trimed string
106 + */
107 + char * PDBReader::TrimSpaces(char *str) {
108 +  size_t len;
109 +  char *right, *left;
110 +  
111 +  /* Trim whitespace from left side */
112 +  for (left = str; isspace(*left); left++);
113 +  
114 +  /* Trim whitespace from right side */
115 +  if ((len = strlen(left)))
116 +    {
117 +      right = left + (len - 1);
118 +      
119 +      while (isspace(*right))
120 +        {
121 +          *right = '\0';
122 +          right--;
123 +        }
124 +    }
125 +  
126 +  /* Only do the str copy if their was spaces to the left */
127 +  if (left != str)
128 +    strcpy(str, left);
129 +  
130 +  return (str);
131 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines