//-----------------------------------------------------------------------
// 
//     Copyright (c) Microsoft Corporation.
// 
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop.Vista
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Runtime.InteropServices;
    /// 
    /// The native version of the JET_OPENTEMPORARYTABLE2 structure.
    /// 
    [StructLayout(LayoutKind.Sequential)]
    [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules",
        "SA1305:FieldNamesMustNotUseHungarianNotation",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.NamingRules",
        "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    internal unsafe struct NATIVE_OPENTEMPORARYTABLE2
    {
        /// 
        /// Size of the structure.
        /// 
        public uint cbStruct;
        /// 
        /// Columns to create.
        /// 
        public NATIVE_COLUMNDEF* prgcolumndef;
        /// 
        /// Number of entries in prgcolumndef.
        /// 
        public uint ccolumn;
        /// 
        /// Optional pointer to unicode index information.
        /// 
        public NATIVE_UNICODEINDEX2* pidxunicode;
        /// 
        /// Table options.
        /// 
        public uint grbit;
        /// 
        /// Pointer to array of returned columnids. This
        /// should have at least ccolumn entries.
        /// 
        public uint* rgcolumnid;
        /// 
        /// Maximum key size.
        /// 
        public uint cbKeyMost;
        /// 
        /// Maximum amount of data used to construct a key.
        /// 
        public uint cbVarSegMac;
        /// 
        /// Returns the tableid of the new table.
        /// 
        public IntPtr tableid;
    }
    
    /// 
    /// A collection of parameters for the JetOpenTemporaryTable method.
    /// 
    public partial class JET_OPENTEMPORARYTABLE
    {
        /// 
        /// Returns the unmanaged opentemporarytable that represents this managed class.
        /// 
        /// 
        /// A native (interop) version of the JET_OPENTEMPORARYTABLE.
        /// 
        internal NATIVE_OPENTEMPORARYTABLE2 GetNativeOpenTemporaryTable2()
        {
            this.CheckDataSize();
            var openTemporaryTable = new NATIVE_OPENTEMPORARYTABLE2();
            openTemporaryTable.cbStruct = checked((uint)Marshal.SizeOf(typeof(NATIVE_OPENTEMPORARYTABLE2)));
            openTemporaryTable.ccolumn = checked((uint)this.ccolumn);
            openTemporaryTable.grbit = (uint)this.grbit;
            openTemporaryTable.cbKeyMost = checked((uint)this.cbKeyMost);
            openTemporaryTable.cbVarSegMac = checked((uint)this.cbVarSegMac);
            return openTemporaryTable;
        }
    }
}