Added missing #include <cstring> for std::strlen and std::memset
[SXSI/TextCollection.git] / TextCollectionBuilder.h
1 /******************************************************************************
2  *   Copyright (C) 2009 by Niko Valimaki <nvalimak@cs.helsinki.fi>            *
3  *   Text collection interface for an in-memory XQuery/XPath engine           *
4  *                                                                            *
5  *   This program is free software; you can redistribute it and/or modify     *
6  *   it under the terms of the GNU Lesser General Public License as published *
7  *   by the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                      *
9  *                                                                            *
10  *   This program is distributed in the hope that it will be useful,          *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
13  *   GNU Lesser General Public License for more details.                      *
14  *                                                                            *
15  *   You should have received a copy of the GNU Lesser General Public License *
16  *   along with this program; if not, write to the                            *
17  *   Free Software Foundation, Inc.,                                          *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                *
19  ******************************************************************************/ 
20
21 #ifndef _SXSI_TextCollectionBuilder_h_
22 #define _SXSI_TextCollectionBuilder_h_
23
24 #include "TextCollection.h"
25 #include "Tools.h" // Defines ulong and uchar.
26 #include <vector>
27 #include <utility> // Defines std::pair.
28 #include <cstring> // Defines std::strlen, added by Kim
29
30 namespace SXSI
31 {
32     struct TCBuilderRep; // Pimpl
33     
34     /**
35      * Build an instance of the TextCollection class.
36      */
37     class TextCollectionBuilder
38     {
39     public:
40         explicit TextCollectionBuilder(unsigned);
41         ~TextCollectionBuilder();
42         
43         /** 
44          * Insert text
45          *
46          * Must be a zero-terminated string from alphabet [1,255].
47          * Can not be called after makeStatic().
48          * The i'th text insertion gets an identifier value i-1.
49          * In other words, document identifiers start from 0.
50          */
51         void InsertText(uchar const *);
52         /**
53          * Make static
54          *
55          * Convert to a static collection; reduces space and time complexities.
56          * New texts can not be inserted after this operation.
57          */
58         TextCollection * InitTextCollection();
59         
60     private:
61         struct TCBuilderRep * p_;
62
63         // No copy constructor or assignment
64         TextCollectionBuilder();
65         TextCollectionBuilder(TextCollectionBuilder const&);
66         TextCollectionBuilder& operator = (TextCollectionBuilder const&);
67     };
68 }
69 #endif