* Writes record information into the binary buffer. * * @param buf Buffer to fill with binary record information. * * @throws Isis::IException::Programmer - Invalid field type */
| 122 | * @throws Isis::IException::Programmer - Invalid field type |
| 123 | */ |
| 124 | void TableRecord::Pack(char *buf) const { |
| 125 | int sbyte = 0; |
| 126 | for (int f = 0; f < Fields(); f++) { |
| 127 | const Isis::TableField &field = p_fields[f]; |
| 128 | if (field.isDouble()) { |
| 129 | vector<double> vals = field; |
| 130 | for (unsigned int i = 0; i < vals.size(); i++) { |
| 131 | //*((double *)(buf+sbyte)) = vals[i]; |
| 132 | memmove(buf + sbyte, &vals[i], 8); |
| 133 | sbyte += sizeof(double); |
| 134 | } |
| 135 | } |
| 136 | else if (field.isInteger()) { |
| 137 | vector<int> vals = field; |
| 138 | for (unsigned int i = 0; i < vals.size(); i++) { |
| 139 | //*((int *)(buf+sbyte)) = vals[i]; |
| 140 | memmove(buf + sbyte, &vals[i], 4); |
| 141 | sbyte += sizeof(int); |
| 142 | } |
| 143 | } |
| 144 | else if (field.isText()) { |
| 145 | QString val = (QString)field; |
| 146 | for (int i = 0; i < field.size(); i++) { |
| 147 | if (i < (int)val.length()) { |
| 148 | buf[sbyte] = val[i].toLatin1(); |
| 149 | } |
| 150 | else { |
| 151 | buf[sbyte] = 0; |
| 152 | } |
| 153 | sbyte++; |
| 154 | } |
| 155 | } |
| 156 | else if (field.isReal()) { |
| 157 | vector<float> vals = field; |
| 158 | for (unsigned int i = 0; i < vals.size(); i++) { |
| 159 | //*((int *)(buf+sbyte)) = vals[i]; |
| 160 | memmove(buf + sbyte, &vals[i], 4); |
| 161 | sbyte += sizeof(float); |
| 162 | } |
| 163 | } |
| 164 | else { |
| 165 | string msg = "Invalid field type"; |
| 166 | throw IException(IException::Programmer, msg, _FILEINFO_); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Reads record information from the binary buffer. |