Ticket #260: scriptindex.diff

File scriptindex.diff, 1.5 KB (added by Yevgeny Binder, 16 years ago)
  • scriptindex.cc

     
    2828#include <algorithm>
    2929#include <fstream>
    3030#include <iostream>
     31#include <sstream>
    3132#include <list>
    3233#include <map>
    3334#include <string>
     
    9596const char * action_names[] = {
    9697    "bad", "new",
    9798    "boolean", "date", "field", "hash", "index", "indexnopos", "load", "lower",
    98     "truncate", "unhtml", "unique", "value", "weight"
     99    "numeric", "truncate", "unhtml", "unique", "value", "weight"
    99100};
    100101
    101102// For debugging:
     
    106107    typedef enum {
    107108        BAD, NEW,
    108109        BOOLEAN, DATE, FIELD, HASH, INDEX, INDEXNOPOS, LOAD, LOWER,
    109         TRUNCATE, UNHTML, UNIQUE, VALUE, WEIGHT
     110        NUMERIC, TRUNCATE, UNHTML, UNIQUE, VALUE, WEIGHT
    110111    } type;
    111112private:
    112113    type action;
     
    233234                            code = Action::LOAD;
    234235                        }
    235236                        break;
     237                    case 'n':
     238                        if (action == "numeric") {
     239                            code = Action::NUMERIC;
     240                            arg = YES;
     241                            takes_integer_argument = true;
     242                        }
     243                        break;
    236244                    case 't':
    237245                        if (action == "truncate") {
    238246                            code = Action::TRUNCATE;
     
    591599                        if (!value.empty())
    592600                            doc.add_value(i->get_num_arg(), value);
    593601                        break;
     602                    case Action::NUMERIC:
     603                        if (!value.empty())
     604                        {
     605                                std::istringstream to_double(value);
     606                                double          value_double;
     607                               
     608                                to_double >> value_double;
     609                               
     610                            doc.add_value(i->get_num_arg(), Xapian::sortable_serialise(value_double));
     611                        }
     612                        break;
    594613                    case Action::DATE: {
    595614                        const string & type = i->get_string_arg();
    596615                        string yyyymmdd;