📄 constraint_nodes.cpp
字号:
if (this->type_ == TAO_DOUBLE)
return_value = this->op_.double_;
else if (this->type_ == TAO_SIGNED)
return_value = (CORBA::Double) this->op_.integer_;
else if (this->type_ == TAO_UNSIGNED)
return_value = (CORBA::Double) this->op_.uinteger_;
return return_value;
}
TAO_Literal_Constraint::operator const char* (void) const
{
return (this->type_ == TAO_STRING) ? this->op_.str_ : 0;
}
TAO_Literal_Constraint::operator const CORBA::Any* (void) const
{
return (this->type_ == TAO_SEQUENCE) ? this->op_.any_ : 0;
}
TAO_Expression_Type
TAO_Literal_Constraint::comparable_type (CORBA::TypeCode_ptr type)
{
// Convert a CORBA::TCKind into a TAO_Literal_Type
ACE_DECLARE_NEW_CORBA_ENV;
TAO_Expression_Type return_value = TAO_UNKNOWN;
CORBA::TCKind kind = CORBA::tk_null;
ACE_TRY
{
kind = type->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
return return_value;
}
ACE_ENDTRY;
// Since this is a "top level try block, no need to check again.
switch (kind)
{
case CORBA::tk_ushort:
case CORBA::tk_ulong:
return_value = TAO_UNSIGNED;
break;
case CORBA::tk_long:
case CORBA::tk_short:
return_value = TAO_SIGNED;
break;
case CORBA::tk_boolean:
return_value = TAO_BOOLEAN;
break;
case CORBA::tk_float:
case CORBA::tk_double:
return_value = TAO_DOUBLE;
break;
case CORBA::tk_string:
return_value = TAO_STRING;
break;
case CORBA::tk_sequence:
return_value = TAO_SEQUENCE;
break;
case CORBA::tk_alias:
{
CORBA::TCKind kind = CORBA::tk_void;
ACE_TRY_EX (label2)
{
CORBA::TypeCode_var typecode = type->content_type (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK_EX (label2);
kind = typecode->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK_EX (label2);;
}
ACE_CATCHANY
{
return return_value;
}
ACE_ENDTRY;
// Since this is a "top level try block, no need to check again.
if (kind == CORBA::tk_sequence)
return_value = TAO_SEQUENCE;
}
break;
default:
return_value = TAO_UNKNOWN;
}
return return_value;
}
int
operator== (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
int return_value = 0;
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_STRING:
return_value = (ACE_OS::strcmp ((const char*) left, (const char*) right) == 0);
break;
case TAO_DOUBLE:
return_value = (CORBA::Double) left == (CORBA::Double) right;
break;
case TAO_SIGNED:
return_value = (CORBA::Long) left == (CORBA::Long) right;
break;
case TAO_UNSIGNED:
return_value = (CORBA::ULong) left == (CORBA::ULong) right;
break;
case TAO_BOOLEAN:
return_value = (CORBA::Boolean) left == (CORBA::Boolean) right;
break;
}
return return_value;
}
int
operator!= (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
int return_value = 0;
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_STRING:
return_value = (ACE_OS::strcmp ((const char*) left, (const char*) right) != 0);
break;
case TAO_DOUBLE:
return_value = (CORBA::Double) left != (CORBA::Double) right;
break;
case TAO_SIGNED:
return_value = (CORBA::Long) left != (CORBA::Long) right;
break;
case TAO_UNSIGNED:
return_value = (CORBA::ULong) left != (CORBA::ULong) right;
break;
case TAO_BOOLEAN:
return_value = (CORBA::Boolean) left != (CORBA::Boolean) right;
break;
}
return return_value;
}
int
operator< (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
int return_value = 0;
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_STRING:
return_value = (ACE_OS::strcmp ((const char*) left, (const char*) right) < 0);
break;
case TAO_DOUBLE:
return_value = (CORBA::Double) left < (CORBA::Double) right;
break;
case TAO_SIGNED:
return_value = (CORBA::Long) left < (CORBA::Long) right;
break;
case TAO_UNSIGNED:
return_value = (CORBA::ULong) left < (CORBA::ULong) right;
break;
case TAO_BOOLEAN:
return_value = (CORBA::Boolean) left < (CORBA::Boolean) right;
break;
}
return return_value;
}
int
operator<= (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
int return_value = 0;
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_STRING:
return_value = (ACE_OS::strcmp ((const char*) left, (const char*) right) <= 0);
break;
case TAO_DOUBLE:
return_value = (CORBA::Double) left <= (CORBA::Double) right;
break;
case TAO_SIGNED:
return_value = (CORBA::Long) left <= (CORBA::Long) right;
break;
case TAO_UNSIGNED:
return_value = (CORBA::ULong) left <= (CORBA::ULong) right;
break;
}
return return_value;
}
int
operator> (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
int return_value = 0;
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_STRING:
return_value = (ACE_OS::strcmp ((const char*) left, (const char*) right) > 0);
break;
case TAO_DOUBLE:
return_value = (CORBA::Double) left > (CORBA::Double) right;
break;
case TAO_SIGNED:
return_value = (CORBA::Long) left > (CORBA::Long) right;
break;
case TAO_UNSIGNED:
return_value = (CORBA::ULong) left > (CORBA::ULong) right;
break;
}
return return_value;
}
int
operator>= (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
int return_value = 0;
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_STRING:
return_value = (ACE_OS::strcmp ((const char*) left, (const char*) right) >= 0);
break;
case TAO_DOUBLE:
return_value = (CORBA::Double) left >= (CORBA::Double) right;
break;
case TAO_SIGNED:
return_value = (CORBA::Long) left >= (CORBA::Long) right;
break;
case TAO_UNSIGNED:
return_value = (CORBA::ULong) left >= (CORBA::ULong) right;
break;
}
return return_value;
}
int
operator== (CORBA::Double left, const TAO_Literal_Constraint& right)
{
return (left == (CORBA::Double) right);
}
int
operator== (const TAO_String_Manager& left,
const TAO_Literal_Constraint& right)
{
int result = 0;
if ((const char*) right != 0)
result = ACE_OS::strcmp ((const char*) left,
(const char*) right) == 0;
return result;
}
TAO_Literal_Constraint
operator+ (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_DOUBLE:
{
CORBA::Double result = (CORBA::Double) left + (CORBA::Double) right;
return TAO_Literal_Constraint ((CORBA::Double) result);
}
case TAO_SIGNED:
{
CORBA::Long result = (CORBA::Long) left + (CORBA::Long) right;
return TAO_Literal_Constraint ((CORBA::Long) result);
}
case TAO_UNSIGNED:
{
CORBA::ULong result = (CORBA::ULong) left + (CORBA::ULong) right;
return TAO_Literal_Constraint ((CORBA::ULong) result);
}
default:
return TAO_Literal_Constraint ((CORBA::Long)0);
}
}
TAO_Literal_Constraint
operator- (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_DOUBLE:
{
CORBA::Double result = (CORBA::Double) left - (CORBA::Double) right;
return TAO_Literal_Constraint ((CORBA::Double) result);
}
case TAO_SIGNED:
{
CORBA::Long result = (CORBA::Long) left - (CORBA::Long) right;
return TAO_Literal_Constraint ((CORBA::Long) result);
}
case TAO_UNSIGNED:
{
CORBA::ULong result = (CORBA::ULong) left - (CORBA::ULong) right;
return TAO_Literal_Constraint ((CORBA::ULong) result);
}
default:
return TAO_Literal_Constraint ((CORBA::Long)0);
}
}
TAO_Literal_Constraint
operator* (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_DOUBLE:
{
CORBA::Double result = (CORBA::Double) left * (CORBA::Double) right;
return TAO_Literal_Constraint ((CORBA::Double) result);
}
case TAO_SIGNED:
{
CORBA::Long result = (CORBA::Long) left * (CORBA::Long) right;
return TAO_Literal_Constraint ((CORBA::Long) result);
}
case TAO_UNSIGNED:
{
CORBA::ULong result = (CORBA::ULong) left * (CORBA::ULong) right;
return TAO_Literal_Constraint ((CORBA::ULong) result);
}
default:
return TAO_Literal_Constraint ((CORBA::Long)0);
}
}
TAO_Literal_Constraint
operator/ (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
TAO_Expression_Type widest_type =
TAO_Literal_Constraint::widest_type (left, right);
switch (widest_type)
{
case TAO_DOUBLE:
{
CORBA::Double result = (CORBA::Double) left / (CORBA::Double) right;
return TAO_Literal_Constraint ((CORBA::Double) result);
}
case TAO_SIGNED:
{
CORBA::Long result = (CORBA::Long) left / (CORBA::Long) right;
return TAO_Literal_Constraint ((CORBA::Long) result);
}
case TAO_UNSIGNED:
{
CORBA::ULong result = (CORBA::ULong) left / (CORBA::ULong) right;
return TAO_Literal_Constraint ((CORBA::ULong) result);
}
default:
return TAO_Literal_Constraint ((CORBA::Long)0);
}
}
TAO_Literal_Constraint
operator- (const TAO_Literal_Constraint& operand)
{
switch (operand.expr_type ())
{
case TAO_DOUBLE:
{
CORBA::Double result = - (CORBA::Double) operand;
return TAO_Literal_Constraint ((CORBA::Double) result);
}
case TAO_SIGNED:
{
CORBA::Long result = - (CORBA::Long) operand;
return TAO_Literal_Constraint ((CORBA::Long) result);
}
case TAO_UNSIGNED:
{
CORBA::Long result = - (CORBA::Long) ((CORBA::ULong) operand);
return TAO_Literal_Constraint ((CORBA::ULong) result);
}
default:
return TAO_Literal_Constraint ((CORBA::Long)0);
}
}
TAO_Expression_Type
TAO_Literal_Constraint::widest_type (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right)
{
TAO_Expression_Type left_type = left.expr_type (),
right_type = right.expr_type (),
return_value = right_type;
if (right_type != left_type)
{
if (right_type > left_type)
return_value = right_type;
else
return_value = left_type;
}
return return_value;
}
void
TAO_Literal_Constraint::copy (const TAO_Literal_Constraint& lit)
{
this->type_ = lit.type_;
if (this->type_ == TAO_STRING)
this->op_.str_ = CORBA::string_dup (lit.op_.str_);
else if (this->type_ == TAO_DOUBLE)
this->op_.double_ = lit.op_.double_;
else if (this->type_ == TAO_UNSIGNED)
this->op_.uinteger_ = lit.op_.uinteger_;
else if (this->type_ == TAO_SIGNED)
this->op_.integer_ = lit.op_.integer_;
else if (this->type_ == TAO_BOOLEAN)
this->op_.bool_ = lit.op_.bool_;
else if (this->type_ == TAO_SEQUENCE)
this->op_.any_ = lit.op_.any_;
else
type_ = TAO_UNKNOWN;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -