http://bugs.openzim.org/show_bug.cgi?id=15
Summary: zim::File getUuid() should return an HEX encoded MD5 hash Product: openZIM Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P5 Component: zimlib AssignedTo: tommi@tntnet.org ReportedBy: emmanuel@engelhart.org CC: dev-l@openzim.org Estimated Hours: 0.0
It returns currently the binary value which is not so easy to handle with (can not use standard string manipulation functions and can not easily save it in a file).
It would be better to return the same value but in HEX format as a NULL terminated string. This would avoid (I'm sure) each client using the zimlib to recode this conversion.
http://bugs.openzim.org/show_bug.cgi?id=15
--- Comment #1 from Tommi Mäkitalo tommi@tntnet.org 2009-12-23 16:11:11 CET --- It does not really return a binary value but a struct, which has a ostream operator. If you want to have a ascii encoded std::string, you may want to use a std::ostringstream:
std::ostringstream m; m << file.getFileheader().getUuid(); std::string myHexEncodedUuid = m.str();
If it is still needed to provide a std::string directly, I may add a small helper like toString, which does exactly this.
If you just want to print it to std::cout, you can do:
std::cout << file.getFileheader().getUuid();
The reason, why I did it that way is, that it is more versatile and efficient to do it that way. You should think, why or better if you really need a std::string. If I add a method toString you may do:
std::cout << file.getFileheader().getUuid().toString();
This is more verbose but less efficient, since you allocate a temporary string, which is thrown away. I do not see a real advantage.
http://bugs.openzim.org/show_bug.cgi?id=15
--- Comment #2 from Emmanuel Engelhart emmanuel@engelhart.org 2009-12-23 17:14:32 CET --- To print to STDOUT (without using a string base third part log framework), this is already the best. You are right.
But, for the rest, I think, a toString() method would be welcome.
http://bugs.openzim.org/show_bug.cgi?id=15
Tommi Mäkitalo tommi@tntnet.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX
--- Comment #3 from Tommi Mäkitalo tommi@tntnet.org 2010-03-27 10:30:52 CET --- There is a operator<< for std::ostream, which prints the hex representation of the uuid. If you want to see the hex representation of a uuid do:
zim::Uuid myUuid = ...; std::cout << myUuid;
If you really need a std::string, use std::ostringstream:
std::ostringstream s; s << myUuid; std::string hexUuid = s.str();