📄 ndrtypes.h
字号:
class NdrConfVarArray : public NdrConfArray { public: NdrConfVarArray (NDRTYPES& n) : NdrConfArray (n) {} TypeKind kind () const { return TK_CVARRAY; } size_t size (NdrUnmarshalStream*); HRESULT marshal1 (NdrMarshalStream* pStrm); };////////////////////////////////////////////////////////////////////////////// NdrConfStruct -- an NdrType subclass that represents a 'conformant// structure' at the IDL/C++ level, i.e. a structure whose final member// is a conformant array, and the length of this array is held in one // of the structures other members.//// To achieve this, the final member is treated as if it were a// fixed-size array, i.e. the WIDL-generated code should contain a// pointer to an NdrArray as the last member of the structure// definition, and it will be manipulated by the NdrConfStruct// marshaling routines so that it works correctly. When the conformant// structure is marshaled, the array-length is marshaled before the// structure itself.//class NdrConfStruct : public NdrStruct { public: NdrConfStruct (NDRTYPES& n) : NdrStruct (n) {} TypeKind kind () const { return TK_CSTRUCT; } size_t size (NdrUnmarshalStream*); HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); private: size_t confElemResize (); };////////////////////////////////////////////////////////////////////////////// NdrInterface -- an NdrType subclass that represents a COM interface// pointer at the 'C' or IDL level. The bind() method always takes the// address of the interface-pointer variable, whether marshaling or// unmarshaling.//class NdrInterface : public NdrType { public: NdrInterface (NDRTYPES& n) : NdrType (n), m_pPointer (0) {} void init (REFIID riid) { m_iid = riid; } TypeKind kind () const { return TK_INTERFACE; } void resize (size_t) {} size_t size (NdrUnmarshalStream*) { return sizeof (void*); } size_t alignment () const { return sizeof (void*); } long value () const { return 0; } void bind (void* pv); HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT marshal2 (NdrMarshalStream* pStrm); HRESULT unmarshal (NdrUnmarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); HRESULT unmarshal2 (NdrUnmarshalStream* pStrm); protected: IUnknown** m_pPointer; // address of interface-ptr IID m_iid; // IID of interface };////////////////////////////////////////////////////////////////////////////// NdrBSTR -- an NdrType subclass that represents a BSTR type...//class NdrBSTR : public NdrType { public: NdrBSTR (NDRTYPES& n) : NdrType (n), m_pBstr (0) {} TypeKind kind () const { return TK_BSTR; } void resize (size_t) {} size_t size (NdrUnmarshalStream*) { return sizeof (void*); } size_t alignment () const { return sizeof (void*); } long value () const { return 0; } void bind (void* pv) { m_pBstr = (BSTR*) pv; } HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT marshal2 (NdrMarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); HRESULT unmarshal2 (NdrUnmarshalStream* pStrm); protected: BSTR* m_pBstr; // ptr to BSTR variable };////////////////////////////////////////////////////////////////////////////// NdrVariant -- an NdrType subclass that represents a VARIANT type...//class NdrVariant : public NdrType { public: NdrVariant (NDRTYPES& n) : NdrType (n), m_pVariant (0) {} TypeKind kind () const { return TK_STRUCT; } void resize (size_t) {} size_t size (NdrUnmarshalStream*); size_t alignment () const { return sizeof (long); } long value () const { return 0; } void bind (void* pv) { m_pVariant = (VARIANT*) pv; } HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT marshal2 (NdrMarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); HRESULT unmarshal2 (NdrUnmarshalStream* pStrm); protected: VARIANT* m_pVariant; // ptr to VARIANT variable };////////////////////////////////////////////////////////////////////////////// NdrSafearray -- an NdrType subclass that represents a SAFEARRAY type...//class NdrSafearray : public NdrType { public: NdrSafearray (NDRTYPES& n); ~NdrSafearray (); TypeKind kind () const { return TK_STRUCT; } void resize (size_t) {} size_t size (NdrUnmarshalStream*) { return sizeof (ULONG); } size_t alignment () const { return sizeof (long); } long value () const { return 0; } void bind (void * pv); HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT marshal2 (NdrMarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); HRESULT unmarshal2 (NdrUnmarshalStream* pStrm); protected: VARIANT* m_pVariant; // ptr to VARIANT variable. This contains the // memory rep of the SAFEARRAY. private: enum { PHASE1 = 0, PHASE2 } m_phase; // used in unmarshalling pointer types. SAFEARRAY * m_pTag; // used to hold a list of the tags for // unmarshalling pointer types. HRESULT actionArray ( int dim, NdrMarshalStream * pMaStrm, NdrUnmarshalStream * pUnStrm, long * ix ); HRESULT marshalBody (NdrMarshalStream * pStrm, long * ix); HRESULT unmarshalBody (NdrUnmarshalStream * pStrm, long * ix); };////////////////////////////////////////////////////////////////////////////// NdrWString -- an NdrType subclass that represents a wide-string,// NULL-terminated...//class NdrWString : public NdrType { public: NdrWString (NDRTYPES& n) : NdrType (n), m_pString (0) {} TypeKind kind () const { return TK_PTR; } void resize (size_t) {} size_t size (NdrUnmarshalStream*); size_t alignment () const { return sizeof (long); } long value () const { return 0; } void bind (void* pv) { m_pString = (OLECHAR*) pv; } HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); protected: OLECHAR* m_pString; // ptr to string size_t m_max; // max length of string size_t m_offset; // offset of mshl data size_t m_len; // len of mshl data };////////////////////////////////////////////////////////////////////////////// NdrCString -- an NdrType subclass that represents a wide-string,// NULL-terminated...//class NdrCString : public NdrType { public: NdrCString (NDRTYPES& n) : NdrType (n), m_pString (0) {} TypeKind kind () const { return TK_PTR; } void resize (size_t) {} size_t size (NdrUnmarshalStream*); size_t alignment () const { return sizeof (long); } long value () const { return 0; } void bind (void* pv) { m_pString = (char*) pv; } HRESULT marshal1 (NdrMarshalStream* pStrm); HRESULT unmarshal1 (NdrUnmarshalStream* pStrm); protected: char* m_pString; // ptr to string size_t m_max; // max length of string size_t m_offset; // offset of mshl data size_t m_len; // len of mshl data };////////////////////////////////////////////////////////////////////////////// NdrTypeFactory -- serves up memory for instances of any of the// supported marshalable types, and records them so that they are// destroyed when this object is destroyed. It achieves this by// allocating the type elements from a private heap, which is// destroyed upon destruction of the object itself. It relies on the// class NdrType having a special placement-new operator which// allocates memory from this factory object's private heap.//class NdrTypeFactory { enum { TYPESIZE=32 }; public: NdrTypeFactory (int hint=256); ~NdrTypeFactory (); void* allocate (size_t); private: char* m_begin; char* m_curr; char* m_end; };#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -