📄 compare.cpp
字号:
/* Sep 25 1995 282U */
/* Sep 25 1995 GARDINER added assignment, comparison and conversion operators */
/*****************************************************************************
File: compare.C
Contents: Functions to implement the comparison operators for ASN.1 objects.
System: ASN development.
Created:
Author: Charles W. Gardiner <gardiner@bbn.com>
Remarks:
COPYRIGHT 1995 BBN Systems and Technologies, A Division of Bolt Beranek and
Newman Inc.
150 CambridgePark Drive
Cambridge, Ma. 02140
617-873-4000
*****************************************************************************/
#ifndef lint
const char compare_rcsid[]="$Header: /nfs/sub-rosa/u2/IOS_Project/ASN/Dev/rcs/lib/asn_obj/compare.C,v 1.2 1995/09/25 22:15:25 gardiner Exp $";
const char compare_sfcsid[] = "@(#)compare.C 282P";
#endif
#include "includes.h"
#include "asn_obj.h"
int AsnObj::operator!=(const AsnObj & robj) const
{
const AsnObj *robjp = &robj;
if (_type != robj._type || (_flags & (ASN_OF_FLAG | ASN_POINTER_FLAG)) !=
(robj._flags & (ASN_OF_FLAG | ASN_POINTER_FLAG))) return -1;
if ((_flags & ASN_POINTER_FLAG))
return ((*(AsnPtr *)this) != (*(AsnPtr *)robjp));
if ((_flags & ASN_FILLED_FLAG) != (robj._flags & ASN_FILLED_FLAG)) return 1;
if (!(_flags & ASN_FILLED_FLAG)) return 0;
if (_type == ASN_CHOICE)
return ((*(AsnChoice *)this) != (*(AsnChoice *)robjp));
if ((_type & ASN_CONSTRUCTED))
return ((*(AsnSequence *)this) != (*(AsnSequence *)robjp));
if ((_valp == 0) != (robj._valp == 0)) return 1;
return robj._valp->diff(this);
}
int AsnObj::operator==(const AsnObj &robj) const
{
int ansr = ((*this) != robj);
if (!ansr) return 1;
if (ansr > 0) return 0;
return -1;
}
int AsnChoice::operator!=(const AsnChoice & robj) const
{
const AsnObj *rsubp;
AsnObj *lsubp;
int flag;
if ((_flags & ASN_DEFINED_FLAG) != (robj._flags & ASN_DEFINED_FLAG))
return asn_obj_err(ASN_MATCH_ERR);
if (!(_flags & ASN_FILLED_FLAG) && !(robj._flags & ASN_FILLED_FLAG)) return 0;
flag = ((_flags & ASN_DEFINED_FLAG))? ASN_CHOSEN_FLAG: ASN_FILLED_FLAG;
for (rsubp = robj._sub; rsubp && !(rsubp->_flags & flag); rsubp = rsubp->_next);
for (lsubp = _sub; lsubp && !(lsubp->_flags & flag); lsubp = lsubp->_next);
if ((lsubp == 0) != (rsubp == 0)) return 1;
if (!lsubp) return 0;
return ((*lsubp) != (*rsubp));
}
int AsnChoice::operator==(const AsnChoice &robj) const
{
int ansr = ((*this) != robj);
if (!ansr) return 1;
if (ansr > 0) return 0;
return -1;
}
int AsnSequence::operator!=(const AsnSequence & robj) const
{
int ansr;
const AsnObj *rsubp, *lsubp;
for (rsubp = robj._sub, lsubp = _sub; lsubp && rsubp &&
!(ansr = ((*lsubp) != (*rsubp)));
rsubp = rsubp->_next, lsubp = lsubp->_next);
if (ansr) return ansr;
if (lsubp || rsubp) return 1;
return 0;
}
int AsnSequence::operator==(const AsnSequence & robj) const
{
int ansr = ((*this) != robj);
if (!ansr) return 1;
if (ansr > 0) return 0;
return -1;
}
int AsnSet::operator!=(const AsnSet & robj) const
{
return ((*(AsnObj *)this) != (AsnObj)robj);
}
int AsnSet::operator==(const AsnSet & robj) const
{
return ((*(AsnObj *)this) == (AsnObj)robj);
}
int AsnTableObj::operator!=(const AsnTableObj &robj) const
{
const AsnObj *robjp = &robj;
return (*((AsnObj *)this) != *robjp);
}
int AsnTableObj::operator==(const AsnTableObj &robj) const
{
int ansr = ((*this) != robj);
if (!ansr) return 1;
if (ansr > 0) return 0;
return -1;
}
int AsnPtr::operator!=(const AsnPtr &robj) const
{
const AsnObj *rsubp = robj._ptr;
AsnObj *lsubp;
int ansr;
if (!rsubp) return 0;
lsubp = _ptr;
if ((ansr = ((*lsubp) != (*rsubp))) < 0) stuff(0);
return ansr;
}
int AsnPtr::operator==(const AsnPtr &robj) const
{
int ansr = ((*this) != robj);
if (!ansr) return 1;
if (ansr > 0) return 0;
return -1;
}
int AsnString::operator!=(const char *c) const
{
int ansr;
char *b;
if (_type != ASN_OBJ_ID) return _valp->diff(c);
if ((ansr = ((AsnObj *)this)->vsize()) != strlen(c) + 1) return 1;
b = (char *)calloc(ansr, 1);
((AsnObj *)this)->read((uchar *)b);
ansr = strncmp(b, c, ansr);
free(b);
return ansr;
}
int AsnString::operator==(const char *c) const
{
int ansr = ((*this) != c);
if (!ansr) return 1;
return 0;
}
int AsnNumeric::operator!=(const long val) const
{
const long i = *this;
return i != val;
}
int AsnNumeric::operator==(const long val) const
{
const long i = *this;
return i == val;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -