1 /******************************************************************************
2 * Copyright (C) 2009 by Niko Valimaki <nvalimak@cs.helsinki.fi> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU Lesser General Public License as published *
6 * by the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ******************************************************************************/
20 #ifndef _SXSI_RLCSABuilder_h_
21 #define _SXSI_RLCSABuilder_h_
23 #include "TextCollectionBuilder.h"
24 #include "TextStorage.h"
25 #include "Tools.h" // Defines ulong and uchar.
29 #include <utility> // Defines std::pair.
30 #include <cstring> // Defines std::strlen, added by Kim
34 struct TCBuilderRep; // Pimpl
37 * Build an instance of the TextCollection class.
39 class RLCSABuilder : public TextCollectionBuilder
42 RLCSABuilder(unsigned samplerate, ulong estimatedInputLength);
44 virtual ~RLCSABuilder();
49 * Must be a zero-terminated string from alphabet [1,255].
50 * Can not be called after makeStatic().
51 * The i'th text insertion gets an identifier value i-1.
52 * In other words, document identifiers start from 0.
54 * Second parameter tells if the text will be added to the
55 * index also. If false, text is added only to the TextCollection
56 * and can not be searched for.
58 virtual void InsertText(uchar const *, bool index = true);
63 * Convert to a static collection.
64 * New texts can not be inserted after this operation.
66 * TextStorage type defaults to TYPE_PLAIN_TEXT, another
67 * possible type is TYPE_LZ_INDEX.
69 virtual TextCollection * InitTextCollection(char type = TextStorage::TYPE_PLAIN_TEXT);
74 // Using Pimpl idiom to hide RLCSA implementation.
75 struct TCBuilderRep * p_;
77 // No copy constructor or assignment
78 RLCSABuilder(RLCSABuilder const&);
79 RLCSABuilder& operator = (RLCSABuilder const&);