Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Uuid formating with dashes
Uuid formating with dashes [message #25117] Thu, 11 February 2010 10:48 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I need to have my Uuids formated with dashes in the standard positions.

So I added to Uuid.h as a counterpart to Format:
String UuidFormatDashes(const Uuid& id);

and Uuid.cpp:
String UuidFormatDashes(const Uuid& id) {
	return Sprintf("%08X-%04X-%04X-%04X-%04X%08X", id.a, (id.b & 0xFFFF0000) >> 16, id.b & 0x0000FFFF,
		(id.c & 0xFFFF0000) >> 16, id.c & 0x0000FFFF, id.d);
}

Alternatively, and even probably better this method should be part of Uuid class and drop the prefix.

[Updated on: Thu, 11 February 2010 10:48]

Report message to a moderator

Re: Uuid formating with dashes [message #25236 is a reply to message #25117] Mon, 15 February 2010 12:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Thu, 11 February 2010 04:48

I need to have my Uuids formated with dashes in the standard positions.

So I added to Uuid.h as a counterpart to Format:
String UuidFormatDashes(const Uuid& id);

and Uuid.cpp:
String UuidFormatDashes(const Uuid& id) {
	return Sprintf("%08X-%04X-%04X-%04X-%04X%08X", id.a, (id.b & 0xFFFF0000) >> 16, id.b & 0x0000FFFF,
		(id.c & 0xFFFF0000) >> 16, id.c & 0x0000FFFF, id.d);
}

Alternatively, and even probably better this method should be part of Uuid class and drop the prefix.


Useful.

Added as FormatWithDashes.

Mirek
Re: Uuid formating with dashes [message #25237 is a reply to message #25236] Mon, 15 February 2010 12:29 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Thank you!

I added the "Uuid" prefix so that I don't take up a general name as "FormatDashes", which can theoretically be applied to anything. Function overloading should fix that though.

I might have to update the scan part too.
Re: Uuid formating with dashes [message #25240 is a reply to message #25237] Mon, 15 February 2010 12:40 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
cbpporter wrote on Mon, 15 February 2010 06:29

Thank you!

I added the "Uuid" prefix so that I don't take up a general name as "FormatDashes", which can theoretically be applied to anything. Function overloading should fix that though.



I think that is the point - next time we can use the same 'FormatWithDashes' for any other type. While perhaps not that important in this case, this strategy pays off with templates... Smile
Previous Topic: XmlParser patch
Next Topic: Defs.h minmax() change/fix
Goto Forum:
  


Current Time: Mon Apr 29 12:34:04 CEST 2024

Total time taken to generate the page: 0.02420 seconds