开篇之作 关于c++中多个基类有相同的方法的解决办法
2006-11-08 16:55
381 查看
blog开了有很长时间了,但是一直没有写。刚刚完成一个项目,期间遇到一些技术细节,借此话题开博。
具体的环境是这样的:我要写一个不同文件格式的文本内容萃取的组件,并把萃取到的内容写入流(IOutputStream)。为此我实现几个标准的流的COM组件,包括标准内存流,标准文件流。这些组件都导出IInputStream和IOutputStream这2个接口,定义如下。不同于Microsoft的IStream接口,这2个接口他们的流指针是相互独立的,所以对于Seek的实现就出现了问题,因为为了保持一致性,所以就不能重命名Seek方法。一个对象中导出具有2个相同方法的接口,而且他们的方法作用分别不同,那么怎么实现才可以不出现二义现象?通过实现和分析,采取了如下的定义方式解决了这个问题,同时也保证了2个接口高度的一致性。
通过以下的示例,我们解决了这样的问题。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
示例:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class IInterface1
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Seek( ) = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class IInterface2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Seek() = 0 ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class Object : public IInterface1, public IInterface2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
HRESULT IInterface1::Seek()...{ return Interface1Seek();} //注意必须是内联的,否则会出现问题
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
HRESULT IInterface2::Seek()...{ return Interface2Seek();}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Interface1Seek();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Interface2Seek();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
mport "oaidl.idl";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import "ocidl.idl";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import "unknwn.idl";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
typedef
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
v1_enum
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
enum
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_BEGIN = 0,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_CUR,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_END
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}START_POS;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
object,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
local,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
uuid(9B679759-51E8-4b67-84AD-CBFEB8FE5FA3),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
helpstring("IBaseStream Interface"),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pointer_default( unique )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
interface IBaseStream : IUnknown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:设置流的大小,如果流已经存在并长度为oldsize,那么新的流将被复制已有的流的min( oldsize, newsize )个字节
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
同时设置相应的流的指针,到最靠近他们的大小
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK成功, 或者一个错误的HRESULT返回
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT SetSize( [in] long newSize );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:废弃已写入的内容
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,否则表示失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Discard( );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
从指定的位置平移offset个字节,并返回新的位置
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,STG_E_INVALIDPOINTER表示newpos是无效的指针, STG_E_INVALIDFUNCTION表示eStartPos是无效的值
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_E_SEEK_OFFSET_OVER表示offset太大,以至超过了流的空间
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Seek( [in] long offset, [in] START_POS eStartPos, [out,retval]long *newpos );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
取得流的大小
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,否则表示失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT GetStreamSize( [out,retval] long *size );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
取得流中数据的数量
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,否则表示失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT GetDataBytes( [out,retval] long *len );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
object,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
local,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
uuid(5B4CBCCD-0683-43e1-A8CB-FF8A7B8D142A),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
helpstring("IInputStream Interface"),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pointer_default( unique )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
interface IInputStream : IBaseStream
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:从流中读取数据,并返回实际读去的数量
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Read( [in,out]long *len, [out] byte *szBuffer );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//输出流
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
object,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
local,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
uuid(80FD37A0-BD90-434a-8EDC-30B9B3252FA6),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pointer_default( unique )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
interface IOutputStream : IBaseStream
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:写入字节到流中
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,E_POINTER表示传入的指针有错, E_INVALIDARG表示参数值有错
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_E_NO_SPACE表示流没有多余的空间
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_E_OUT_OF_MEMORY分配内存失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Write( [in]const byte *bStream, [in,out] long *size );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
具体的环境是这样的:我要写一个不同文件格式的文本内容萃取的组件,并把萃取到的内容写入流(IOutputStream)。为此我实现几个标准的流的COM组件,包括标准内存流,标准文件流。这些组件都导出IInputStream和IOutputStream这2个接口,定义如下。不同于Microsoft的IStream接口,这2个接口他们的流指针是相互独立的,所以对于Seek的实现就出现了问题,因为为了保持一致性,所以就不能重命名Seek方法。一个对象中导出具有2个相同方法的接口,而且他们的方法作用分别不同,那么怎么实现才可以不出现二义现象?通过实现和分析,采取了如下的定义方式解决了这个问题,同时也保证了2个接口高度的一致性。
通过以下的示例,我们解决了这样的问题。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
示例:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class IInterface1
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Seek( ) = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class IInterface2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Seek() = 0 ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class Object : public IInterface1, public IInterface2
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
HRESULT IInterface1::Seek()...{ return Interface1Seek();} //注意必须是内联的,否则会出现问题
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
HRESULT IInterface2::Seek()...{ return Interface2Seek();}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Interface1Seek();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Interface2Seek();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
mport "oaidl.idl";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import "ocidl.idl";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
import "unknwn.idl";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
typedef
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
v1_enum
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
enum
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_BEGIN = 0,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_CUR,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_END
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}START_POS;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
object,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
local,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
uuid(9B679759-51E8-4b67-84AD-CBFEB8FE5FA3),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
helpstring("IBaseStream Interface"),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pointer_default( unique )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
interface IBaseStream : IUnknown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:设置流的大小,如果流已经存在并长度为oldsize,那么新的流将被复制已有的流的min( oldsize, newsize )个字节
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
同时设置相应的流的指针,到最靠近他们的大小
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK成功, 或者一个错误的HRESULT返回
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT SetSize( [in] long newSize );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:废弃已写入的内容
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,否则表示失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Discard( );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
从指定的位置平移offset个字节,并返回新的位置
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,STG_E_INVALIDPOINTER表示newpos是无效的指针, STG_E_INVALIDFUNCTION表示eStartPos是无效的值
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_E_SEEK_OFFSET_OVER表示offset太大,以至超过了流的空间
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Seek( [in] long offset, [in] START_POS eStartPos, [out,retval]long *newpos );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
取得流的大小
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,否则表示失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT GetStreamSize( [out,retval] long *size );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
取得流中数据的数量
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,否则表示失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT GetDataBytes( [out,retval] long *len );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
object,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
local,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
uuid(5B4CBCCD-0683-43e1-A8CB-FF8A7B8D142A),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
helpstring("IInputStream Interface"),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pointer_default( unique )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
interface IInputStream : IBaseStream
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:从流中读取数据,并返回实际读去的数量
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Read( [in,out]long *len, [out] byte *szBuffer );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//输出流
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
object,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
local,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
uuid(80FD37A0-BD90-434a-8EDC-30B9B3252FA6),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
pointer_default( unique )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
interface IOutputStream : IBaseStream
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@short:写入字节到流中
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
@return:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
S_OK表示成功,E_POINTER表示传入的指针有错, E_INVALIDARG表示参数值有错
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_E_NO_SPACE表示流没有多余的空间
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
STREAM_E_OUT_OF_MEMORY分配内存失败
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HRESULT Write( [in]const byte *bStream, [in,out] long *size );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 关于开发JNI时编写C++找不到to_string()方法的解决办法
- 关于request.getRealPath("") 方法已过时的解决办法
- 关于下拉框option在IE下jquery方法hide()无效的解决办法
- 关于微信小程序使用不了push()方法的解决办法
- C++中同一类中参数名和变量名相同时出错,解决办法有两种
- c++中关于设置左对齐和右对齐的问题解决方法
- 关于 QtCreartor编写纯C++程序调用不到C++某些标准库和枚举以及运行错误 的解决方法
- C++与C函数的相互调用方法以及error C2732:链接规范与"f"的早期规范冲突的解决办法
- 关于C++ 里使用Openmp并行之cout混乱输出的解决方法
- C++之map插入数据相同的key不能覆盖value解决办法
- 【软件技巧】关于mindmanager 2012安装后报C++错误的解决方法
- 关于Spring JdbcTemplate调用queryForObject()方法结果集为空时报异常的解决办法
- 关于mindmanager 2012安装后报C++错误的解决方法
- 关于C++为类增加标识符和对象DBID的解决方法
- 关于sharepoint2013的SPUtility.GetGenericSetupPath()方法过期解决办法
- 关于c++6.0在电脑上打不开解决方法:
- 关于CCArmature加载时因为plist中含有相同名称的图片导致碰撞框被冲掉的解决办法。
- 关于tableView的cellForRowAtIndexPath方法不走的一个解决办法
- 关于C++/C中防止头文件的重复包含的解决办法
- 关于C++/C中防止头文件的重复包含的解决办法 (转)