From 878439cc9293e3f5a00f1ffd8d2a13e4fc1b804f Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 1 Oct 2013 20:57:56 -0400 Subject: Move this string pool code to svl. Change-Id: I1379fbc377607be8831133d64db2e14f8c75bff8 --- svl/Library_svl.mk | 1 + svl/source/misc/stringpool.cxx | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 svl/source/misc/stringpool.cxx (limited to 'svl') 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 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: */ -- cgit