//--------------------------------------------------------------------------- bool IValue::operator<=(const IValue &a_Val) const { char_type type1 = GetType(), type2 = a_Val.GetType(); if (type1 == type2 || (IsScalar() && a_Val.IsScalar())) { switch (GetType()) { case 's': return GetString() <= a_Val.GetString(); case 'i': case 'f': case 'c': return GetFloat() <= a_Val.GetFloat(); case 'b': return GetBool() <= a_Val.GetBool(); default: ErrorContext err; err.Errc = ecINTERNAL_ERROR; err.Pos = -1; err.Type1 = GetType(); err.Type2 = a_Val.GetType(); throw ParserError(err); } // switch this type } else { ErrorContext err; err.Errc = ecTYPE_CONFLICT_FUN; err.Arg = (type1 != 'f' && type1 != 'i') ? 1 : 2; err.Type1 = type2; err.Type2 = type1; throw ParserError(err); } }
//--------------------------------------------------------------------------- bool IValue::operator!=(const IValue &a_Val) const { char_type type1 = GetType(), type2 = a_Val.GetType(); if (type1 == type2 || (IsScalar() && a_Val.IsScalar())) { switch (GetType()) { case 's': return GetString() != a_Val.GetString(); case 'i': case 'f': return GetFloat() != a_Val.GetFloat(); case 'c': return (GetFloat() != a_Val.GetFloat()) || (GetImag() != a_Val.GetImag()); case 'b': return GetBool() != a_Val.GetBool(); case 'v': return true; case 'm': if (GetRows() != a_Val.GetRows() || GetCols() != a_Val.GetCols()) { return true; } else { for (int i = 0; i < GetRows(); ++i) { if (const_cast<IValue*>(this)->At(i) != const_cast<IValue&>(a_Val).At(i)) return true; } return false; } default: ErrorContext err; err.Errc = ecINTERNAL_ERROR; err.Pos = -1; err.Type2 = GetType(); err.Type1 = a_Val.GetType(); throw ParserError(err); } // switch this type } else { return true; } }