Functions

I3Identifier.cc File Reference

#include "I3Identifier.h"
#include "SHA1.h"

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const I3Identifier &id)

Detailed Description

Author:
Antonio Zea

Definition in file I3Identifier.cc.


Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const I3Identifier id 
)
Parameters:
os String stream
id I3Identifier to be output
Returns:
os parameter

Definition at line 195 of file I3Identifier.cc.

{
    bool allzeros;
    const char hex[] = "0123456789abcdef";
    string s0, s1;

    if (id.name.length() != 0) {
        os << "(" << id.name << ") ";
    }

    for (int i = 0; i < id.prefixLength / 8; i++) {
        os << hex[id.key[i] >> 4];
        os << hex[id.key[i] & 0xf];
    }
    os << ':';

    allzeros = true;
    for (int i = id.prefixLength / 8; i < id.keyLength / 8; i++) {
        if (id.key[i] != 0) {
            allzeros = false;
            break;
        }
    }
    if (allzeros) {
        os << "0...";
    } else {
        for (int i = id.prefixLength / 8; i < id.keyLength / 8; i++) {
            os << hex[id.key[i] >> 4];
            os << hex[id.key[i] & 0xf];
        }
    }
    return os;
}