FACT++  1.0
std::string Checksum::str ( bool  complm = true) const
inline

Definition at line 148 of file checksum.h.

References i, and val().

Referenced by CompressedFitsWriter::close(), CompressedFitsWriter::writeDrsCalib(), factofits::WriteDrsOffsetsTable(), and ofits::WriteFitsHeader().

149  {
150  std::string rc(16,0);
151 
152  const uint8_t exclude[13] =
153  {
154  0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
155  0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60
156  };
157 
158  const uint32_t value = complm ? ~val() : val(); // complement each bit of the value
159 
160  for (int ii = 0; ii < 4; ii++)
161  {
162  uint8_t byte = (value >> (24 - (8 * ii)));
163 
164  const uint8_t quotient = byte / 4 + '0';
165  const uint8_t remainder = byte % 4;
166 
167  uint32_t ch[4] = { uint32_t(quotient+remainder), quotient, quotient, quotient };
168 
169  // avoid ASCII punctuation
170  while (1)
171  {
172  bool check = false;
173  for (int kk = 0; kk < 13; kk++)
174  {
175  for (int jj = 0; jj < 4; jj += 2)
176  {
177  if (ch[jj] != exclude[kk] && ch[jj+1] != exclude[kk])
178  continue;
179 
180  ch[jj]++;
181  ch[jj+1]--;
182  check=true;
183  }
184  }
185 
186  if (!check)
187  break;
188  }
189 
190  for (int jj = 0; jj < 4; jj++) // assign the bytes
191  rc[4*jj+ii] = ch[jj];
192  }
193 
194  const char lastChar = rc[15];
195  for (int i=15;i>0;i--)
196  rc[i] = rc[i-1];
197  rc[0] = lastChar;
198  return rc;
199 /*
200  uint8_t *p = reinterpret_cast<uint8_t*>(&value);
201  //swap the bytes of the value
202  uint8_t temp;
203  temp = p[0];
204  p[0] = p[3];
205  p[3] = temp;
206  temp = p[1];
207  p[1] = p[2];
208  p[2] = temp;
209 
210  for (int i=0; i<4; i++)
211  {
212  rc[i+ 0] = '0' + p[i]/4 + p[i]%4;
213  rc[i+ 4] = '0' + p[i]/4;
214  rc[i+ 8] = '0' + p[i]/4;
215  rc[i+12] = '0' + p[i]/4;
216  }
217 
218  while(1)
219  {
220  bool ok = true;
221  for (int i=0; i<16-4; i++)
222  {
223  for (int j=0; j<13; j++)
224  if (rc[i]==exclude[j] || rc[(i+4)%16]==exclude[j])
225  {
226  rc[i]++;
227  rc[(i+4)%16]--;
228  ok = false;
229  }
230  }
231 
232  if (ok)
233  break;
234  }
235 
236 
237  return rc;
238  */
239  }
int i
Definition: db_dim_client.c:21
uint32_t val() const
Definition: checksum.h:20
unsigned char byte
Definition: MGImage.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function: