IModelObject::Compare 方法 (dbgmodel.h)
Compare 方法比较两个模型对象,并返回这些对象之间的关系的指示。 返回三种状态之一:
< 0: (this < other)
== 0: (this == other)
> 0: (this > other)
请注意,只能使用此方法比较内部值。 使用任何其他对象类型进行调用将导致失败。
语法
HRESULT Compare(
IModelObject *other,
IModelObject **ppResult
);
参数
other
要与此对象进行比较的对象。 实例对象位于比较的左侧,此参数提供的对象位于右侧。
ppResult
此处返回比较结果。 如果小于零,则此 < 其他;如果等于零,则此 == 其他;如果大于零,则此 > 其他。
返回值
此方法返回指示成功或失败的 HRESULT。
言论
代码示例
ComPtr<IModelObject> spValue1; /* get some ordinal */
ComPtr<IModelObject> spValue2; /* get some other ordinal */
ComPtr<IModelObject> spResult;
if (SUCCEEDED(spValue1->Compare(spValue2.Get(), &spResult)))
{
VARIANT vtVal;
if (SUCCEEDED(spResult->GetIntrinsicValueAs(VT_I4, &vtVal)))
{
int compVal = vtVal.lVal;
// compVal < 0 : spValue1 < spValue2
// compVal == 0: spValue1 == spValue2
// compVal > 0 : spValue1 > spValue2
}
}
要求
要求 | 价值 |
---|---|
标头 | dbgmodel.h |