summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-08-28 09:58:02 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-08-28 10:02:38 (GMT)
commit063dc0412e0f84c779f133ec7293873b76f6b2d0 (patch)
treeb764ad8a157a865dfa482131e51f96ec593e4076 /Swiften
parentb1a9a1b61ebce0f64d656006a85607c8c8491f4a (diff)
downloadswift-063dc0412e0f84c779f133ec7293873b76f6b2d0.zip
swift-063dc0412e0f84c779f133ec7293873b76f6b2d0.tar.bz2
Use UUIDs as IQ IDs.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/IDGenerator.cpp26
-rw-r--r--Swiften/Base/IDGenerator.h3
2 files changed, 8 insertions, 21 deletions
diff --git a/Swiften/Base/IDGenerator.cpp b/Swiften/Base/IDGenerator.cpp
index 80ed34d..5556f7b 100644
--- a/Swiften/Base/IDGenerator.cpp
+++ b/Swiften/Base/IDGenerator.cpp
@@ -1,34 +1,24 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2011 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Base/IDGenerator.h>
+#include <boost/uuid/uuid.hpp>
+#include <boost/uuid/uuid_io.hpp>
+#include <boost/uuid/uuid_generators.hpp>
+#include <boost/lexical_cast.hpp>
+
namespace Swift {
IDGenerator::IDGenerator() {
}
std::string IDGenerator::generateID() {
- bool carry = true;
- size_t i = 0;
- while (carry && i < currentID_.size()) {
- char c = currentID_[i];
- if (c >= 'z') {
- currentID_[i] = 'a';
- }
- else {
- currentID_[i] = c+1;
- carry = false;
- }
- ++i;
- }
- if (carry) {
- currentID_ += 'a';
- }
- return currentID_;
+ static boost::uuids::random_generator generator;
+ return boost::lexical_cast<std::string>(generator());
}
}
diff --git a/Swiften/Base/IDGenerator.h b/Swiften/Base/IDGenerator.h
index d536dcc..44eeb76 100644
--- a/Swiften/Base/IDGenerator.h
+++ b/Swiften/Base/IDGenerator.h
@@ -14,8 +14,5 @@ namespace Swift {
IDGenerator();
std::string generateID();
-
- private:
- std::string currentID_;
};
}