diff options
Diffstat (limited to 'svl/source/misc/stringpool.cxx')
-rw-r--r-- | svl/source/misc/stringpool.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
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: */ |