//*****************************************************************************
// CompLib.idl
//
// Interface definitions.
//
// Copyright (c) 1996-1997, Microsoft Corp.  All rights reserved.
//*****************************************************************************


import "objidl.idl";


//*****************************************************************************
// This is a bogus interface to collect OLE/DB struct definitions.  This is
// a copy of the real OLE/DB stuff which isn't public.
//*****************************************************************************
cpp_quote("// If you have problems using the full OLE/DB interfaces in your code,")
cpp_quote("// you need to include \"oledb.h\" before this file.")
[
	uuid(A7A3F9B1-6F26-11d0-B7B0-00A0C90FEE73),
    pointer_default(unique)
]
interface DBStructureDefinitions
{
	//
	//	A DBID is the way a particular column is identified.
	//	It consists of a GUID followed by either a LONG or a Unicode
	//	string.
	//

	typedef DWORD DBKIND;

	enum DBKINDENUM {
		DBKIND_GUID_NAME,
		DBKIND_GUID_PROPID,
		DBKIND_NAME,
		DBKIND_PGUID_NAME,
		DBKIND_PGUID_PROPID,
		DBKIND_PROPID,
		DBKIND_GUID,
	};

	typedef struct tagDBID {
		[switch_type(DBKIND),switch_is(eKind)] union {
			[case(DBKIND_GUID_NAME, DBKIND_GUID_PROPID, DBKIND_GUID)] GUID guid;
			[case(DBKIND_PGUID_NAME, DBKIND_PGUID_PROPID)] GUID *pguid;
		} uGuid;
		DBKIND	eKind;
		[switch_type(DBKIND),switch_is(eKind)] union {
			[case(DBKIND_GUID_NAME, DBKIND_NAME, DBKIND_PGUID_NAME)] LPOLESTR pwszName;
			[case(DBKIND_GUID_PROPID, DBKIND_PGUID_PROPID, DBKIND_PROPID)] ULONG ulPropid;
		} uName;
	} DBID;
}


//*****************************************************************************
// This is a bogus interface to collect structure definitions we need.
//*****************************************************************************
[
	uuid(8D7E63C0-6F2D-11d0-B7B0-00A0C90FEE73),
    pointer_default(unique)
]
interface TiggerStructureDefinitions
{
	typedef long OID4;
	typedef short OID2;
	typedef long OID;
	typedef OID * REFOID;
	typedef OID KLSID;
	typedef INT_PTR TABLEID;
	typedef unsigned long COMPLIBID;

	//@todo: check with OLE DB spec to see how you are allowed to describe new types.
	enum EXTENDEDDBTYPES
	{
		DBTYPE_OID				= 300,
		DBTYPE_INT				= 301,
		DBTYPE_UTF8				= 302
	};

	//@todo: make these format parameters, and allocate a buffer for 
	// any copies.s
	typedef struct _tagFKRELSHIP
	{
		LPCWSTR		szFKTable;
		LPCWSTR		szFKColumn;
		LPCWSTR		szOidColumn;
		LPCWSTR		szSeqColumn;
		int			iTypes;
		[size_is(iTypes)] const KLSID *rgKlsid;
	} FKRELSHIP;

	
	typedef struct _tagCLBMEMOPEN
	{
		BYTE		*pbData;
		ULONG		cbData;
	} CLBMEMOPEN;

//*****************************************************************************
// These structures are used to describe user defined schemas that can be hard
// code at development time and used with the complib engine. 
//	COMPLIBSCHEMASTG	- Saved to disk to track schema references
//	COMPLIBSCHEMA		- Used at run-time to refer to a schema by id.
//	COMPLIBSCHEMABLOB	- Contains ID and actual schema definition values. 
//	COMPLIBSCHEMADESC	- Used for ICRSchema to reflect on contents.
//*****************************************************************************

	typedef struct _tagCOMPLIBSCHEMASTG
	{
		GUID		sid;			// ID of the schema.
		ULONG		Version;		// Version number of the schema.
	} COMPLIBSCHEMASTG;

	typedef struct _tagCOMPLIBSCHEMA
	{
		const GUID	*psid;			// ID of the schema.
		ULONG		Version;		// Version number of the schema.
	} COMPLIBSCHEMA;

	typedef struct _tagCOMPLIBSCHEMABLOB
	{
		const COMPLIBSCHEMA *pSchemaID; // What schema version.
		USHORT 		iTables;		// How many tables in the schema.
		USHORT		fFlags;			// Flags about the schema.
		const BYTE	*pbReadWrite;	// Read write schema blob.
		ULONG		cbReadWrite;	// Size of read/write schema.
		const BYTE	*pbReadOnly;	// Read only schema blob.
		ULONG		cbReadOnly;		// Size of read only schema.
		const BYTE	*pbNames;		// Name heap.
		ULONG		cbNames;		// Size of name heap.
	} COMPLIBSCHEMABLOB;

	typedef struct _tagCOMPLIBSCHEMADESC
	{
		GUID		sid;			// ID of the schema.
		ULONG		Version;		// Version number of the schema.
		USHORT		iTables;		// How many tables are in this schema.
	} COMPLIBSCHEMADESC;

	enum MISCDBVALS
	{
		OID_INTERNAL			= 99,
		INAVLID_TABLEID			= 0xffffffff
	};
	
#define DISPID_VALUE    0
#define DISPID_NEWENUM  -4

cpp_quote(" ")
cpp_quote("// The GUIDs below are useful for direct OLE DB access only.  Link with")
cpp_quote("// mscorclb.lib for Component Dictionary linkage.")
cpp_quote("#ifndef GUID_SPEC")
cpp_quote("#	ifdef UNDER_CE")
cpp_quote("#		define GUID_SPEC(g) extern const GUID g")
cpp_quote("#	else")
cpp_quote("#		if _MSC_VER >= 1100")
cpp_quote("#			define GUID_SPEC(g) extern const GUID __declspec(selectany) g")
cpp_quote("#		else")
cpp_quote("#			define GUID_SPEC(g) EXTERN_C const GUID __based(__segname(\"_CODE\")) g")
cpp_quote("#		endif")
cpp_quote("#	endif")
cpp_quote("#endif")
cpp_quote(" ")

cpp_quote("#ifdef DBINITCONSTANTS")
cpp_quote("#ifndef __TIGGER_PROP_SETS_ONLY__")
cpp_quote("GUID_SPEC(CLSID_DataSource) = {0x0C1D21E6,0x6B16,0x11D0,{0xB7,0xA9,0x00,0xA0,0xC9,0x0F,0xEE,0x73}};")
cpp_quote("GUID_SPEC(IID_IDBSessionSave) = { 0x927d0a3d, 0xf23a, 0x11d0, { 0xad, 0x32, 0x0, 0xc0, 0x4f, 0xc3, 0x24, 0x80 } };")
cpp_quote("GUID_SPEC(IID_IPluggableSchema) = {0xD6790DA0,0xD57B,0x11d1,{0x8F,0x61,0x00,0x60,0x97,0xE4,0x8F,0x10} };")
cpp_quote("#endif")
cpp_quote("GUID_SPEC(DBPROPSET_TIGGER) = { 0xe0444ece, 0x7e1d, 0x11d0, { 0xad, 0x16, 0x0, 0xc0, 0x4f, 0xc3, 0x24, 0x80 } };")
cpp_quote("GUID_SPEC(DBPROPSET_TIGGERCOL) = { 0xe26eee1f, 0xb2ae, 0x11d0, { 0xad, 0x23, 0x0, 0xc0, 0x4f, 0xc3, 0x24, 0x80 } };")
cpp_quote("GUID_SPEC(CLCUSTDATA_LIBSTATS) = { 0x2be796ca, 0xe1eb, 0x11d0, { 0x8c, 0x72, 0x0, 0xc0, 0x4f, 0xc3, 0x1d, 0xf8 } };")
cpp_quote("GUID_SPEC(SCHEMA_Temp) = { 0xb8395301, 0x6f5e, 0x11d1, { 0x9f, 0x27, 0x10, 0x34, 0x90, 0x0, 0x0, 0x0 } };")
cpp_quote("GUID_SPEC(SCHEMA_User) = { 0xb8395302, 0x6f5e, 0x11d1, { 0x9f, 0x27, 0x10, 0x34, 0x90, 0x0, 0x0, 0x0 } };")
cpp_quote("GUID_SPEC(SCHEMA_SymbolTable) = { 0xb8395303, 0x6f5e, 0x11d1, { 0x9f, 0x27, 0x10, 0x34, 0x90, 0x0, 0x0, 0x0 } };")
cpp_quote("GUID_SPEC(DBSCHEMA_COMPLIBSCHEMAS) = { 0x179cb634, 0xd4c3, 0x11d1, { 0x8f, 0x5f, 0x0, 0x60, 0x97, 0xe4, 0x8f, 0x10 } };")
cpp_quote("#else")
cpp_quote("EXTERN_C const GUID CLSID_DataSource;")
cpp_quote("EXTERN_C const GUID IID_IDBSessionSave;")
cpp_quote("EXTERN_C const GUID DBPROPSET_TIGGER;")
cpp_quote("EXTERN_C const GUID DBPROPSET_TIGGERCOL;")
cpp_quote("EXTERN_C const GUID CLCUSTDATA_LIBSTATS;")
cpp_quote("EXTERN_C const GUID SCHEMA_Temp;")
cpp_quote("EXTERN_C const GUID SCHEMA_User;")
cpp_quote("EXTERN_C const GUID SCHEMA_SymbolTable;")
cpp_quote("EXTERN_C const GUID DBSCHEMA_COMPLIBSCHEMAS;")
cpp_quote("EXTERN_C const GUID IID_IPluggableSchema;")
cpp_quote("#endif")
cpp_quote(" ")



cpp_quote("//******************************************************************")
cpp_quote("// Property set values for sessions.")
cpp_quote("//******************************************************************")
	enum DBPROPTIGGER
	{
		DBPROP_TIGGER_MODE,
		DBPROP_TIGGER_MEMOPEN
	};

	enum DBPROPMODE
	{
		DBPROP_TMODEF_READ					= 0x00000001,
		DBPROP_TMODEF_WRITE					= 0x00000002,
		DBPROP_TMODEF_EXCLUSIVE				= 0x00000004,
		DBPROP_TMODEF_CREATE				= 0x00000010,
		DBPROP_TMODEF_FAILIFTHERE			= 0x00000020,
		DBPROP_TMODEF_SLOWSAVE				= 0x00000100,
		DBPROP_TMODEF_NOTXNBACKUPFILE		= 0x00000200,
		DBPROP_TMODEF_COMPLUS				= 0x00001000,
		DBPROP_TMODEF_SMEMCREATE			= 0x00002000,
		DBPROP_TMODEF_SMEMOPEN				= 0x00004000,
		DBPROP_TMODEF_DFTWRITEMASK			= 0x00000113,
		DBPROP_TMODEF_DFTREADWRITEMASK		= 0x00000103,
		DBPROP_TMODEF_ALIGNBLOBS			= 0x00010000,
		DBPROP_TMODEF_BACKUP_SEMANTICS		= 0x00020000,
		DBPROP_TMODEF_RESERVED				= 0x80000000
	};

	enum CLBFORMAT
	{
		CLBFORMAT_UNKNOWN,
		CLBFORMAT_NATIVE,
		CLBFORMAT_CLASS
	};


cpp_quote("//******************************************************************")
cpp_quote("// Property set values for new tables.")
cpp_quote("//******************************************************************")
	enum
	{
		DBPROP_TIGGER_DROPIFEMPTY,
		DBPROP_TIGGER_RECORDIDSTART
	};


cpp_quote("//******************************************************************")
cpp_quote("// Property set values for columns.")
cpp_quote("//******************************************************************")
	enum
	{
		DBPROP_TIGGER_COLRECORDID
	};

cpp_quote("//******************************************************************")
cpp_quote("// Property set values for new indexes.")
cpp_quote("//******************************************************************")
	enum
	{
		DBPROP_TIGGER_INDEXROWTHRESHOLD,
		DBPROP_TIGGER_INDEXMAXCOLLISIONS,
		DBPROP_TIGGER_INDEXDEFERBUILD
	};

// Constants...                              
enum CL_MODE
{
	CL_MODE_READ									 = DBPROP_TMODEF_READ,
	CL_MODE_READWRITE								 = DBPROP_TMODEF_WRITE|DBPROP_TMODEF_EXCLUSIVE,
	CL_MODE_FAILIFTHERE								 = DBPROP_TMODEF_FAILIFTHERE
};

enum CL_LIBFLAGS                             
{                                            
    CL_LIBFLAGS_IsControl   				         = 0x0001,
};                                           

enum CL_ACCESSFLAGS                          
{                                            
    CL_ACCESSFLAGS_IsHidden   				         = 0x0001,
    CL_ACCESSFLAGS_IsRestricted   			         = 0x0002,

    CL_ACCESSFLAGS_ALL			   			         = 0x0003,
};                                           

enum CL_MEMBERFLAGS                          
{                                            
    CL_MEMBERFLAGS_IsUIDefault   			         = 0x4000,
    CL_MEMBERFLAGS_IsReplaceable   			         = 0x2000,
    CL_MEMBERFLAGS_IsSource   				         = 0x1000,

    CL_MEMBERFLAGS_ALL		   				         = 0x7000,
};                                           

enum CL_ARRAYFLAGS                           
{                                            
    CL_ARRAYFLAGS_TreatAsString   			         = 0x0001,
};                                           

enum CL_FIELDUSAGEFLAGS                      
{                                            
    CL_FIELDUSAGEFLAGS_IsIn   				         = 0x0001,
    CL_FIELDUSAGEFLAGS_IsOut   				         = 0x0002,
    CL_FIELDUSAGEFLAGS_Ignore   			         = 0x0004,
};                                           

enum CL_UNIONMEMFLAGS                        
{                                            
    CL_UNIONMEMFLAGS_IsDefault   			         = 0x0001,
};                                           

enum CL_FUNCFLAGS                            
{                                            
    CL_FUNCFLAGS_IsVarArg   				         = 0x0001,
    CL_FUNCFLAGS_IsIdempotent   			         = 0x0002,

	CL_FUNCFLAGS_DispProp							 = 0x4000,
};                                           

enum CL_INTERFACEFLAGS                       
{                                            
    CL_INTERFACEFLAGS_IsAutomationCompatible         = 0x0001,
    CL_INTERFACEFLAGS_IsDual   				         = 0x0002,
    CL_INTERFACEFLAGS_IsExtensible   		         = 0x0004,

    CL_INTERFACEFLAGS_DispInterface   		         = 0x4000,
};                                           

enum CL_ENTRYPTFLAGS                         
{                                            
    CL_ENTRYPTFLAGS_UsesGetLastError   		         = 0x0001,
};                                           

enum  CL_PARAMFLAGS                          
{                                            
    CL_PARAMFLAGS_IsIn   					         = 0x0001,
    CL_PARAMFLAGS_IsOut   					         = 0x0002,
    CL_PARAMFLAGS_IsOptional   				         = 0x0004,
    CL_PARAMFLAGS_IsLocale   				         = 0x0008,
    CL_PARAMFLAGS_IsRetval   				         = 0x0010,
    CL_PARAMFLAGS_HasDefault   				         = 0x0020, //@todo: remove when Variants are nullable 
};                                           

enum CL_PROPFLAGS                            
{                                            
    CL_PROPFLAGS_IsReadOnly   				         = 0x0001,
    CL_PROPFLAGS_IsBindable   				         = 0x0002,
    CL_PROPFLAGS_IsDisplayBind   			         = 0x0004,
    CL_PROPFLAGS_SupportsOnRequestEdit   	         = 0x0008,
    CL_PROPFLAGS_IsDefaultBind   			         = 0x0010,
    CL_PROPFLAGS_IsDefaultCollElem   		         = 0x0020,
    CL_PROPFLAGS_SupportsImmediateBind   	         = 0x0040,
    CL_PROPFLAGS_IsBrowsable   				         = 0x0080,

	CL_PROPFLAGS_DispProp							 = 0x4000,
};                                           

enum CL_COCLASSFLAGS                         
{                                            
    CL_COCLASSFLAGS_IsInterfaceSetOpen   	         = 0x0001,
    CL_COCLASSFLAGS_IsAppObject   			         = 0x0002,
    CL_COCLASSFLAGS_IsIndependentlyCreateable        = 0x0004,
    CL_COCLASSFLAGS_IsPredefined			         = 0x0008,
    CL_COCLASSFLAGS_SupportsDeferredCreate           = 0x0010,
};                                           

enum CL_CLASSCATFLAGS                        
{                                            
    CL_CLASSCATFLAGS_IsLicensed   			         = 0x0001,
    CL_CLASSCATFLAGS_IsControl   			         = 0x0002,
    CL_CLASSCATFLAGS_IsAggregatable   		         = 0x0004,
};                                           

enum CL_IMPLFLAGS                            
{                                            
    CL_IMPLFLAGS_IsRestricted   			         = 0x0001,
    CL_IMPLFLAGS_IsAlwaysSupported   		         = 0x0002,
    CL_IMPLFLAGS_IsSource   				         = 0x0004,
    CL_IMPLFLAGS_IsDefault   				         = 0x0008,
    CL_IMPLFLAGS_IsDefaultVTBLSource   		         = 0x0010,
};                                           


}

cpp_quote("#if defined(__cplusplus)")

cpp_quote("#ifndef _REFOID_DEFINED")
cpp_quote("#define _REFOID_DEFINED")
cpp_quote("#define REFOID              const OID &")
cpp_quote("#endif // !_REFOID_DEFINED")

cpp_quote("#else // !__cplusplus")

cpp_quote("#ifndef _REFOID_DEFINED")
cpp_quote("#define _REFOID_DEFINED")
cpp_quote("#define REFOID              const OID * const")
cpp_quote("#endif // !_REFOID_DEFINED")

cpp_quote("#endif // !__cplusplus")





//*****************************************************************************
// Interface for page dump code to produce proper output.
//*****************************************************************************
[
	object,
	uuid(00EC6260-7D54-11d0-9E9E-585873000000),
	pointer_default(unique)
]
interface IOutScreen : IUnknown
{
	import "oaidl.idl";
	import "ocidl.idl";

	HRESULT PrintLine(
		[in] LPCWSTR	szLine);
};

//*****************************************************************************
// Interface IPluggableSchema to allow oledb consumers to add/delete complib schemas
//*****************************************************************************
[
	object,
	uuid(D6790DA0-D57B-11d1-8F61-006097E48F10),
	pointer_default(unique)
]
interface IPluggableSchema : IUnknown
{
	HRESULT Add(
		[in] const COMPLIBSCHEMABLOB *pSchema);
	HRESULT Delete(
		[in] const COMPLIBSCHEMABLOB *pSchema);

};


// Forwards...

//*****************************************************************************
// 
//*****************************************************************************
[
	uuid(BBD3EA61-551C-11D0-B78D-00A0C90FEE73),
	version(1.0),
	helpstring("CompLib 1.0 Type Library")
]
library METASTORELib
{
	importlib("stdole32.tlb");

	[
		uuid(EDA305FC-5796-11D0-B78F-00A0C90FEE73)
	]

	coclass MetaSession
	{
		[default] interface IUnknown;
		interface IPluggableSchema;
	};

	
	[
		uuid(EDA30600-5796-11D0-B78F-00A0C90FEE73)
	]
	coclass TableSet
	{
		[default] interface IUnknown;
	};

	
	[
		uuid(0C1D21E6-6B16-11D0-B7A9-00A0C90FEE73)
	]
	coclass DataSource
	{
		[default] interface IUnknown;
		interface IPersist;
	};

	
	[
		uuid(6343C431-6AD9-11d1-9F24-7200A4000000)
	]
	coclass ComplibSimpleTable
	{
		[default] interface IUnknown;
	};



#if 0
	module CompLib
	{
		[helpstring("Create a new ComponentLibrary"), entry(5)] 
		HRESULT __stdcall CreateComponentLibrary([in]LPCWSTR szName, [in]long fFlags, [out, retval]ICompLibrary **ppICompLibrary);
		[helpstring("Open an existing ComponentLibrary"), entry(6)] 
		HRESULT __stdcall OpenComponentLibrary([in]LPCWSTR szName, [in]long fFlags, [out, retval]ICompLibrary **ppICompLibrary);
		[helpstring("Open an existing ComponentLibrary on top of memory."), entry(7)] 
		HRESULT __stdcall OpenComponentLibraryOnMem([in]ULONG cbData, [in, size_is(cbData)]BYTE *pbData, [out, retval]ICompLibrary **ppICompLibrary);
	};
#endif
};


