MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / vwrite_discriminator

Function vwrite_discriminator

dds/DCPS/XTypes/DynamicVwrite.cpp:1061–1250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1059}
1060
1061bool vwrite_discriminator(ValueWriter& vw, DDS::DynamicData_ptr value,
1062 const DDS::MemberDescriptor_var& md, CORBA::Long& disc_val)
1063{
1064 using namespace OpenDDS::XTypes;
1065 const DDS::MemberId id = DISCRIMINATOR_ID;
1066 const DDS::DynamicType_var disc_type = get_base_type(md->type());
1067 const DDS::TypeKind disc_tk = disc_type->get_kind();
1068 DDS::TypeKind treat_disc_as;
1069 if (get_equivalent_kind(disc_type, treat_disc_as) != DDS::RETCODE_OK) {
1070 return false;
1071 }
1072
1073 ListEnumHelper enum_helper(treat_disc_as);
1074 if (disc_tk == TK_ENUM && !set_enumerated_helper<ACE_CDR::Long>(disc_type, enum_helper)) {
1075 return false;
1076 }
1077
1078 DDS::ReturnCode_t rc = DDS::RETCODE_OK;
1079 switch (treat_disc_as) {
1080 case TK_BOOLEAN: {
1081 CORBA::Boolean val = false;
1082 rc = value->get_boolean_value(val, id);
1083 if (!check_rc(rc, id, disc_tk, "vwrite_discriminator")) {
1084 return false;
1085 }
1086 disc_val = static_cast<CORBA::Long>(val);
1087 if (!vw.write_boolean(val)) {
1088 return false;
1089 }
1090 break;
1091 }
1092 case TK_BYTE: {
1093 CORBA::Octet val = 0x00;
1094 rc = value->get_byte_value(val, id);
1095 if (!check_rc(rc, id, disc_tk, "vwrite_discriminator")) {
1096 return false;
1097 }
1098 disc_val = static_cast<CORBA::Long>(val);
1099 if (!vw.write_byte(val)) {
1100 return false;
1101 }
1102 break;
1103 }
1104 case TK_CHAR8: {
1105 CORBA::Char val = '\0';
1106 rc = value->get_char8_value(val, id);
1107 if (!check_rc(rc, id, disc_tk, "vwrite_discriminator")) {
1108 return false;
1109 }
1110 disc_val = static_cast<CORBA::Long>(val);
1111 if (!vw.write_char8(val)) {
1112 return false;
1113 }
1114 break;
1115 }
1116#ifdef DDS_HAS_WCHAR
1117 case TK_CHAR16: {
1118 CORBA::WChar val = L'\0';

Callers 1

vwrite_unionFunction · 0.85

Calls 15

get_base_typeFunction · 0.85
get_equivalent_kindFunction · 0.85
typekind_to_stringFunction · 0.85
get_kindMethod · 0.80
get_int64_valueMethod · 0.80
get_uint64_valueMethod · 0.80
check_rcFunction · 0.70
typeMethod · 0.45
get_boolean_valueMethod · 0.45
write_booleanMethod · 0.45
get_byte_valueMethod · 0.45
write_byteMethod · 0.45

Tested by

no test coverage detected