/* Copyright 2015, Michele Santullo * This file is part of "dindexer". * * "dindexer" is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * "dindexer" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with "dindexer". If not, see . */ #ifndef id9CF5E6FA7E334DF09559C2968C494CB9 #define id9CF5E6FA7E334DF09559C2968C494CB9 #include #include #include #include #include #include #include #include #include namespace din { template , typename StrRef=boost::basic_string_ref> class StringPool { typedef std::pair StringListPair; typedef std::vector> PoolType; typedef std::vector StringListType; typedef std::function FuncGetFirst; public: typedef C char_type; typedef Str string_type; typedef StrRef stringref_type; typedef boost::transform_iterator const_iterator; StringPool ( void ) = default; ~StringPool ( void ) noexcept = default; template void update ( ItR parDataBeg, ItR parDataEnd ); void update ( const StringPool& parOther ); void insert ( const std::vector& parStrings, const string_type* parBaseString ); void insert ( stringref_type parString, const string_type* parBaseString ); const string_type* ptr_to_literal ( const char* parLiteral ); std::size_t size ( void ) const { return m_strings.size(); } bool empty ( void ) const { return m_strings.empty(); } const_iterator begin ( void ) const; const_iterator end ( void ) const; const string_type* get_stringref_source ( std::size_t parIndex ) const; const stringref_type& operator[] ( std::size_t parIndex ) const; void pop ( void ); private: PoolType m_pool; StringListType m_strings; }; } //namespace din #include "stringpool.inl" #endif