CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Identifier-01-02-15/src/Identifier.cxx
Go to the documentation of this file.
1#include "Identifier/Identifier.h"
2#include <stdarg.h>
3#include <stdio.h>
4#include <algorithm>
5
6#include <iostream>
7#include <iomanip>
8
9//-----------------------------------------------
10void Identifier::set (const std::string& id)
11{
12 sscanf (id.c_str(), "0x%x", &m_id);
13}
14
15
16//-----------------------------------------------
17std::string Identifier::getString() const
18{
19 std::string result;
20 char temp[20];
21
22 sprintf (temp, "0x%x", (unsigned int)m_id);
23 result += temp;
24 result.insert(2,10-result.length(),'0');
25
26 return (result);
27}
28
29//-----------------------------------------------
30void Identifier::show () const
31{
32 const Identifier& me = *this;
33 std::cout << me.getString();
34}
35
36std::ostream& operator<<(std::ostream & os, const Identifier& Id)
37{
38 return (os<<Id.getString());
39}
std::ostream & operator<<(std::ostream &os, const Identifier &Id)
const double me
Definition: PipiJpsi.cxx:48
virtual std::string getString() const
Provide a string form of the identifier - hexadecimal.
virtual void show() const
Print out in hex form.
virtual void set(const std::string &id)
build from a string form - hexadecimal
char * c_str(Index i)
Definition: EvtCyclic3.cc:252