|
1 | | -/* CSD.cpp |
2 | | - * Copyright (C) 2011, Rodrigo Canovas & Miguel A. Martinez-Prieto |
3 | | - * all rights reserved. |
4 | | - * |
5 | | - * Abstract class for implementing Compressed String Dictionaries following: |
6 | | - * |
7 | | - * ========================================================================== |
8 | | - * "Compressed String Dictionaries" |
9 | | - * Nieves R. Brisaboa, Rodrigo Canovas, Francisco Claude, |
10 | | - * Miguel A. Martinez-Prieto and Gonzalo Navarro. |
11 | | - * 10th Symposium on Experimental Algorithms (SEA'2011), p.136-147, 2011. |
12 | | - * ========================================================================== |
13 | | - * |
14 | | - * This library is free software; you can redistribute it and/or |
15 | | - * modify it under the terms of the GNU Lesser General Public |
16 | | - * License as published by the Free Software Foundation; either |
17 | | - * version 2.1 of the License, or (at your option) any later version. |
18 | | - * |
19 | | - * This library is distributed in the hope that it will be useful, |
20 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 | | - * Lesser General Public License for more details. |
23 | | - * |
24 | | - * You should have received a copy of the GNU Lesser General Public |
25 | | - * License along with this library; if not, write to the Free Software |
26 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
27 | | - * |
28 | | - * |
29 | | - * Contacting the authors: |
30 | | - * Rodrigo Canovas: rcanovas@dcc.uchile.cl |
31 | | - * Miguel A. Martinez-Prieto: migumar2@infor.uva.es |
32 | | - */ |
33 | | -#include <stdexcept> |
34 | | -#include "CSD.h" |
35 | | -#include "CSD_PFC.h" |
36 | | - |
37 | | -#ifdef HAVE_CDS |
38 | | -#include "CSD_HTFC.h" |
39 | | -#include "CSD_FMIndex.h" |
40 | | - |
41 | | -#include <libcdsBasics.h> |
42 | | - |
43 | | -using namespace cds_utils; |
44 | | - |
45 | | -#endif |
46 | | - |
47 | | -namespace csd |
48 | | -{ |
49 | | - |
50 | | -CSD::CSD() : numstrings(0) { |
51 | | - |
52 | | -} |
53 | | - |
54 | | -CSD * CSD::load(istream & fp) |
55 | | -{ |
56 | | - int type = fp.get(); |
57 | | - if(!fp.good()) { |
58 | | - throw std::runtime_error("Error reading stream"); |
59 | | - } |
60 | | - switch(type) |
61 | | - { |
62 | | - case PFC: |
63 | | - return CSD_PFC::load(fp); |
64 | | -#ifdef HAVE_CDS |
65 | | - case FMINDEX: |
66 | | - return CSD_FMIndex::load(fp); |
67 | | - case HTFC: |
68 | | - return CSD_HTFC::load(fp); |
69 | | -#endif |
70 | | - default: |
71 | | - throw std::logic_error("No implementation for CSD"); |
72 | | - } |
73 | | - return NULL; |
74 | | -} |
75 | | - |
76 | | -CSD *CSD::create(unsigned char type) |
77 | | -{ |
78 | | - switch(type) |
79 | | - { |
80 | | - case PFC: return new CSD_PFC(); |
81 | | -#ifdef HAVE_CDS |
82 | | - case HTFC: return new CSD_HTFC(); |
83 | | - case FMINDEX: return new CSD_FMIndex(); |
84 | | -#endif |
85 | | - default: throw std::logic_error("No implementation for CSD"); |
86 | | - } |
87 | | - |
88 | | - return NULL; |
89 | | -} |
90 | | - |
91 | | -uint32_t CSD::getLength() |
92 | | -{ |
93 | | - return numstrings; |
94 | | -} |
95 | | - |
96 | | -} |
| 1 | +/* CSD.cpp |
| 2 | + * Copyright (C) 2011, Rodrigo Canovas & Miguel A. Martinez-Prieto |
| 3 | + * all rights reserved. |
| 4 | + * |
| 5 | + * Abstract class for implementing Compressed String Dictionaries following: |
| 6 | + * |
| 7 | + * ========================================================================== |
| 8 | + * "Compressed String Dictionaries" |
| 9 | + * Nieves R. Brisaboa, Rodrigo Canovas, Francisco Claude, |
| 10 | + * Miguel A. Martinez-Prieto and Gonzalo Navarro. |
| 11 | + * 10th Symposium on Experimental Algorithms (SEA'2011), p.136-147, 2011. |
| 12 | + * ========================================================================== |
| 13 | + * |
| 14 | + * This library is free software; you can redistribute it and/or |
| 15 | + * modify it under the terms of the GNU Lesser General Public |
| 16 | + * License as published by the Free Software Foundation; either |
| 17 | + * version 2.1 of the License, or (at your option) any later version. |
| 18 | + * |
| 19 | + * This library is distributed in the hope that it will be useful, |
| 20 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | + * Lesser General Public License for more details. |
| 23 | + * |
| 24 | + * You should have received a copy of the GNU Lesser General Public |
| 25 | + * License along with this library; if not, write to the Free Software |
| 26 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | + * |
| 28 | + * |
| 29 | + * Contacting the authors: |
| 30 | + * Rodrigo Canovas: rcanovas@dcc.uchile.cl |
| 31 | + * Miguel A. Martinez-Prieto: migumar2@infor.uva.es |
| 32 | + */ |
| 33 | +#include <stdexcept> |
| 34 | +#include "CSD.h" |
| 35 | +#include "CSD_PFC.h" |
| 36 | + |
| 37 | +#ifdef HAVE_CDS |
| 38 | +#include "CSD_HTFC.h" |
| 39 | +#include "CSD_FMIndex.h" |
| 40 | + |
| 41 | +#include <libcdsBasics.h> |
| 42 | + |
| 43 | +using namespace cds_utils; |
| 44 | + |
| 45 | +#endif |
| 46 | + |
| 47 | +namespace csd |
| 48 | +{ |
| 49 | + |
| 50 | +CSD::CSD() : numstrings(0) { |
| 51 | + |
| 52 | +} |
| 53 | + |
| 54 | +CSD * CSD::load(istream & fp) |
| 55 | +{ |
| 56 | + int type = fp.get(); |
| 57 | + if(!fp.good()) { |
| 58 | + throw std::runtime_error("Error reading stream"); |
| 59 | + } |
| 60 | + switch(type) |
| 61 | + { |
| 62 | + case PFC: |
| 63 | + return CSD_PFC::load(fp); |
| 64 | +#ifdef HAVE_CDS |
| 65 | + case FMINDEX: |
| 66 | + return CSD_FMIndex::load(fp); |
| 67 | + case HTFC: |
| 68 | + return CSD_HTFC::load(fp); |
| 69 | +#endif |
| 70 | + default: |
| 71 | + throw std::logic_error("No implementation for CSD"); |
| 72 | + } |
| 73 | + return NULL; |
| 74 | +} |
| 75 | + |
| 76 | +CSD *CSD::create(unsigned char type) |
| 77 | +{ |
| 78 | + switch(type) |
| 79 | + { |
| 80 | + case PFC: return new CSD_PFC(); |
| 81 | +#ifdef HAVE_CDS |
| 82 | + case HTFC: return new CSD_HTFC(); |
| 83 | + case FMINDEX: return new CSD_FMIndex(); |
| 84 | +#endif |
| 85 | + default: throw std::logic_error("No implementation for CSD"); |
| 86 | + } |
| 87 | + |
| 88 | + return NULL; |
| 89 | +} |
| 90 | + |
| 91 | +uint32_t CSD::getLength() |
| 92 | +{ |
| 93 | + return numstrings; |
| 94 | +} |
| 95 | + |
| 96 | +} |
0 commit comments