//-----------------------------------------------------------------------
// 
//     Copyright (c) Microsoft Corporation.
// 
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Runtime.InteropServices;
    /// 
    /// Native (unmanaged) version of the JET_ENUMCOLUMNVALUE class.
    /// 
    [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 struct NATIVE_ENUMCOLUMNVALUE
    {
        /// 
        /// The column value that was enumerated.
        /// 
        public uint itagSequence;
        /// 
        /// Error or warning from the enumeration.
        /// 
        public int err;
        /// 
        /// Size of returned data.
        /// 
        public uint cbData;
        /// 
        /// Pointer to returned data.
        /// 
        public IntPtr pvData;
    }
    /// 
    /// Enumerates the column values of a record using the JetEnumerateColumns
    /// function. 
    /// returns an array of JET_ENUMCOLUMNVALUE
    /// structures. The array is returned in memory that was allocated using
    /// the callback that was supplied to that function.
    /// 
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.NamingRules",
        "SA1300:ElementMustBeginWithUpperCaseLetter",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules",
        "SA1305:FieldNamesMustNotUseHungarianNotation",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    public class JET_ENUMCOLUMNVALUE
    {
        /// 
        /// Gets the column value (by one-based index) that was enumerated.
        /// 
        public int itagSequence { get; internal set; }
        /// 
        /// Gets the column status code resulting from the enumeration of the
        /// column value.
        /// 
        /// 
        /// 
        /// 
        public JET_wrn err { get; internal set; }
        /// 
        /// Gets the size of the column value for the column.
        /// 
        public int cbData { get; internal set; }
        /// 
        /// Gets the value that was enumerated for the column.
        /// 
        public IntPtr pvData { get; internal set; }
        /// 
        /// Returns a  that represents the current .
        /// 
        /// 
        /// A  that represents the current .
        /// 
        public override string ToString()
        {
            return string.Format(
                CultureInfo.InvariantCulture,
                "JET_ENUMCOLUMNVALUE(itagSequence = {0}, cbData = {1})",
                this.itagSequence,
                this.cbData);
        }
        /// 
        /// Sets the fields of the object from a native JET_ENUMCOLUMN struct.
        /// 
        /// 
        /// The native enumcolumn to set the values from.
        /// 
        internal void SetFromNativeEnumColumnValue(NATIVE_ENUMCOLUMNVALUE value)
        {
            this.itagSequence = checked((int)value.itagSequence);
            this.err = (JET_wrn)value.err;
            this.cbData = checked((int)value.cbData);
            this.pvData = value.pvData;
        }
    }
}