/*++

© 1998 Seagate Software, Inc.  All rights reserved

Module Name:

    wsbint.idl

Abstract:

    IDL source for RsCommon.dll

    This file defines the WSB public interfaces and will be processed by 
    the MIDL tool to produce the type library (Wsb.tlb) and marshalling code.

Author:

    Chuck Bardeen   [cbardeen]   29-Oct-1996

Revision History:

--*/


import "oaidl.idl";
import "wsbdef.idl";

//  Forward references
interface IWsbCollectable;
interface IWsbEnum;
interface IWsbDbEntity;
interface IWsbDbSession;


/*++

Interface Name:
    
    IWsbCollectable 

Interface Description:

    Collectable interface -- allows an object to be put into a collection.

--*/

[
    object,
    uuid(9C7D6F0A-1562-11D0-81AC-00A0C91180F2),
    helpstring("IWsbCollectable Interface"),
    pointer_default(unique)
]
interface IWsbCollectable : IUnknown
{
    HRESULT CompareTo([in] IUnknown* pCollectable, [out] SHORT* pResult);

/*++

Method Name:

    CompareTo

Method Description:

   Compares the value of the object to the value given.

Arguments:

    pCollectable - Pointer to value object.

    pResult - Pointer to result: 
        >0  for object > value;
        0  for object = value;
        <0 for object < value.

Return Value:

    S_OK        - object = value

    S_FALSE     - object != value


--*/

    HRESULT IsEqual([in] IUnknown* pCollectable);

/*++

Method Name:

    IsEqual

Method Description:

    Determine if the object is equal to another object.

Arguments:

    pCollectable - Pointer to the other object.

Return Value:

    S_OK        - object = value

    S_FALSE     - object != value

--*/

};


/*++

Interface Name:
    
    IWsbCollection 

Interface Description:

    Collection of collectable objects.

--*/

[
    object,
    uuid(9C7D6F0F-1562-11D0-81AC-00A0C91180F2),
    helpstring("IWsbCollection Interface"),
    pointer_default(unique)
]
interface IWsbCollection : IUnknown
{
    HRESULT Add([in] IUnknown* pCollectable);

/*++

Method Name:

    Add

Method Description:

    Add an element to the collection. Duplicate entries
    (or items for whom IsEqual() returns S_OK) are allowed.

Arguments:

    pCollectable    - The collectable object to be added.

Return Value:

    S_OK        - The item was added.

    E_POINTER   - pCollectable is NULL.

    E_...       - Errors from AddAt()
--*/

    HRESULT Contains([in] IUnknown* pCollectable);

/*++

Method Name:

    Contains

Method Description:

    Determine whether the collection contains an element that
    IsEqual() to pCollectable.

Arguments:

    pCollectable    - The collectable object to be found.

Return Value:

    S_OK            - The collection contains the collectable.

    S_FALSE         - The collection doesn't contain the collectable.
--*/

    HRESULT GetEntries([out] ULONG* pEntries);

/*++

Method Name:
    
    GetEntries
    
Method Description:

    Return how many objects are in the collection.

Arguments:

    pEntries    - A pointer to a long that will be set to the number of entries.

Return Value:

    S_OK        - Success.

    E_POINTER   - pEntries was a NULL pointer
--*/

    HRESULT Find([in] IUnknown* pCollectable, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

       Find

Method Description:

    Searche for the first element in the collection that IsEqual()
    to pCollectable. If an element is found, then the interface specified
    by riid is returned (if it exists).

Arguments:

    pCollectable    - The collectable object to be found.

    riid            - The interface to be returned if the object is found.

    ppElement       - A pointer to be set to the found object's interface.

Return Value:

    S_OK            - The collection contains the collectable.

    WSB_E_NOTFOUND  - The collection doesn't contain the collectable.

    E_POINTER       - Either pCollectable or ppElements was a NULL pointer

    E_...           - Anything that could be returned by CopyIfmatches().
--*/

    HRESULT IsEmpty(void);

/*++

Method Name:

       IsEmpty

Method Description:

    Returns an indication of whether the collection is
    empty (i.e. has 0 entries).

Arguments:

    None.

Return Value:

    S_OK        - The collection is empty.

    S_FALSE     - The collection is not empty.
--*/

    HRESULT IsLocked(void);

/*++

Method Name:

       IsLocked

Method Description:

    Determines if a collection is locked by another thread.

Arguments:

    None.

Return Value:

    S_OK - The collection is locked by another thread
    S_FALSE - The collection is not locked by another thread (it may be locked by
            the calling thread)

--*/
    HRESULT Lock(void);

/*++

Method Name:

       Lock

Method Description:

    Locks the collection (using a critical section) for this
    thread.  Must be followed by an Unlock call.

Arguments:

    None.

Return Value:

    S_OK

--*/

    HRESULT OccurencesOf([in] IUnknown* pCollectable, [out] ULONG* occurences);

/*++

Method Name:

   OccurrencesOf

Method Description:

    Determine how many objects are considered equivalent to the object
    specified (using IsEqual()).

Arguments:

    pCollectable    - The collectable object to be found.

    pOccurences     - A pointer to where the number of occurences will
                      be written.

Return Value:

    S_OK        - At least one occurence was found.

    S_FALSE     - No occurences were found.

    E_POINTER   - Either pCollectable or pOccurences is NULL.
--*/

    HRESULT Remove([in] IUnknown* pCollectable, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    Remove

Method Description:

    Remove the first occurence of an object that matches
    (IsEqual() == S_OK) pCollectable from the collection.

Arguments:

    pCollectable    - The collectable instance we want to remove.

    riid            - The interface to be returned if the object is removed.
    
    ppElement       - A pointer where the collectable interface should be returned.

Return Value:

    S_OK            - The element was removed.

    WSB_E_NOTFOUND  - The object was not found in the collection.

    E_POINTER       - pCollectable is NULL.
--*/

    HRESULT RemoveAndRelease([in] IUnknown* pCollectable);

/*++

Method Name:

    RemoveAndRelease

Method Description:

    Remove the first item in the collection that matches pCollectable
    (using IsEqual()) and then release the instance.

Arguments:

    pCollectable    - The collectable instance to be found and removed.

Return Value:

    S_OK        - The item was removed.

    WSB_E_NOTFOUND  - The object was not found in the collection.

    E_POINTER   - pCollectable is NULL.

    E_...       - Errors from Remove()
--*/

    HRESULT RemoveAllAndRelease(void);

/*++

Method Name:

    RemoveAllAndRelease

Method Description:

    Remove all the objects from the collection and release them.

Arguments:

    None.

Return Value:

    S_OK        - All items removed.

    E_...       - Errors from RemoveAndRelease(), Enum->Last, ...
--*/

    HRESULT Unlock(void);

/*++

Method Name:

       Unlock

Method Description:

    Unlocks the collection.  Must have be preceeded by a Lock call.

Arguments:

    None.

Return Value:

    S_OK

--*/

    HRESULT Enum([out, retval] IWsbEnum** ppEnum);

/*++

Method Name:

    Enum

Method Description:

    Return an enumerator for the collection. The returned enumerator supports
    the IWsbEnum interface.

Arguments:

    ppEnum      - A pointer to where the iterface pointer should be returned.

Return Value:

    S_OK        - The enumerator was constructed.

    E_POINTER   - ppEnum is NULL.

    E_...       - Errors from CoCreateInstance() and Init()
--*/

    HRESULT EnumUnknown([out, retval] IEnumUnknown** ppEnum);

/*++

Method Name:

    EnumUnknown

Method Description:

    Return an enumerator for the collection.  The returned enumerator
    supports the IEnumUnknown interface.

Arguments:

    ppEnum      - A pointer to where the iterface pointer should be returned.

Return Value:

    S_OK        - The enumerator was constructed.

    E_POINTER   - ppEnum is NULL.

    E_...       - Errors from CoCreateInstance(), QueryInterface() and Init()
--*/

};


/*++

Interface Name:
    
    IWsbEnum 

Interface Description:

    Enumerator for a WsbCollection.

--*/

[
    object,
    uuid(9C7D6F14-1562-11D0-81AC-00A0C91180F2),
    helpstring("IWsbEnum Interface"),
    pointer_default(unique)
]
interface IWsbEnum : IUnknown

{
    HRESULT First([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    First

Method Description:

  Get the first item in the collection.

Arguments:

  riid              - The interface to be returned for the object found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection is empty.

  E_POINTER         - ppElement is NULL.

--*/

    HRESULT Next([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    Next

Method Description:

  Get the next item in the collection (i.e. the item after the current item).

Arguments:

  riid              - The interface to be returned for the object found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection is empty or the current item was the
                      last one in the collection.

  E_POINTER         - ppElement is NULL.

--*/

    HRESULT This([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    This

Method Description:

  Get the current item in the collection.

Arguments:

  riid              - The interface to be returned for the object found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The current item no longer exists, or the collection is empty.

  E_POINTER         - ppElement is NULL.

--*/

    HRESULT Previous([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    Previous

Method Description:

  Get the previous item in the collection (i.e. the item before the current item).

Arguments:

  riid              - The interface to be returned for the object found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection is empty or the current item was the
                      first in the collection.

  E_POINTER         - ppEelement is NULL.

--*/

    HRESULT Last([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    Last

Method Description:

  This method gets the last item in the collection.

Arguments:

  riid              - The interface to be returned for the object found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection is empty.

  E_POINTER         - ppElement is NULL.

--*/

    
    HRESULT FindNext([in] IUnknown* pCollectable, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    FindNext

Method Description:

  Find the next item in the collection (starting after the current item)
  that matches (IsEqual() = S_OK) the item specified.

Arguments:

  pCollectable      - The item for which we are looking.

  riid              - The interface to be returned for the object found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection past the current item does not contain 
                        the item.

  E_POINTER         - ppElement is NULL.

--*/

    HRESULT Find([in] IUnknown* pCollectable, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    Find

Method Description:

  Find the first item in the collection that matches
  (IsEqual() = S_OK) the item specified.

Arguments:

  pCollectable      - The item for which we are looking.

  riid              - The interface to be returned for the objects found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection does not contain the item.

  E_POINTER         - ppElement is NULL.

--*/

    HRESULT FindPrevious([in] IUnknown* pCollectable, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    FindPrevious

Method Description:

  Find the previous item in the collection (from before the
  current item) that matches (IsEqual() = S_OK) the item specified.

Arguments:

  pCollectable      - The item for which we are looking.

  riid              - The interface to be returned for the objects found.

  ppElement         - A pointer to where the interface should be returned.

Return Value:

  S_OK              - The requested element was returned.

  WSB_E_NOTFOUND    - The collection before the current item does not contain 
                        the item.

  E_POINTER         - ppElement is NULL.

--*/


    HRESULT SkipToFirst(void);

/*++

Method Name:

    SkipToFirst

Method Description:

  Reset the current item to the beginning of the list.

Arguments:

  None.

Return Value:

  S_OK              - Success.

  S_FALSE           - There are no elements in the collection.

--*/

    HRESULT SkipNext([in] ULONG element);

/*++

Method Name:

    SkipNext

Method Description:

  Move the current index forward 'element' elements. If this
  puts the current index beyond the end of the collection, then it will
  be set to the end.

Arguments:

  element - The number of elements to skip.

Return Value:

  S_OK          - Success.

  S_FALSE       - The request would have put the item beyond the end of 
                    the collection.

--*/

    HRESULT SkipTo([in] ULONG index);

/*++

Method Name:

    SkipTo

Method Description:

  Set the current item to the index'th element in the collection.

Arguments:

  index     - The index number.

Return Value:

  S_OK              - Success.

  S_FALSE           - The index value was beyond the end of the collection,
                      so the index will be placed at the end instead.

--*/

    HRESULT SkipPrevious([in] ULONG element);

/*++

Method Name:

    SkipPrevious

Method Description:

  Move the current index backward 'element' elements. If this
  puts the current index beyond the beginning of the collection, then it will
  be set to the beginning.

Arguments:

  element - The number of elements to skip.

Return Value:

  S_OK          - Success.

  S_FALSE       - The request would have put the index before the beginning
                    of the collection.

--*/

    HRESULT SkipToLast(void);

/*++

Method Name:

    SkipToLast

Method Description:

  Set the current item to the last element of the collection.

Arguments:

  None.

Return Value:

  S_OK              - Success.

  S_FALSE           - There are no elements in the collection.

--*/


    HRESULT Reset(void);

/*++

Method Name:

    Reset

Method Description:

    Set the current item to the first element.

Arguments:

    None.

Return Value:

    S_OK    - Success.

  S_FALSE           - There are no elements in the collection.

--*/

    HRESULT Init([in] IWsbCollection* pCollection);

/*++

Method Name:

    Init

Method Description:

  Initialize the enumerator and associate it with the collection
  specified.

Arguments:

  pCollection       - The collection.

Return Value:

  S_OK              - Success.

  S_FALSE           - Already initialized.

  E_POINTER         - pCollection is NULL.

--*/

    HRESULT Clone([out] IWsbEnum** ppEnum);

/*++

Method Name:

    Clone

Method Description:

    Make a copy of this enumerator.

Arguments:

    ppEnum - Pointer to pointer to enumerator.

Return Value:

    S_OK    - Success.

  E_POINTER         - ppEnum is NULL.

--*/

};


/*++

Interface Name:
    
    IWsbEnumEx 

Interface Description:

    Exteneded enumerator for a WsbCollection.

--*/

[
    object,
    uuid(F5A3AC60-9993-11d0-81E7-00A0C91180F2),
    helpstring("IWsbEnumEx Interface"),
    pointer_default(unique)
]
interface IWsbEnumEx : IUnknown

{
    HRESULT First([in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    First

Method Description:

  Find the first 'element' items in the collection.

Arguments:

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection is empty.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    HRESULT Next([in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    Next

Method Description:

  Find the next 'element' items in the collection, starting with
  the item after the current item.

Arguments:

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection is empty or the current item was the
                        last one in the collection.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    HRESULT This([in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    This

Method Description:

  Find the next 'element' items in the collection, starting with
  the current item.

Arguments:

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elemens were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection is empty.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    HRESULT Previous([in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    Previous

Method Description:

  Find the previous 'element' items in the collection, starting with
  the item before the current item.

Arguments:

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the request elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection is empty or the current item was the
                        first in the collection.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    HRESULT Last([in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    Last

Method Description:

  This method finds the last 'element' items in the collection. If
  multiple elements are requested, then they will be returned in order
  starting from the last element (i.e. n, n-1, n-2, n-3, ...).

Arguments:

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection is empty.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    
    HRESULT FindNext([in] IUnknown* pCollectable, [in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    FindNext

Method Description:

  Find the next 'element' items in the collection (starting past the
  current item) that match (IsEqual = S_OK) the collectable specified.

Arguments:

  pCollectable      - The item for which we are looking.

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection past the current item does not contain 
                        the collectable.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    HRESULT Find([in] IUnknown* pCollectable, [in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    Find

Method Description:

  Find the first 'element' items in the collection that match
  (IsEqual = S_OK) the collectable specified.

Arguments:

  pCollectable      - The item for which we are looking.

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection does not contain the collectable.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/

    HRESULT FindPrevious([in] IUnknown* pCollectable, [in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), length_is(*pElementsFetched)] void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    FindPrevious

Method Description:

  Find the previous 'element' items in the collection (from before the
  current item) that match (IsEqual = S_OK) the collectable specified.

Arguments:

  pCollectable      - The item for which we are looking.

  element           - The number of elements to retrieve.

  riid              - The interface to be returned for the objects found.

  elements          - A pointer to an array of interface pointers at least
                      as large as the number of elements requested.

  pElementsFetched  - The number of elements actually returned. This can
                      be NULL if only one item is requested.

  Return Value:

  S_OK              - All the requested elements were returned.

  S_FALSE           - Some elements were returned, but less than the number
                      requested.

  WSB_E_NOTFOUND    - The collection before the current item does not contain 
                        the collectable.

  E_POINTER         - elements is NULL.

  E_INVALIDARG      - element = 0.

--*/


    HRESULT SkipToFirst(void);

/*++

Method Name:

    SkipToFirst

Method Description:

  Reset the current item to the beginning of the list.

Arguments:

  None.

Return Value:

  S_OK              - Success.

  S_FALSE           - There are no elements in the collection.

--*/

    HRESULT SkipNext([in] ULONG element);

/*++

Method Name:

    SkipNext

Method Description:

  Move the current index forward 'element' elements. If this
  puts the current index beyond the end of the collection, then it will
  be set to the end.

Arguments:

  element - The number of elements to skip.

Return Value:

  S_OK          - Success.

  S_FALSE       - The request would have put the item beyond the end of 
                    the collection.

--*/

    HRESULT SkipTo([in] ULONG index);

/*++

Method Name:

    SkipTo

Method Description:

  Set the current item to the index'th element in the collection.

Arguments:

  index     - The index number.

Return Value:

  S_OK              - Success.

  S_FALSE           - The index value was beyond the end of the collection,
                      so the index will be placed at the end instead.

--*/

    HRESULT SkipPrevious([in] ULONG element);

/*++

Method Name:

    SkipPrevious

Method Description:

  Move the current index backward 'element' elements. If this
  puts the current index beyond the beginning of the collection, then it will
  be set to the beginning.

Arguments:

  element - The number of elements to skip.

Return Value:

  S_OK          - Success.

  S_FALSE       - The request would have put the index before the beginning
                    of the collection.

--*/

    HRESULT SkipToLast(void);

/*++

Method Name:

    SkipToLast

Method Description:

  Set the current item to the last element of the collection.

Arguments:

  None.

Return Value:

  S_OK              - Success.

  S_FALSE           - There are no elements in the collection.

--*/


    HRESULT Reset(void);

/*++

Method Name:

    Reset

Method Description:

    Set the current item to the first element.

Arguments:

    None.

Return Value:

    S_OK    - Success.

  S_FALSE           - There are no elements in the collection.

--*/

    HRESULT Init([in] IWsbCollection* pCollection);

/*++

Method Name:

    Init

Method Description:

  Initialize the enumerator and associate it with the collection
  specified.

Arguments:

  pCollection       - The collection.

Return Value:

  S_OK              - Success.

  S_FALSE           - Already initialized.

  E_POINTER         - pCollection is NULL.

--*/

    HRESULT Clone([out] IWsbEnum** ppEnum);

/*++

Method Name:

    Clone

Method Description:

    Make a copy of this enumerator.

Arguments:

    ppEnum - Pointer to pointer to enumerator.

Return Value:

    S_OK    - Success.

  E_POINTER         - ppEnum is NULL.

--*/

};


/*++

Interface Name:
    
    IWsbGuid 

Interface Description:

    GUID.

--*/

[
    object,
    uuid(A0FF1F41-237A-11D0-81BA-00A0C91180F2),
    helpstring("IWsbGuid Interface"),
    pointer_default(unique)
]
interface IWsbGuid : IWsbCollectable
{
    HRESULT CompareToGuid([in] GUID value, [out] SHORT* pResult);

/*++

Method Name:

    CompareToGuid

Method Description:

   Compares the value of the object to the value given.

Arguments:

    value - Input value

    pResult - Pointer to result: 
        >0  for object > value;
        0  for object = value;
        <0 for object < value.

Return Value:

    S_OK        - object = value

    S_FALSE     - object != value


--*/

    HRESULT CompareToIGuid([in] IWsbGuid* pGuid, [out] SHORT* pResult);

/*++

Method Name:

    CompareToIGuid

Method Description:

   Compares the value of the object to the value given.

Arguments:

    pGuid - Pointer to GUID object.

    pResult - Pointer to result: 
        >0  for object > value;
        0  for object = value;
        <0 for object < value.

Return Value:

    S_OK        - object = value

    S_FALSE     - object != value


--*/

    HRESULT GetGuid([out] GUID* pValue);

/*++

Method Name:

    GetGuid

Method Description:

    Return the object's value.

Arguments:

    pValue - Pointer to return value.

Return Value:

    S_OK        - Success.

    E_POINTER   - Passed in pointer is null.

--*/

    HRESULT SetGuid([in] GUID value);

/*++

Method Name:

    SetGuid

Method Description:

    Set the object's value.

Arguments:

    value - Input value

Return Value:

    S_OK        - Success.

--*/

};


/*++

Interface Name:
    
    IWsbIndexedCollection 

Interface Description:

    Indexed collection.

--*/

[
    object,
    uuid(A5B69200-214B-11D0-81B7-00A0C91180F2),
    helpstring("IWsbIndexedCollection Interface"),
    pointer_default(unique)
]
interface IWsbIndexedCollection : IWsbCollection
{
    HRESULT AddAt([in] IUnknown* pCollectable, [in] ULONG index);

/*++

Method Name:

    AddAt

Method Description:

    Add the collectable to the collection at the index specified.

Arguments:

    pCollectable    - The collectable instance we want to add.

    index           - The location (zero based) at which to add the item. An item
                      already at this location and all following items will be shifted
                      up one.

Return Value:

    S_OK            - The element was added.

    E_POINTER       - pCollectable is NULL.
--*/

    HRESULT Append([in] IUnknown* pCollectable);

/*++

Method Name:

    Append

Method Description:

    Add an element to the end of the collection. Duplicate entries
    (or items for whom IsEqual() returns S_OK) are allowed.

Arguments:

    pCollectable    - The collectable instance to be added.

Return Value:

    S_OK        - The item was added.

    E_POINTER   - pCollectable is NULL.

    E_...       - Errors from Add()
--*/

    HRESULT Prepend([in] IUnknown* pCollectable);

/*++

Method Name:

    Prepend

Method Description:

    Add the collectable to the beginning of the collection.

Arguments:

    pCollectable    - The collectable instance we want to add.

Return Value:

    S_OK            - The element was added.

    WSB_E_NOTFOUND  - The collection is empty.

    E_POINTER       - ppElement is NULL.
--*/

    HRESULT RemoveAt([in] ULONG index, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    RemoveAt

Method Description:

    Remove the collectable at the specified index from the collection and
    return it. All other elements are shifted down to fill the hole.

Arguments:


    index       - The location (zero based) from which the item should be
                  removed.

    riid        - The interface to be returned if the object is found.

    ppElement   - A pointer to the interface that will be returned for the
                  removed item. If this is NULL, then the item is released
                  and not returned.

Return Value:

    S_OK                - The element was removed.

    WSB_E_OUTOFBOUNDS   - The index is outside the range of legal elements.
--*/

    HRESULT First([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    First

Method Description:

    Get the first element.

Arguments:

    riid        - The interface to be returned if the object is found.

    ppElement   - A pointer where the collectable should be returned.

Return Value:

    S_OK    - Success.

--*/

    HRESULT At([in] ULONG index, [in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    At

Method Description:

    Return the collectable at the specified index.

Arguments:

    index       - The location (zero based) of the item that should be
                  found.

    riid        - The interface to be returned if the object is found.
    
    ppElement   - A pointer where the collectable should be returned.

Return Value:

    S_OK                - The element was found.

    WSB_E_OUTOFBOUNDS   - The index value is bigger than the last element.

    E_POINTER           - ppElement is NULL.
--*/

    HRESULT Last([in] REFIID riid, [out, iid_is(riid)] void** ppElement);

/*++

Method Name:

    Last

Method Description:

    Return the last element in the collection.

Arguments:

    riid        - The interface to be returned if the object is found.
    
    ppElement   - A pointer where the collectable should be returned.

Return Value:

    S_OK            - The last element was returned.

    WSB_E_NOTFOUND  - The collection is empty.

    E_POINTER       - ppElement is NULL.
--*/
    
    HRESULT Index([in] IUnknown* pCollectable, [in] ULONG* pIndex);


/*++

Method Name:

    Index

Method Description:

    Return the index of an element in the collection.

Arguments:

    pCollectable    - The collectable instance whose index we want.
    
    pIndex          - A pointer to where the index should be returned.

Return Value:

    S_OK            - The index of the element was determined.

    WSB_E_NOTFOUND  - The element is not in the collection.

    E_POINTER       - pCollectable or pIndex is NULL.
--*/
    
    HRESULT Copy([in] ULONG start, [in] ULONG stop, [in] REFIID riid, [out, iid_is(riid), size_is((stop > start) ? (stop - start) : (start - stop),), length_is(*pElementsFetched)]void** elements, [out] ULONG* pElementsFetched);

/*++

Method Name:

    Copy

Method Description:

    Copy a range of entries from the collection to the elements

Arguments:

    start               - The index value where the copying should start.
    
    stop                - The index value where the copying should stop.

    riid                - The interface to be returned for the objects found.
    
    elements            - A pointer where the collectables should be returned.

    pElementsFetched    - The number of items copied.

Return Value:

    S_OK                - All the elements were copied.

    S_FALSE             - Fewer elements were copied than requested.

    WSB_E_NOTFOUND      - The index value is bigger than the last element.

    E_POINTER           - elements or pElementsFetched is NULL.
--*/

    HRESULT CopyIfMatches([in] ULONG start, [in] ULONG stop, [in] IUnknown* pCollectable, 
    [in] ULONG element, [in] REFIID riid, [out, iid_is(riid), size_is(element,), 
    length_is(*pElementsFetched)]void** elements, [out] ULONG* pElementsFetched, [out] ULONG* pStoppedAt);

/*++

Method Name:

    CopyIfMatches

Method Description:

    Copy matching elements from a range of entries in the collection.

Arguments:

    start               - The index value where the search should start.
    
    stop                - The index value where the search should stop.

    pCollectable        - The collectable we are trying to match (IsEqual()
                           == S_OK).

    element             - The number of matches to look for.

    riid                - The interface to be returned for the objects found.
    
    elements            - A pointer where the collectables should be returned.

    pElementsFetched    - The number of items copied. Can be null if only
                          1 item was requested.

    pStoppedAt          - The last index that was checked.

Return Value:

    S_OK                - All the elements were copied.

    S_FALSE             - Fewer elements were copied than requested.

    WSB_E_NOTFOUND      - No matching elements were found in the given range.

    E_POINTER           - elements, pStoppedAt is NULL.
--*/

};

/*++

Interface Name:
    
    IWsbPersistStream

Interface Description:

    Implements an interface for an object persistable
    from/to a stream.

--*/

[
    object,
    uuid(C4D14AA2-79EE-11D0-9909-00A0C9058BF6),
    helpstring("IWsbPersistStream Interface"),
    pointer_default(unique)
]
interface IWsbPersistStream : IUnknown
{

    HRESULT SetIsDirty([in] BOOL isDirty);

/*++

Method Name:

   SetIsDirty

Method Description:

  Set the dirty bit to indicate whether the instance has been modified since it
  was lasted persisted.

Arguments:

  isDirty       - A boolean that is TRUE if the instance has been modified
                  since it was last persisted.

Return Value:

  S_OK              - Success
--*/

}

/*++

Interface Name:
    
    IWsbPersistable 

Interface Description:

    Persistable.

--*/

[
    object,
    uuid(5BF46531-282D-11D0-81BE-00A0C91180F2),
    helpstring("IWsbPersistable Interface"),
    pointer_default(unique)
]
interface IWsbPersistable : IWsbPersistStream
{

    HRESULT GetDefaultFileName([in, out, string, size_is(bufferSize)] OLECHAR** pFilename, [in] ULONG bufferSize);

/*++

Method Name:

   GetDefaultFileName

Method Description:

  Get the default file name template. The
  default file name is the type (e.g. *.cpp). If the instance hasn't had
  a file name specified, then this default template can be used to find a 
  list of possible candidates.

Arguments:

  pFileName     - A pointer to the string that will be set. If NULL, then
                  COM memory will be allocated an it's pointer returned.

  bufferSize    - The size of the buffer provided (or to be allocated). A
                  size of 0 means that the buffer should be allocated to
                  the size needed (and assumes that the memory was allocated
                  by COM).

Return Value:

  S_OK              - Success

  E_OUTOFMEMORY     - Unable to get memory to allocate the buffer.

--*/

    HRESULT ReleaseFile(void);

/*++

Method Name:

   ReleaseFile

Method Description:

   Release the persistence file.  After this method is called, the next call
   to IPersistFile::Save must supply a file name.

Arguments:

  None

Return Value:

  S_OK              - Success

--*/

    HRESULT SetDefaultFileName([in, string] OLECHAR* fileName);

/*++

Method Name:

       SetDefaultFileName

Method Description:

  Set the default file name template. The
  default file name is the type (e.g. *.cpp). If the instance hasn't had
  a file name specified, then this default template can be used to find a 
  list of possible candidates.

Arguments:

  fileName      - The string to which the default file name will be set.

Return Value:

  S_OK              - Success

  E_OUTOFMEMORY     - Unable to get memory to allocate the buffer.

--*/
};

/*++

Interface Name:
    
    IWsbString 

Interface Description:

    String.

--*/

[
    object,
    uuid(DB35D731-21E9-11D0-81B8-00A0C91180F2),
    helpstring("IWsbString Interface"),
    pointer_default(unique)
]
interface IWsbString : IWsbCollectable
{
    HRESULT CompareToString([in, string] OLECHAR* value, [out] SHORT* pResult);

/*++

Method Name:

    CompareToString

Method Description:

   Compares the value of the object to the value given.

Arguments:

    value - Input value

    pResult - Pointer to result: 
        >0  for object > value;
        0  for object = value;
        <0 for object < value.

Return Value:

    S_OK        - object = value

    S_FALSE     - object != value


--*/

    HRESULT CompareToIString([in] IWsbString* pString, [out] SHORT* pResult);

/*++

Method Name:

    CompareToIString

Method Description:

   Compares the value of the object to the value given.

Arguments:

    pString - Pointer to string object.

    pResult - Pointer to result: 
        >0  for object > value;
        0  for object = value;
        <0 for object < value.

Return Value:

    S_OK        - object = value

    S_FALSE     - object != value


--*/

    HRESULT GetString([in, out, string] OLECHAR** pValue, [in] ULONG bufferSize);

/*++

Method Name:

    GetString

Method Description:

    Return the object's value.

Arguments:

    pValue      - A pointer the variable that should be set to the
                  value of the object. If NULL, then a buffer will
                  be allocated, that will need to be freed by the
                  caller (using CoTaskMemFree()).

    bufferSize  - The size of the buffer provided or allocated. A size
                     of 0 means that a string should be allocated that is
                     just large enough to hold the string.

Return Value:

    S_OK        - Success.

    E_POINTER       - Passed in pointer is null.

    E_OUTOFMEMORY   - Not enough memory to store the string.

--*/

    HRESULT GetStringAndCase([in, out, string] OLECHAR** pValue, [out] BOOL* pIsCaseDependent, [in] ULONG bufferSize);

/*++

Method Name:

    GetStringAndCase

Method Description:

    Get the string and case dependency for this object.

Arguments:

    pValue              - A pointer the variable that should be set to the
                          value of the object. If NULL, then a buffer will
                          be allocated, that will need to be freed by the
                          caller (using CoTaskMemFree()).

    pIsCaseDependent    - A pointer to a boolean that will be set according to
                          whehther the string is case dependent.

    bufferSize          - The size of the buffer provided or allocated. A size
                          of 0 means that a string should be allocated that is
                          just large enough to hold the string.


Return Value:

    S_OK            - Success.

    E_POINTER       - Passed in pointer is null.

    E_OUTOFMEMORY   - Not enough memory to store the string.


--*/

    HRESULT IsCaseDependent(void);

/*++

Method Name:

    IsCaseDependent

Method Description:

    Indicates whether the object considers itself to be case dependent. This
    information is used during comparisons.

Arguments:

    None.

Return Value:

    S_OK        - Is Case Dependent

    S_FALSE     - Is Not Case Dependent


--*/

    HRESULT SetIsCaseDependent([in] BOOL isCaseDependent);

/*++

Method Name:

    SetIsCaseDependent

Method Description:

    Set whether the string is considered case dependent or
    case independent. This information is used during comparisons.

Arguments:

    isCaseDependent     - A boolean that is TRUE when the string is to be case
                          dependent (i.e. "AB" != "ab").

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetString([in, string] OLECHAR* value);

/*++

Method Name:

    SetString

Method Description:

    Set the object's value.

Arguments:

    value - Input value

Return Value:

    S_OK    - Success.

--*/

    HRESULT SetStringAndCase([in, string] OLECHAR* value, [in] BOOL isCaseDependent);

/*++

Method Name:

    SetStringAndCase

Method Description:

    Set the value of this object and its case dependency.

Arguments:

    value               - The value to which the object should be set.

    isCaseDependent     - A boolean that is TRUE when the string is case
                          dependent (i.e. "AB" != "ab").


Return Value:

    S_OK            - Success.

    E_OUTOFMEMORY   - Not enough memory to store the string.

--*/

};


/*++

Interface Name:
    
    IWsbTestable 

Interface Description:

    Testable.

--*/

[
    object,
    uuid(05342021-25D8-11D0-81BB-00A0C91180F2),
    helpstring("IWsbTestable Interface"),
    pointer_default(unique)
]
interface IWsbTestable : IUnknown
{
    HRESULT Test([out] USHORT *passed, [out] USHORT* failed);

/*++

Method Name:

    Test

Method Description:

    Run the object self-test code.

Arguments:

    passed - Set to the number of tests passed.

    failed - Set to the number of tests failed.

Return Value:

    S_OK    - Success.

--*/

};


/*++

Interface Name:
    
    IWsbDbSys

Interface Description:

    ISAM Database system.

--*/

[
    object,
    uuid(F2608980-0A45-47B4-B110-37EA59F67C47),
    helpstring("IWsbDbSys Interface"),
    pointer_default(unique)
]
interface IWsbDbSys : IUnknown
{

    HRESULT Backup([in, string] OLECHAR* path, [in] ULONG flags);

/*++

Method Name:

    Backup

Method Description:

   Backup databases to the given directory.  Can not be called before Init.

Arguments:

    path  - Directory where backup files are to be saved.

    flags - Flags that control the backup.

Return Value:

    S_OK        - Success.

--*/

    HRESULT Init([in, string] OLECHAR* path, [in] ULONG flags);

/*++

Method Name:

    Terminate

Method Description:

   Initializes the IDB system for this instance.

Arguments:

    path  - Pathname for auxiliary IDB data.  Can be NULL for default.
    flags - Some combination of IDB_SYS_INIT_FLAG_* values or together or zero.

Return Value:

    S_OK        - Success.

--*/

    HRESULT Terminate(void);

/*++

Method Name:

    Init

Method Description:

   Cleans up the IDB system for this instance.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT NewSession([out] IWsbDbSession** ppSession);

/*++

Method Name:

    NewSession

Method Description:

   Create a new IDB session and return it.

Arguments:

    ppSession - Address of pointer to new session.

Return Value:

    S_OK        - Success.

--*/

    HRESULT GetGlobalSession([out] IWsbDbSession** ppSession);

/*++

Method Name:

    GetGlobalSession

Method Description:

   Retruns the global IDB session for the corresponding Jet instance.

Arguments:

    ppSession - Address of pointer to receive the global session.

Return Value:

    S_OK        - Success.

--*/

    HRESULT Restore([in, string] OLECHAR* fromPath, [in, string] OLECHAR* toPath);

/*++

Method Name:

    Restore

Method Description:

   Restore databases. Must be called before Init.

Arguments:

    fromPath - Directory where backup files are.

    toPath   - Directory where DBs are to be restored.

Return Value:

    S_OK        - Success.

--*/

    HRESULT IncrementChangeCount(void);

/*++

Method Name:

    IncrementChangeCount

Method Description:

   Increment counter for number of changes for this isntance.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/
};


/*++

Interface Name:
    
    IWsbDb 

Interface Description:

    ISAM Database.

--*/

[
    object,
    uuid(D7A42F4A-117C-47A3-9C30-92D63A4919E4),
    helpstring("IWsbDb Interface"),
    pointer_default(unique)
]
interface IWsbDb : IUnknown
{

    HRESULT Close([in] IWsbDbSession* pSession);

/*++

Method Name:

    Close

Method Description:

    Close the data base.

Arguments:

    pSession  - Pointer to IDB session.

Return Value:

    S_OK            - Success.

--*/

    HRESULT Create([in, string] OLECHAR* path, [in, defaultvalue(0)] ULONG flags);

/*++

Method Name:

    Create

Method Description:

   Creates a new data base at the path given.

Arguments:

    path - Pathname for data base.

Return Value:

    S_OK        - Success.

    E_OUTOFMEMORY   - Unable to allocate memory.

--*/

    HRESULT Delete([in, string] OLECHAR* path, [in, defaultvalue(0)] ULONG flags);

/*++

Method Name:

    Delete

Method Description:

   Deletes a data base at the path given.

Arguments:

    path - Pathname for data base. (If NULL, use stored path.)

Return Value:

    S_OK        - Success.

    S_FALSE     - Data base didn't exist

    E_*         - Some error occurred

--*/

    HRESULT Dump([in, string] OLECHAR* Filename, [in] ULONG Flags, [in] ULONG Data);

/*++

Method Name:

    Dump

Method Description:

   Writes human-readable info to the text file given by filename.

Arguments:

    Filename - Pathname for output file.

    Flags    - Controls what to dump.  (See IDB_DUMP_FLAG_* defines.)

    Data     - Use depends on flags.

Return Value:

    S_OK        - Success.

--*/

    HRESULT GetEntity([in] IWsbDbSession* pSession, [in] ULONG RecId, [in] REFIID riid, [out, retval, iid_is(riid)] void** ppEntity);

/*++

Method Name:

    GetEntity

Method Description:

   Returns a DB entity for the record type given.

Arguments:

    pSession  - Pointer to IDB session.

    RecId - Record type identifier.

    riid   - The interface to be returned in ppEntity.

    ppEntity - Pointer into which to return the requested interface.

Return Value:

    S_OK        - Success.

--*/

    HRESULT GetName([out, string] OLECHAR** pName);

/*++

Method Name:

    GetName

Method Description:

   Returns the name of this data base.

Arguments:

    pName - Pointer to name for data base.

Return Value:

    S_OK        - Success.

    E_OUTOFMEMORY   - Unable to allocate memory.

--*/

    HRESULT GetPath([out, string] OLECHAR** pPath);

/*++

Method Name:

    GetPath

Method Description:

   Returns the path of this data base.

Arguments:

    pPath - Pointer to pathname for data base.

Return Value:

    S_OK        - Success.

    E_OUTOFMEMORY   - Unable to allocate memory.

--*/

    HRESULT GetVersion([out] ULONG* pVer);

/*++

Method Name:

    GetVersion

Method Description:

   Returns the version number of this data base.

Arguments:

    pVer - Pointer to version for data base.

Return Value:

    S_OK        - Success.

--*/

    HRESULT Locate([in, string] OLECHAR* path);

/*++

Method Name:

    Locate

Method Description:

    Locate an existing data base.

Arguments:

   path - Pointer to the data base path. If this is NULL, the
            standard locations (whatever that means) are searched
            for a DB of this type.

Return Value:

    S_OK            - The data base was found and validated.

    E_OUTOFMEMORY   - Unable to allocate memory.

--*/

    HRESULT Open([in, out] IWsbDbSession** ppSession);

/*++

Method Name:

    Open

Method Description:

    Open the data base.

Arguments:

    ppSession  - Address of IDB session pointer.  If the session pointer is NULL,
        Open returns a new session.  Otherwise, the session passed in is used.

Return Value:

    S_OK            - Success.

--*/

};

[
    object,
    uuid(01973831-E996-11d0-9928-00A0C9058BF6),
    helpstring("IWsbDbSession Interface"),
    pointer_default(unique)
]
interface IWsbDbSession : IUnknown
{

    HRESULT TransactionBegin(void);

/*++

Method Name:

    TransactionBegin

Method Description:

    Begin a transaction on the data base.

Arguments:

    None.

Return Value:

    S_OK            - Success.

--*/

    HRESULT TransactionCancel(void);

/*++

Method Name:

    TransactionCancel

Method Description:

    Cancel (rollback) the current transaction on the data base.

Arguments:

    None.

Return Value:

    S_OK            - Success.

--*/

    HRESULT TransactionEnd(void);

/*++

Method Name:

    TransactionEnd

Method Description:

    End the current transaction on the data base and commit the changes.

Arguments:

    None.

Return Value:

    S_OK            - Success.

--*/

};


/*++

Interface Name:
    
    IWsbDbKey 

Interface Description:

    Data base key.  Used only by DbEntity code.

--*/

[
    object,
    uuid(46CE9EDA-447C-11D0-98FC-00A0C9058BF6),
    helpstring("IWsbDbKey Interface"),
    pointer_default(unique)
]
interface IWsbDbKey : IUnknown
{

    HRESULT AppendBool([in] BOOL value);

/*++

Method Name:

    AppendBool

Method Description:

   Append to the key a BOOL.

Arguments:

    value - The BOOL value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT AppendBytes([in, size_is(size)] UCHAR* bytes, [in] ULONG size);

/*++

Method Name:

    AppendBytes

Method Description:

   Append to the key an array of bytes.

Arguments:

    bytes - The array of bytes.

    size - The number of bytes in the key.

Return Value:

    S_OK        - Success.

--*/

    HRESULT AppendFiletime([in] FILETIME value);

/*++

Method Name:

    AppendFiletime

Method Description:

   Append to the key a FILETIME value.

Arguments:

    value - The FILETIME value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT AppendGuid([in] GUID value);

/*++

Method Name:

    AppendGuid

Method Description:

   Append to the key a GUID.

Arguments:

    value - The GUID value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT AppendLonglong([in] LONGLONG value);

/*++

Method Name:

    AppendLonglong

Method Description:

   Append to the key a LONGLONG value.

Arguments:

    value - The LONGLONG value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT AppendString([in, string] OLECHAR* value);

/*++

Method Name:

    AppendString

Method Description:

   Append to the key with a UNICODE character string value.

Arguments:

    value - The string to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT GetType([out] ULONG* pType);

/*++

Method Name:

    GetType

Method Description:

   Return the type of this DB key.

Arguments:

    pType - Pointer to a ULONG to receive the type value.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToBool([in] BOOL value);

/*++

Method Name:

    SetToBool

Method Description:

   Set the key to an BOOL value.

Arguments:

    value - The BOOL vale to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToBytes([in, size_is(size)] UCHAR* bytes, [in] ULONG size);

/*++

Method Name:

    SetToBytes

Method Description:

   Set the key to an array of bytes.

Arguments:

    bytes - The array of bytes.

    size - The number of bytes in the key.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToFiletime([in] FILETIME value);

/*++

Method Name:

    SetToFiletime

Method Description:

   Set the key to an FILETIME value.

Arguments:

    value - The FILETIME value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToGuid([in] GUID value);

/*++

Method Name:

    SetToGuid

Method Description:

   Set the key to an GUID value.

Arguments:

    value - The GUID value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToLonglong([in] LONGLONG value);

/*++

Method Name:

    SetToLonglong

Method Description:

   Set the key to an LONGLONG value.

Arguments:

    value - The LONGLONG value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToUlong([in] ULONG value);

/*++

Method Name:

    SetToUlong

Method Description:

   Set the key to an unsigned long value.

Arguments:

    value - The ULONG value to use.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetToString([in, string] OLECHAR* value);

/*++

Method Name:

    SetToString

Method Description:

   Set the key to an UNICODE character string value.

Arguments:

    value - The string to use.

Return Value:

    S_OK        - Success.

--*/

};


/*++

Interface Name:
    
    IWsbDbEntity

Interface Description:

    Data base entity.  Used to access records in the DB.

--*/

[
    object,
    uuid(FC7FB18F-F497-47A6-A28F-7CC4BFECAA5E),
    helpstring("IWsbDbEntity Interface"),
    pointer_default(unique)
]
interface IWsbDbEntity : IUnknown
{

    HRESULT Clone([in] REFIID riid, [out, retval, iid_is(riid)] void** ppEntity);

/*++

Method Name:

    Clone

Method Description:

    Make a copy of this entity.

Arguments:

    riid   - The interface to be returned in ppEntity.

    ppEntity - Pointer into which to return the requested interface.

Return Value:

    S_OK    - Success.

--*/

    HRESULT Disconnect(void);

/*++

Method Name:

       Disconnect

Method Description:

    Remove the entities association with a database object.  (This is
    useful for giving the entity to another process without allowing the
    other process to access/change the DB.)

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT FindEQ(void);

/*++

Method Name:

       FindEQ

Method Description:

    Search for the first record in the DB with a key that matches 
    the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT FindGT(void);

/*++

Method Name:

       FindGT

Method Description:

    Search for the first record in the DB with a key that is
    greater than the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT FindGTE(void);

/*++

Method Name:

       FindGTE

Method Description:

    Search for the first record in the DB with a key that is
    greater than or equal to the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT FindLT(void);

/*++

Method Name:

       FindLT

Method Description:

    Search for the last record in the DB with a key that is
    less than the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT FindLTE(void);

/*++

Method Name:

       FindLTE

Method Description:

    Search for the last record in the DB with a key that is
    less than or equal to the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/


    HRESULT First(void);

/*++

Method Name:

    First

Method Description:

   Find the first record in the DB for the current control (use) key,
   i.e. the record in the DB with the smallest key value.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT Last(void);

/*++

Method Name:

    Last

Method Description:

   Find the last record in the DB for the current control (use) key,
   i.e. the record in the DB with the largest key value.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT MarkAsNew(void);

/*++

Method Name:

    MarkAsNew

Method Description:

   Mark the DB entity as new so that a subsequent Write will write
   it as a new DB record rather than replace an existing record.

Arguments:

    None.

Return Value:

    S_OK        - Success.

--*/


    HRESULT Next(void);

/*++

Method Name:

    Next

Method Description:

   Get the next record in the DB for the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT Previous(void);

/*++

Method Name:

    Previous

Method Description:

   Get the previous record in the DB for the current control (use) key.

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT Print([in] IStream* pStream);

/*++

Method Name:

    Print

Method Description:

   Write a human-readable description of the values in this entity to 
   a stream.

Arguments:

    pStream  - Pointer to the output stream.

Return Value:

    S_OK        - Success.

--*/

    HRESULT Remove(void);

/*++

Method Name:

    Remove

Method Description:

   Remove the current record (and its keys) from the DB.

Arguments:

    None.

Return Value:

    S_OK        - Success.

--*/

    HRESULT UpdateKey([in] IWsbDbKey *pKey);

/*++

Method Name:

    UpdateKey

Method Description:

   Sets the key from data fields.

Arguments:

    pKey - The key.

Return Value:

    S_OK        - Success.

--*/

    HRESULT UseKey([in] ULONG type);

/*++

Method Name:

    UseKey

Method Description:

   Sets the current control (use) key type for search functions.

Arguments:

    type - The key type.

Return Value:

    S_OK        - Success.

--*/

    HRESULT Write(void);

/*++

Method Name:

    Write

Method Description:

   Write the data to the DB.  If MarkAsNew() was called, then the data
   is saved as a new DB record otherwise it replaces the current DB record.

   If an existing record is being replaced, i.e. MarkAsNew() was not called,
   this method assumes that none of the fields used as keys has been changed.
   If it is necessary to change a key, then the original record should be
   removed (via Remove()) and the replacement record rewritten as new.

Arguments:

    None.

Return Value:

    S_OK        - Success.

--*/

    HRESULT SetSequentialScan(void);

/*++

Method Name:

    SetSequentialScan

Method Description:

   Sets the corresponding table to sequential scanning for huge performnace gain.
   Should be used if a large table is going to be scanned sequentially, for example, with First() and Next()

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

    HRESULT ResetSequentialScan(void);

/*++

Method Name:

    ResetSequentialScan

Method Description:

   Resets a sequential-scanning flag on the corresponding table
   Should be used if a table was set with the flag and is going to be random-accessed now

Arguments:

    None

Return Value:

    S_OK        - Success.

--*/

};



[
    object,
    uuid(EF5207D0-8C0B-11d0-9E39-00A0C916F120),
    helpstring("IWsbCreateLocalObject Interface"),
    pointer_default(unique)
]
interface IWsbCreateLocalObject : IUnknown
{
    HRESULT CreateInstance( [in] REFCLSID rclsid, [in] REFIID riid, [out, iid_is(riid)] void** ppv );
};

[
    object,
    uuid(0AF2DA10-7DD7-11d0-9E33-00A0C916F120),
    helpstring("IWsbTrace Interface"),
    pointer_default(unique)
]
interface IWsbTrace : IUnknown
{
    HRESULT StartTrace( void );
    HRESULT StopTrace( void );
    HRESULT SetTraceOn(  [in]   LONGLONG traceElement );
    HRESULT SetTraceOff( [in]   LONGLONG traceElement );
    HRESULT GetTraceSettings( [out] LONGLONG *pTraceElements );
    HRESULT GetTraceSetting( [in]  LONGLONG traceElement, [out] BOOL *pOn );
    HRESULT DirectOutput( [in] ULONG output );
    HRESULT SetOutputFormat( [in] BOOL timeStamp, [in] BOOL traceCount, [in] BOOL traceThreadId );
    HRESULT GetOutputFormat( [out] BOOL *pTimeStamp, [out] BOOL *pTraceCount, [out] BOOL *pTraceThreadId );
    HRESULT SetTraceFileControls( [in, string] OLECHAR *traceFileName, [in] BOOL commitEachEntry, [in] LONGLONG maxTraceFileSize, [in, string] OLECHAR *traceFileCopyName );
    HRESULT GetTraceFileControls( [out, string] OLECHAR **traceFileName, [out] BOOL *pCommitEachEntry, [out] LONGLONG *pMaxTraceFileSize, [out, string] OLECHAR **traceFileCopyName );
    HRESULT SetTraceEntryExit ( [in] BOOL traceEntryExit );
    HRESULT GetTraceEntryExit ( [out] BOOL *pTraceEntryExit );
    HRESULT SetLogLevel ( [in] WORD traceError );
    HRESULT GetLogLevel ( [out] WORD *pTraceError );
    HRESULT Print( [in, string] OLECHAR *traceString );
    HRESULT GetRegistryEntry( [out, string]  OLECHAR **pRegistryEntry );
    HRESULT SetRegistryEntry( [in, string]  OLECHAR *pRegistryEntry );
    HRESULT LoadFromRegistry( void );
    HRESULT SetTraceSettings( [in] LONGLONG traceElements );
    HRESULT GetLogSnapShot( [out] BOOL *pOn, [out] WORD *pLevel, [out, string] OLECHAR **pSnapShotPath, [out] BOOL *pResetTrace);
    HRESULT SetLogSnapShot( [in] BOOL on, [in] WORD level, [in, string] OLECHAR *snapShotPath, [in] BOOL resetTrace);
};

// Beyond this point are private interfaces that should only
// be used within IDB implementation code
//

[
    object, local,
    uuid(8A2612A9-2466-470E-AD46-059318CE8C4E),
    helpstring("IWsbDbSysPriv Interface"),
    pointer_default(unique)
]
interface IWsbDbSysPriv : IUnknown
{
    HRESULT IncrementChangeCount(void);
    HRESULT DbAttachedAdd([in, string] OLECHAR* name, [in] BOOL attach);
    HRESULT DbAttachedEmptySlot(void);
    HRESULT DbAttachedInit(void);
    HRESULT DbAttachedRemove([in, string] OLECHAR* name);
};

[
    object, local,
    uuid(5FD6B1D1-6A43-11D0-9905-00A0C9058BF6),
    helpstring("IWsbDbPriv Interface"),
    pointer_default(unique)
]
interface IWsbDbPriv : IUnknown
{
    HRESULT GetJetIds([in] ULONG_PTR SessionID, [in] ULONG RecType,
                [out] ULONG_PTR* pTableId, [out] ULONG* pDataColId);
    HRESULT GetJetIndexInfo([in] ULONG_PTR SessionId, [in] ULONG RecType, [in] ULONG KeyType, [out] ULONG* pColId,
                [in, out, string] OLECHAR** pName, [in] ULONG bufferSize);
    HRESULT GetNewSQN([in] ULONG RecType, [out] ULONG* pSeqNum);
    HRESULT GetKeyInfo([in] ULONG RecType, [in] USHORT nKeys,
            [out, size_is(nKeys)] COM_IDB_KEY_INFO* pKeyInfo);
    HRESULT GetRecInfo([in] ULONG RecType, [out] COM_IDB_REC_INFO* pRecInfo); 
    HRESULT Lock(void);
    HRESULT Unlock(void);
};


[
    object, local,
    uuid(C8DA1798-A48C-458C-B597-F497AB046A38),
    helpstring("IWsbDbSessionPriv Interface"),
    pointer_default(unique)
]
interface IWsbDbSessionPriv : IUnknown
{
    HRESULT Init([in] ULONG_PTR* pInstance);
    HRESULT GetJetId([out] ULONG_PTR* pSessionId);
};


[
    object, local,
    uuid(5FD6B1D4-6A43-11D0-9905-00A0C9058BF6),
    helpstring("IWsbDbKeyPriv Interface"),
    pointer_default(unique)
]
interface IWsbDbKeyPriv : IUnknown
{
    HRESULT GetBytes([out] UCHAR** ppBytes, [out] ULONG* pSize);
    HRESULT SetType([in] ULONG type);
};


[
    object, local,
    uuid(F16476FD-BF20-442A-84EB-5CEA9462E81D),
    helpstring("IWsbDbEntityPriv Interface"),
    pointer_default(unique)
]
interface IWsbDbEntityPriv : IUnknown
{
    HRESULT Copy([in] IWsbDbEntity* pEntity);
    HRESULT CopyValues([in] ULONG flags, [in] IWsbDbEntity* pEntity);
    HRESULT GetCurKey([out] IWsbDbKey** ppKey);
    HRESULT GetKey([in] ULONG KeyType, [out] IWsbDbKey** ppKey);
    HRESULT GetValue([in] ULONG flag, [out] ULONG* pValue);
    HRESULT Init([in] IWsbDb* pDb, [in] IWsbDbSys* pDbSys, [in] ULONG RecType, [in] ULONG_PTR SessionId);
    HRESULT SetValue([in] ULONG flag, [in] ULONG value);
};

[
    object,
	uuid(58A4F966-55BE-4D62-892E-43A9978BF4C2),
    helpstring("IWsbServer Interface"),
    pointer_default(unique)
]
interface IWsbServer : IUnknown
{
    HRESULT GetDbPathAndName([out, string] OLECHAR **pDbPathAndName, [in] ULONG bufferSize);
    HRESULT GetId([out] GUID *pId);
    HRESULT GetRegistryName([out, string] OLECHAR **pRegistryName, [in] ULONG bufferSize);
    HRESULT GetBuildVersion( [out] ULONG *pBuildVersion );
    HRESULT GetNtProductVersion( [out, string] OLECHAR **pNtProductVersion, [in] ULONG bufferSize );
    HRESULT GetNtProductBuild( [out] ULONG *pNtProductBuild );
    HRESULT GetDatabaseVersion( [out] ULONG *pDatabaseVersion );
    HRESULT SaveAll(void);
    HRESULT SetId([in]  GUID   id );
    HRESULT DestroyObject(void);
    HRESULT Unload(void);

/*++

Method Name:

       Unload

Method Description:

    Undo what a Load of a persistence file may have set or created (before 
    retrying the load on a backup persistence file).

Arguments:

    None.

Return Value:

    S_OK        - Success
--*/

    HRESULT CheckAccess( [in] WSB_ACCESS_TYPE AccessType );

/*++

Method Name:

       CheckAccess

Method Description:

    Check access.

Arguments:

    AccessType - Type of access to check for

Return Value:

    S_OK            - Permissions OK
    E_ACCESSDENIED  - Permissions denied
    
--*/

    HRESULT GetTrace( [out] IWsbTrace ** ppTrace );

/*++

Method Name:

       GetTrace

Method Description:

    Retrieves the object in the service that is used to control
    trace settings.

Arguments:

    ppTrace - returned IWsbTrace pointer

Return Value:

    S_OK            - Permissions OK
    E_*             - Error occurred.
    
--*/


    HRESULT SetTrace( [in] IWsbTrace * pTrace );

/*++

Method Name:

       SetTrace

Method Description:

    Set the object in that is used to control trace settings.

Arguments:

    pTrace - given IWsbTrace pointer

Return Value:

    S_OK            - Everything OK
    E_*             - Error occurred.
    
--*/

};

[
    object,
    uuid(3F0DA041-69F1-11d2-AF82-00104B9A3758),
    helpstring("IHsmSystemState Interface"),
    pointer_default(unique)
]
interface IHsmSystemState : IUnknown
{
    HRESULT ChangeSysState([in, out] HSM_SYSTEM_STATE* pSysState);

/*++

Method Name:

       ChangeSysState

Method Description:

    Requests a state change event of an object.

Arguments:

    pSysState - Pointer to a HSM_SYSTEM_STATE structure that includes
            flags indicating the type of request.

Return Value:

    S_OK            - Event was handled OK.
    S_FALSE         - Event was rejected.
    E_*             - Error occurred.
    
--*/
};

//------------------------------------------------------------------------
//
//                             IHsmEvent
//
//------------------------------------------------------------------------

[
    object,
    uuid(621EFF31-B2E2-11d1-B9A6-00A0C9190447),
    helpstring("IHsmEvent Interface"),
    pointer_default(unique)
]
interface IHsmEvent : IUnknown
{
    HRESULT OnStateChange               ( void );
};
