From 840a11929afb062d271693b52176a45224b1c6ca Mon Sep 17 00:00:00 2001 From: maroy Date: Sun, 9 Jan 2005 16:00:02 +0000 Subject: [PATCH] added fromDecimalString() --- .../core/include/LiveSupport/Core/UniqueId.h | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/livesupport/modules/core/include/LiveSupport/Core/UniqueId.h b/livesupport/modules/core/include/LiveSupport/Core/UniqueId.h index ece9a7d3a..098095bb6 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/UniqueId.h +++ b/livesupport/modules/core/include/LiveSupport/Core/UniqueId.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Author : $Author: maroy $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/UniqueId.h,v $ ------------------------------------------------------------------------------*/ @@ -59,8 +59,8 @@ namespace Core { /** * A class representing globally unique identifiers. * - * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @author $Author: maroy $ + * @version $Revision: 1.5 $ */ class UniqueId { @@ -120,6 +120,28 @@ class UniqueId idReader >> std::hex >> this->id; } + /** + * Create a UniqueId from a numeric value, which is a string + * representation of the id, in base 10. + * If the argument is not a valid decimal number between 0 and + * 2^31-1 (inclusive), the value of the UniqueId will be + * bogus. + * + * @param strValue the id in base 10, in string from. + * @return a new UniqueId with the specified ID value. + */ + static Ptr::Ref + fromDecimalString(const std::string idStr) throw () + { + IdType id; + // TODO: error checking + std::stringstream idReader(idStr); + idReader >> id; + + Ptr::Ref uid(new UniqueId(id)); + return uid; + } + /** * Compare this is with an other one. *