本文整理汇总了C++中DataType::kind方法的典型用法代码示例。如果您正苦于以下问题:C++ DataType::kind方法的具体用法?C++ DataType::kind怎么用?C++ DataType::kind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType::kind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(TypeParserTests, TestIntPointerDataTypeParsing) {
this->setInput("*Int a");
DataType type = this->typeParser()->parseType();
ASSERT_EQ(DataType::Pointer, type.kind());
ASSERT_EQ(1, type.subtypeCount());
type = type.subtypeAtIndex(0);
ASSERT_EQ(DataType::Integer, type.kind());
ASSERT_EQ("a", this->peek().str());
}
示例2: parseTypePostfixes
DataType TypeParser::parseTypePostfixes(const DataType& type) {
DataType newType(type);
if (_helper->nextIf(Token::Type::OperatorNot)) {
newType.setAccess(DataType::Access::ReadWrite);
}
if (_helper->nextIf(Token::Type::OperatorQuestionMark)) {
switch (type.kind()) {
case DataType::Kind::Pointer:
newType.setKind(DataType::Kind::NullablePointer);
break;
case DataType::Kind::GenericPointer:
newType.setKind(DataType::Kind::GenericNullablePointer);
break;
case DataType::Kind::Generic:
newType = DataType::wrapInType(DataType::Kind::GenericNullablePointer, newType);
break;
default:
newType = DataType::wrapInType(DataType::Kind::NullablePointer, newType);
break;
}
}
return newType;
}
示例3:
TEST_F(ParserTests_Types, GlobalMutableBooleanPointerToMutablePointer) {
ASTNode* node = this->parseNode("*!*Bool! value\n");
node = node->childAtIndex(0);
DataType type = node->dataType();
ASSERT_EQ("Variable Declaration", node->nodeName());
ASSERT_EQ("value", node->name());
EXPECT_EQ(DataType::Pointer, type.kind());
EXPECT_EQ(DataType::Access::ReadWrite, type.access());
ASSERT_EQ(1, node->dataType().subtypeCount());
type = type.subtypeAtIndex(0);
EXPECT_EQ(DataType::Pointer, type.kind());
EXPECT_EQ(DataType::Access::Read, type.access());
ASSERT_EQ(1, type.subtypeCount());
type = type.subtypeAtIndex(0);
EXPECT_EQ(DataType::Boolean, type.kind());
EXPECT_EQ(DataType::Access::ReadWrite, type.access());
}
示例4: parseTypeSpecifiers
DataType TypeParser::parseTypeSpecifiers(const DataType& type) {
if (type.kind() == DataType::Kind::Character) {
return this->parseCharacterTypeSpecifiers(type);
}
DataType newType(type);
uint32_t value = 0;
// width specifier (or, colon)
if (_helper->nextIf(Token::Type::PunctuationColon)) {
if (_helper->peek().type() != Token::Type::PunctuationColon) {
if (!this->parseIntegerSpecifierValue(&value)) {
return DataType();
}
newType.setWidthSpecifier(value);
}
}
// alignment (or, colon)
if (_helper->nextIf(Token::Type::PunctuationColon)) {
if (_helper->peek().type() != Token::Type::PunctuationColon) {
if (!this->parseIntegerSpecifierValue(&value)) {
return DataType();
}
newType.setAlignmentSpecifier(value);
}
}
// vector
if (_helper->nextIf(Token::Type::PunctuationColon)) {
if (!this->parseIntegerSpecifierValue(&value)) {
return DataType();
}
newType.setVectorSizeSpecifier(value);
}
return newType;
}
示例5: Config_Error
DataType
DataType_Handler::data_type (
const CORBA::TypeCode_ptr& src)
{
DANCE_TRACE("DataType_Handler::data_type");
DataType type;
switch (src->kind ())
{
case ::CORBA::tk_null:
type.kind (TCKind::tk_null);
break;
case CORBA::tk_short:
type.kind (TCKind::tk_short);
break;
case CORBA::tk_long:
type.kind (TCKind::tk_long);
break;
case CORBA::tk_ushort:
type.kind (TCKind::tk_ushort);
break;
case CORBA::tk_ulong:
type.kind (TCKind::tk_ulong);
break;
case CORBA::tk_float:
type.kind (TCKind::tk_float);
break;
case CORBA::tk_double:
type.kind (TCKind::tk_double);
break;
case CORBA::tk_boolean:
type.kind (TCKind::tk_boolean);
break;
case CORBA::tk_char:
type.kind (TCKind::tk_char);
break;
case CORBA::tk_octet:
type.kind (TCKind::tk_octet);
break;
case CORBA::tk_string:
type.kind (TCKind::tk_string);
break;
case CORBA::tk_longlong:
type.kind (TCKind::tk_longlong);
break;
case CORBA::tk_ulonglong:
type.kind (TCKind::tk_ulonglong);
break;
case CORBA::tk_longdouble:
type.kind (TCKind::tk_longdouble);
break;
case CORBA::tk_wchar:
type.kind (TCKind::tk_wchar);
break;
case CORBA::tk_wstring:
type.kind (TCKind::tk_wstring);
break;
case CORBA::tk_any:
type.kind (TCKind::tk_any);
break;
case CORBA::tk_TypeCode:
type.kind (TCKind::tk_TypeCode);
default:
DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
(LM_ERROR, "DataType_Handler::data_type - Invalid typecode\n"));
throw Config_Error ("", "Invalid typecode");
}
return type;
}
示例6: kind
///This method takes a CIAO::Config_Handlers::DataType
///and returns the corresponding CORBA::TypeCode.
CORBA::TypeCode_ptr
DataType_Handler::data_type (const DataType& desc)
{
DANCE_TRACE("DataType_Handler::destructor");
TCKind kind (desc.kind ());
switch (kind.integral ())
{
case TCKind::tk_null_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_null);
case TCKind::tk_short_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_short);
case TCKind::tk_long_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_long);
case TCKind::tk_ushort_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_ushort);
case TCKind::tk_ulong_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_ulong);
case TCKind::tk_float_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_float);
case TCKind::tk_double_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_double);
case TCKind::tk_boolean_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_boolean);
case TCKind::tk_char_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_char);
case TCKind::tk_octet_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_octet);
case TCKind::tk_string_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_string);
case TCKind::tk_longlong_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_longlong);
case TCKind::tk_ulonglong_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_ulonglong);
case TCKind::tk_longdouble_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_longdouble);
case TCKind::tk_wchar_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_wchar);
case TCKind::tk_wstring_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_wstring);
case TCKind::tk_any_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_any);
case TCKind::tk_TypeCode_l:
return CORBA::TypeCode::_duplicate (CORBA::_tc_TypeCode);
default:
DANCE_DEBUG (DANCE_LOG_TERMINAL_ERROR,
(LM_ERROR, "DataType_Handler::data_type - Invalid typecode in any\n"));
throw Config_Error ("", "Invalid typecode");
}
// This case used to be supported...is it not in the schema?
// case TCKind::tk_Object)
// return CORBA::TypeCode::_duplicate (CORBA::_tc_Object);*/
}
示例7: Config_Error
DynamicAny::DynAny_ptr
DynAny_Handler::extract_into_dynany (const DataType &type,
const DataValue &value,
CORBA::TypeCode_ptr req_tc)
{
DANCE_TRACE("DynAny_Handler::extract_into_dynany");
DynamicAny::DynAny_var retval;
if (req_tc)
retval = this->daf_->create_dyn_any_from_type_code (req_tc);
TCKind::Value tkind = type.kind ().integral ();
if ((value.count_short () && tkind != TCKind::tk_short_l) ||
(value.count_long () && tkind != TCKind::tk_long_l) ||
(value.count_ushort () && tkind != TCKind::tk_ushort_l ) ||
(value.count_ulong () && tkind != TCKind::tk_ulong_l) ||
(value.count_float () && tkind != TCKind::tk_float_l) ||
(value.count_double () && tkind != TCKind::tk_double_l) ||
(value.count_boolean () && tkind != TCKind::tk_boolean_l) ||
(value.count_octet () && tkind != TCKind::tk_octet_l) ||
(value.count_longlong () && tkind != TCKind::tk_longlong_l) ||
(value.count_ulonglong () && tkind != TCKind::tk_ulonglong_l) ||
(value.count_string () && !(tkind == TCKind::tk_string_l ||
tkind == TCKind::tk_char_l ||
tkind == TCKind::tk_wchar_l)))
{
throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Wrong value type for data type"));
}
switch (tkind)
{
// ========== BASIC TYPES
case TCKind::tk_null_l:
case TCKind::tk_void_l:
DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
(LM_ERROR,
ACE_TEXT ("DynAny_Handler::extract_into_dynany - Don't know how to handle null or void types\n")));
throw Config_Error (ACE_TEXT (""),
ACE_TEXT ("Null or void types not supported"));
break;
case TCKind::tk_short_l:
{
if (!req_tc)
{
retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_short);
}
CORBA::Short s = 0;
if (value.count_short ())
{
s = *(*value.begin_short ());
}
retval->insert_short (s);
}
break;
case TCKind::tk_long_l:
{
if (!req_tc)
{
retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_long);
}
CORBA::Long l = 0;
if (value.count_long ())
{
l = *(*value.begin_long ());
}
retval->insert_long (l);
}
break;
case TCKind::tk_ushort_l:
{
if (!req_tc)
{
retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_ushort);
}
CORBA::UShort us = 0;
if (value.count_ushort ())
{
us = *(*value.begin_ushort ());
}
retval->insert_ushort (us);
}
break;
case TCKind::tk_ulong_l:
{
if (!req_tc)
{
retval = this->daf_->create_dyn_any_from_type_code (CORBA::_tc_ulong);
}
CORBA::ULong ul = 0;
if (value.count_ulong ())
{
ul = *(*value.begin_ulong ());
}
retval->insert_ulong (ul);
//.........这里部分代码省略.........