summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-01 20:57:56 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-04 19:15:21 -0400
commit878439cc9293e3f5a00f1ffd8d2a13e4fc1b804f (patch)
tree3f486ae2c83dea424096517b12ad3bbe048f1ec1 /svl
parent6cea76189fb8d9fbb358f757157df66c7ea31c85 (diff)
Move this string pool code to svl.
Change-Id: I1379fbc377607be8831133d64db2e14f8c75bff8
Diffstat (limited to 'svl')
-rw-r--r--svl/Library_svl.mk1
-rw-r--r--svl/source/misc/stringpool.cxx35
2 files changed, 36 insertions, 0 deletions
diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index 277be91d2f74..eddabf0a259d 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
svl/source/misc/lockfilecommon \
svl/source/misc/ownlist \
svl/source/misc/sharecontrolfile \
+ svl/source/misc/stringpool \
svl/source/misc/strmadpt \
svl/source/misc/urihelper \
svl/source/notify/brdcst \
diff --git a/svl/source/misc/stringpool.cxx b/svl/source/misc/stringpool.cxx
new file mode 100644
index 000000000000..f8ddda9b0acd
--- /dev/null
+++ b/svl/source/misc/stringpool.cxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "svl/stringpool.hxx"
+
+namespace svl {
+
+StringPool::StringPool() {}
+
+rtl_uString* StringPool::intern( const OUString& rStr )
+{
+ StrHashType::iterator it = maStrPool.find(rStr);
+ if (it == maStrPool.end())
+ {
+ // Not yet in the pool.
+ std::pair<StrHashType::iterator, bool> r = maStrPool.insert(rStr.intern());
+ if (!r.second)
+ // Insertion failed.
+ return NULL;
+
+ it = r.first;
+ }
+
+ return it->pData;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */