diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-02 10:47:28 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-04 19:15:22 -0400 |
commit | 5d3ea0cde3f4c61832c48281e75dabd22621a893 (patch) | |
tree | 17cd79135e43b45467048ce26102729144b5642c /include | |
parent | 279ae5116119b96b25fa56b53ecde4d61878cad7 (diff) |
Establish mapping between original strings and upper strings.
This will be used to retrieve case insensitive string identifiers
later.
Change-Id: Ia34f57d0e8d0cb6bd4630f8d110853ed049770b5
Diffstat (limited to 'include')
-rw-r--r-- | include/svl/stringpool.hxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/svl/stringpool.hxx b/include/svl/stringpool.hxx index 643c8466c0bc..25415684c9fd 100644 --- a/include/svl/stringpool.hxx +++ b/include/svl/stringpool.hxx @@ -13,18 +13,55 @@ #include "svl/svldllapi.h" #include "rtl/ustring.hxx" +#include <boost/unordered_map.hpp> #include <boost/unordered_set.hpp> +class CharClass; + namespace svl { +/** + * Storage for pool of shared strings. It also provides mapping from + * original-cased strings to upper-cased strings for case insensitive + * operations. + */ class SVL_DLLPUBLIC StringPool { typedef boost::unordered_set<OUString, OUStringHash> StrHashType; + typedef std::pair<StrHashType::iterator, bool> InsertResultType; + typedef boost::unordered_map<const rtl_uString*, const rtl_uString*> StrIdMapType; + StrHashType maStrPool; + StrHashType maStrPoolUpper; + StrIdMapType maToUpperMap; + CharClass* mpCharClass; + public: StringPool(); + StringPool( CharClass* pCharClass ); + /** + * Intern a string object into the shared string pool. + * + * @param rStr string object to intern. + * + * @return a pointer to the string object stored inside the pool, or NULL + * if the insertion fails. + */ rtl_uString* intern( const OUString& rStr ); + + /** + * Get a unique ID of string object that's expected to be in the shared + * string pool. If the string is not in the pool, NULL is returned. + * + * @param rStr string object to get the ID of. + * + * @return unique ID of the string object. + */ + const rtl_uString* getIdentifier( const OUString& rStr ) const; + +private: + InsertResultType findOrInsert( StrHashType& rPool, const OUString& rStr ) const; }; } |