/*************************************************************************************************
 * IDL for bindings of scripting languages
 *                                                      Copyright (C) 2006-2009 Mikio Hirabayashi
 * This file is part of Tokyo Tyrant.
 * Tokyo Tyrant is free software; you can redistribute it and/or modify it under the terms of
 * the GNU Lesser General Public License as published by the Free Software Foundation; either
 * version 2.1 of the License or any later version.  Tokyo Tyrant is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with Tokyo
 * Tyrant; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA.
 *************************************************************************************************/


/**
 * namespace of Tokyo Tyrant
 */
module TokyoTyrant {
  //----------------------------------------------------------------
  // list of strings (substituted for by the native mechanism)
  //----------------------------------------------------------------
  interface List {
    string get(in long index);
  };
  //----------------------------------------------------------------
  // map of strings (substituted for by the native mechanism)
  //----------------------------------------------------------------
  interface Map {
    string get(in string key);
  };
  //----------------------------------------------------------------
  // the error codes
  //----------------------------------------------------------------
  interface ECODE {
    const long ESUCCESS = 0;
    const long EINVALID = 1;
    const long ENOHOST = 2;
    const long EREFUSED = 3;
    const long ESEND = 4;
    const long ERECV = 5;
    const long EKEEP = 6;
    const long ENOREC = 7;
    const long EMISC = 9999;
    long ecode();
    string errmsg(in long ecode);
  };
  //----------------------------------------------------------------
  // the remove database API
  //----------------------------------------------------------------
  interface RDB :ECODE {
    const long XOLCKREC = 1 << 0;
    const long XOLCKGLB = 1 << 1;
    const long MONOULOG = 1 << 0;
    boolean open(in string host, in long port);
    boolean close();
    boolean put(in string key, in string value);
    boolean putkeep(in string key, in string value);
    boolean putcat(in string key, in string value);
    boolean putshl(in string key, in string value, in long width);
    boolean putnr(in string key, in string value);
    boolean out(in string key);
    string get(in string key);
    long mget(inout Map recs);
    long vsiz(in string key);
    boolean iterinit();
    string iternext();
    List fwmkeys(in string prefix, in long max);
    long addint(in string key, in long num);
    double adddouble(in string key, in double num);
    string ext(in string name, in string key, in string value, in long opts);
    boolean sync();
    boolean optimize(in string params);
    boolean vanish();
    boolean copy(in string path);
    long long rnum();
    long long size();
    string stat();
    List misc(in string name, in List args, in long opts);
  };
  //----------------------------------------------------------------
  // the table extension API
  //----------------------------------------------------------------
  interface RDBTBL :RDB {
    const long ITLEXICAL = 0;
    const long ITDECIMAL = 1;
    const long ITTOKEN = 2;
    const long ITQGRAM = 3;
    const long ITOPT = 9998;
    const long ITVOID = 9999;
    const long ITKEEP = 1 << 24;
    boolean put(in string pkey, in Map cols);
    boolean putkeep(in string pkey, in Map cols);
    boolean putcat(in string pkey, in Map cols);
    boolean out(in string pkey);
    Map get(in string pkey);
    boolean setindex(in string name, in long type);
    long long genuid();
  };
  interface RDBQRY {
    const long QCSTREQ = 0;
    const long QCSTRINC = 1;
    const long QCSTRBW = 2;
    const long QCSTREW = 3;
    const long QCSTRAND = 4;
    const long QCSTROR = 5;
    const long QCSTROREQ = 6;
    const long QCSTRRX = 7;
    const long QCNUMEQ = 8;
    const long QCNUMGT = 9;
    const long QCNUMGE = 10;
    const long QCNUMLT = 11;
    const long QCNUMLE = 12;
    const long QCNUMBT = 13;
    const long QCNUMOREQ = 14;
    const long QCFTSPH = 15;
    const long QCFTSAND = 16;
    const long QCFTSOR = 17;
    const long QCFTSEX = 18;
    const long QCNEGATE = 1 << 24;
    const long QCNOIDX = 1 << 25;
    const long QOSTRASC = 0;
    const long QOSTRDESC = 1;
    const long QONUMASC = 2;
    const long QONUMDESC = 3;
    const long MSUNION = 0;
    const long MSISECT = 1;
    const long MSDIFF = 2;
    void addcond(in string name, in long op, in string expr);
    void setorder(in string name, in long type);
    void setlimit(in long max, in long skip);
    List search();
    boolean searchout();
    string hint();
    typedef sequence<RDBQRY> QueryList;
    List metasearch(in QueryList qrys, in long type);
  };
};



/* END OF FILE */
