⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fastdbcli.cs

📁 最新版本!fastdb是高效的内存数据库系统
💻 CS
📖 第 1 页 / 共 4 页
字号:
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_fetch(int statement, QueryType queryType);

    /*=====================================================================
     * cli_insert
     *     Execute insert statement.
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     *     oid        - object identifier of created record. 
     * Returns:
     *     status code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_insert(int statement, ref uint oid);

    /*=====================================================================
     * cli_get_first
     *     Get first row of the selection.
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_get_first(int statement);

    /*=====================================================================
     * cli_get_last
     *     Get last row of the selection.
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_get_last(int statement);

    /*=====================================================================
     * cli_get_next
     *     Get next row of the selection. If get_next records is called
     *     exactly after cli_fetch function call, is will fetch the first record
     *     in selection.
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_get_next(int statement);

    /*=====================================================================
     * cli_get_prev
     *     Get previous row of the selection. If get_next records is called
     *     exactly after cli_fetch function call, is will fetch the last record
     *     in selection.
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_get_prev(int statement);

    /*=====================================================================
     * cli_skip
     *     Skip specified number of rows. 
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     *     n          - number of objects to be skipped
     *                - if "n" is positive, then this function has the same effect as
     *                     executing cli_get_next() function "n" times.
     *                - if "n" is negative, then this function has the same effect as
     *                     executing cli_get_prev() function "-n" times.
     *                - if "n"  is zero, this method just reloads current record
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_skip(int statement, int n);

    /*=====================================================================
     * cli_seek
     *    Position cursor to the record with specified OID
     * Parameters:
     *     statement   - statememt descriptor returned by cli_statement
     *     oid         - object identifier of the record to which cursor should be positioned
     * Returns:
     *     >= 0 - success, position of the record in the selection
     *     <  0 - error code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_seek(int statement, uint oid);


    /*=====================================================================
     * cli_get_oid
     *     Get object identifier of the current record
     * Parameters:
     *     statement  - statememt descriptor returned by cli_statement
     * Returns:
     *     object identifier or 0 if no object is seleected
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern uint cli_get_oid(int statement);
    
    /*=====================================================================
     * cli_update
     *     Update the current row in the selection. You have to set
     *     for_update parameter of cli_fetch to 1 in order to be able 
     *     to perform updates. Updated value of row fields will be taken
     *     from bound column variables. 
     * Parameters:
     *     statement   - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_update(int statement);

    /*=====================================================================
     * cli_remove
     *     Remove all selected records. You have to set
     *     for_update parameter of cli_fetch to 1 in order to be able 
     *     to remove records. 
     * Parameters:
     *     statement   - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_remove(int statement);

    /*=====================================================================
     * cli_free
     *     Deallocate statement and all associated data
     * Parameters:
     *     statement   - statememt descriptor returned by cli_statement
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_free(int statement);

    /*=====================================================================
     * cli_commit
     *     Commit current database transaction
     * Parameters:
     *     session - session descriptor as returned by cli_open
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_commit(int session);

    /*=====================================================================
     * cli_precommit
     *     Release all locks set by transaction. This methods allows other clients
     *     to proceed, but it doesn't flush transaction to the disk.
     * Parameters:
     *     session - session descriptor as returned by cli_open
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_precommit(int session);

    /*=====================================================================
     * cli_abort
     *     Abort current database transaction
     * Parameters:
     *     session - session descriptor as returned by cli_open
     * Returns:
     *     result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_abort(int session);

    public enum FieldFlags: int { 
      cli_noindex       = 0, /* no indexes */
      cli_hashed        = 1, /* field should be indexed usnig hash table */
      cli_indexed       = 2  /* field should be indexed using B-Tree */
    };

    [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )]
    internal struct CliFieldDescriptor {  
      public FieldType     type;
      public FieldFlags    flags;
      public IntPtr        name;
      public IntPtr        refTableName;
      public IntPtr        inverseRefFieldName;
    };

    /*=====================================================================
     * cli_describe
     *     Describe fileds of specified table
     * Parameters:
     *     session - session descriptor as returned by cli_open
     *     table   - name of the table
     *     fields  - address of the pointer to the array of fields descriptors, 
     *               this array should be later deallocated by application by cli_free_memory()
     * Returns:
     *     >= 0 - number of fields in the table
     *     < 0  - result code as described in cli_result_code enum
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern unsafe int cli_describe(
      int    session, 
      string table,
      ref void* fields);
    //[In,Out] ref CliFieldDescriptor[] fields);  // cli_field_descriptor** fields

    /*=====================================================================
     * cli_get_field_size
     *     Calculate field size
     * Parameters:
     *     fields  - array with fields descriptors obtained using cli_describe function
     *     field_no - number of the field
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_get_field_size(
      [In, Out] CliFieldDescriptor[] fields,   // cli_field_descriptor* fields
      int field_no);

    /*=====================================================================
     * cli_get_field_offset
     *     Calculate offset of the field 
     * Parameters:
     *     fields  - array with fields descriptors obtained using cli_describe function
     *     field_no - number of the field
     */
    [DllImport(libname,
       CharSet           = CharSet.Ansi,  // We want ANSI String
       CallingConvention = CallingConvention.Cdecl)]
    internal static extern int cli_get_field_offset(
      [In, Out] CliFieldDescriptor[] fields,   // cli_field_descriptor* fields
      int field_no);

    [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )]
      internal struct CliTableDescriptor {
      public IntPtr name;
    }

    /*=====================================================================
     * cli_show_tables
     *     Show all tables of specified database
     * Parameters:
     *     session - session descriptor as returned by cli_open
     *     tables  - address of the pointer to the array of tables descriptors,
     *               this array should be later deallocated by application by cli_free_memory()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -