Switch to unified view

a/src/query/xadump.cpp b/src/query/xadump.cpp
...
...
43
    "-e <output encoding>\n"
43
    "-e <output encoding>\n"
44
    " -i docid -D : get document data for docid\n"
44
    " -i docid -D : get document data for docid\n"
45
    " -i docid -X : delete document docid\n"
45
    " -i docid -X : delete document docid\n"
46
    " -i docid -b : 'rebuild' document from term positions\n"
46
    " -i docid -b : 'rebuild' document from term positions\n"
47
    " -i docid -T : term list for doc docid\n"
47
    " -i docid -T : term list for doc docid\n"
48
    " -i docid -r : reconstructed text for docid\n"
48
    " -t term -E  : term existence test\n"
49
    " -t term -E  : term existence test\n"
49
    " -t term -F  : retrieve term frequency data for given term\n"
50
    " -t term -F  : retrieve term frequency data for given term\n"
50
    " -t term -P  : retrieve postings for term\n"
51
    " -t term -P  : retrieve postings for term\n"
51
    " -T          : list all terms\n"
52
    " -T          : list all terms\n"
52
    "    -f       : precede each term in the list with its occurrence counts\n"
53
    "    -f       : precede each term in the list with its occurrence counts\n"
...
...
81
#define OPT_q     0x1000
82
#define OPT_q     0x1000
82
#define OPT_s     0x2000
83
#define OPT_s     0x2000
83
#define OPT_t     0x4000
84
#define OPT_t     0x4000
84
#define OPT_x     0x8000
85
#define OPT_x     0x8000
85
#define OPT_l     0x10000
86
#define OPT_l     0x10000
87
#define OPT_r     0x20000
86
88
87
// Compute an exploded version of string, inserting a space between each char.
89
// Compute an exploded version of string, inserting a space between each char.
88
// (no character combining possible)
90
// (no character combining possible)
89
static string detailstring(const string& in)
91
static string detailstring(const string& in)
90
{
92
{
...
...
122
{
124
{
123
    if (o_index_stripchars) {
125
    if (o_index_stripchars) {
124
    return trm.size() && 'A' <= trm[0] && trm[0] <= 'Z';
126
    return trm.size() && 'A' <= trm[0] && trm[0] <= 'Z';
125
    } else {
127
    } else {
126
    return trm.size() > 0 && trm[0] == ':';
128
    return trm.size() > 0 && trm[0] == ':';
129
    }
130
}
131
132
133
void wholedoc(Xapian::Database* db, int docid)
134
{
135
    vector<string> buf;
136
    Xapian::TermIterator term;
137
    for (term = db->termlist_begin(docid);
138
         term != db->termlist_end(docid); term++) {
139
        Xapian::PositionIterator pos;
140
        for (pos = db->positionlist_begin(docid, *term);
141
             pos != db->positionlist_end(docid, *term); pos++) {
142
            if (buf.size() < *pos)
143
                buf.resize(2*((*pos)+1));
144
            buf[(*pos)] = *term;
145
        }
146
    }
147
    for (vector<string>::iterator it = buf.begin(); it != buf.end(); it++) {
148
        if (!it->empty())
149
            cout << *it << " ";
127
    }
150
    }
128
}
151
}
129
152
130
int main(int argc, char **argv)
153
int main(int argc, char **argv)
131
{
154
{
...
...
163
        goto b1;
186
        goto b1;
164
        case 'l':   op_flags |= OPT_l; break;
187
        case 'l':   op_flags |= OPT_l; break;
165
        case 'n':   op_flags |= OPT_n; break;
188
        case 'n':   op_flags |= OPT_n; break;
166
        case 'P':   op_flags |= OPT_P; break;
189
        case 'P':   op_flags |= OPT_P; break;
167
        case 'q':   op_flags |= OPT_q; break;
190
        case 'q':   op_flags |= OPT_q; break;
191
      case 'r':   op_flags |= OPT_r; break;
168
        case 's':   op_flags |= OPT_s; break;
192
        case 's':   op_flags |= OPT_s; break;
169
        case 'T':   op_flags |= OPT_T; break;
193
        case 'T':   op_flags |= OPT_T; break;
170
        case 't':   op_flags |= OPT_t; if (argc < 2)  Usage();
194
        case 't':   op_flags |= OPT_t; if (argc < 2)  Usage();
171
        aterm = *(++argv);
195
        aterm = *(++argv);
172
        argc--; 
196
        argc--; 
...
...
257
        }
281
        }
258
    } else if (op_flags & OPT_D) {
282
    } else if (op_flags & OPT_D) {
259
        Xapian::Document doc = db->get_document(docid);
283
        Xapian::Document doc = db->get_document(docid);
260
        string data = doc.get_data();
284
        string data = doc.get_data();
261
        cout << data << endl;
285
        cout << data << endl;
286
  } else if (op_flags & OPT_r) {
287
      wholedoc(db, docid);
262
    } else if (op_flags & OPT_X) {
288
    } else if (op_flags & OPT_X) {
263
        Xapian::Document doc = db->get_document(docid);
289
        Xapian::Document doc = db->get_document(docid);
264
        string data = doc.get_data();
290
        string data = doc.get_data();
265
        cout << data << endl;
291
        cout << data << endl;
266
        cout << "Really delete xapian document ?" << endl;
292
        cout << "Really delete xapian document ?" << endl;