MCPcopy Create free account
hub / github.com/DOI-USGS/ISIS3 / Pack

Method Pack

isis/src/core/src/TableRecord.cpp:124–169  ·  view source on GitHub ↗

* Writes record information into the binary buffer. * * @param buf Buffer to fill with binary record information. * * @throws Isis::IException::Programmer - Invalid field type */

Source from the content-addressed store, hash-verified

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.

Callers 3

operator+=Method · 0.45
UpdateMethod · 0.45
mainFunction · 0.45

Calls 7

isDoubleMethod · 0.80
isIntegerMethod · 0.80
isTextMethod · 0.80
isRealMethod · 0.80
IExceptionClass · 0.50
sizeMethod · 0.45
lengthMethod · 0.45

Tested by 1

mainFunction · 0.36