#include "I3Identifier.h"
#include "SHA1.h"
Functions | |
std::ostream & | operator<< (std::ostream &os, const I3Identifier &id) |
std::ostream& operator<< | ( | std::ostream & | os, | |
const I3Identifier & | id | |||
) |
os | String stream | |
id | I3Identifier to be output |
00193 { 00194 bool allzeros; 00195 const char hex[] = "0123456789abcdef"; 00196 string s0, s1; 00197 00198 if (id.name.length() != 0) { 00199 os << "(" << id.name << ") "; 00200 } 00201 00202 for (int i = 0; i < id.prefixLength / 8; i++) { 00203 os << hex[id.key[i] >> 4]; 00204 os << hex[id.key[i] & 0xf]; 00205 } 00206 os << ':'; 00207 00208 allzeros = true; 00209 for (int i = id.prefixLength / 8; i < id.keyLength / 8; i++) { 00210 if (id.key[i] != 0) { 00211 allzeros = false; 00212 break; 00213 } 00214 } 00215 if (allzeros) { 00216 os << "0..."; 00217 } else { 00218 for (int i = id.prefixLength / 8; i < id.keyLength / 8; i++) { 00219 os << hex[id.key[i] >> 4]; 00220 os << hex[id.key[i] & 0xf]; 00221 } 00222 } 00223 return os; 00224 }