OpenDDS  Snapshot(2023/04/28-20:55)
Namespaces | Functions
annotations.cpp File Reference
#include "annotations.h"
#include "be_extern.h"
#include "be_util.h"
#include <ast_annotation_appl.h>
#include <ast_annotation_decl.h>
#include <ast_annotation_member.h>
#include <ast_sequence.h>
#include <ast_array.h>
#include <ast_union.h>
#include <utl_string.h>
Include dependency graph for annotations.cpp:

Go to the source code of this file.

Namespaces

 OpenDDS
 The Internal API and Implementation of OpenDDS.
 

Functions

AST_Expression::AST_ExprValue * get_annotation_member_ev (AST_Annotation_Appl *appl, const char *member_name, AST_Expression::ExprType type)
 
bool get_bool_annotation_member_value (AST_Annotation_Appl *appl, const char *member_name)
 
ACE_UINT32 get_u32_annotation_member_value (AST_Annotation_Appl *appl, const char *member_name)
 
std::string get_str_annotation_member_value (AST_Annotation_Appl *appl, const char *member_name)
 

Function Documentation

◆ get_annotation_member_ev()

AST_Expression::AST_ExprValue* get_annotation_member_ev ( AST_Annotation_Appl *  appl,
const char *  member_name,
AST_Expression::ExprType  type 
)

Definition at line 93 of file annotations.cpp.

References be_util::misc_error_and_abort().

Referenced by get_bool_annotation_member_value(), get_str_annotation_member_value(), and get_u32_annotation_member_value().

95 {
96  AST_Annotation_Member* member =
97  dynamic_cast<AST_Annotation_Member*>((*appl)[member_name]);
98  if (member) {
99  AST_Expression* e = member->value();
100  if (e && e->ev()) {
101  if (e->ev()->et != type) {
102  be_util::misc_error_and_abort(std::string("Found unexpected expression type "
103  "while getting value of member \"") +
104  member_name + "\" of annotation \"" +
105  appl->local_name()->get_string() + '"',
106  appl);
107  }
108  return e->ev();
109  }
110  }
111 
112  be_util::misc_error_and_abort(std::string("Found null pointer while getting value of member \"") +
113  member_name + "\" of annotation \"" +
114  appl->local_name()->get_string() + '"',
115  appl);
116  return 0;
117 }
void misc_error_and_abort(const std::string &message, AST_Decl *node=0)
Report a miscellaneous error and abort.

◆ get_bool_annotation_member_value()

bool get_bool_annotation_member_value ( AST_Annotation_Appl *  appl,
const char *  member_name 
)

Definition at line 119 of file annotations.cpp.

References get_annotation_member_ev().

Referenced by get_str_annotation_member_value().

121 {
122  AST_Expression::AST_ExprValue* const ev =
123  get_annotation_member_ev(appl, member_name, AST_Expression::EV_bool);
124  return ev->u.bval;
125 }
AST_Expression::AST_ExprValue * get_annotation_member_ev(AST_Annotation_Appl *appl, const char *member_name, AST_Expression::ExprType type)
Definition: annotations.cpp:93

◆ get_str_annotation_member_value()

std::string get_str_annotation_member_value ( AST_Annotation_Appl *  appl,
const char *  member_name 
)

Definition at line 135 of file annotations.cpp.

References get_annotation_member_ev(), get_bool_annotation_member_value(), get_str_annotation_member_value(), get_u32_annotation_member_value(), and AnnotationWithValue< T >::value_from_appl().

Referenced by get_str_annotation_member_value(), TopicAnnotation::value_from_appl(), and OpenDDS::internal::SpecialSerializationAnnotation::value_from_appl().

137 {
138  AST_Expression::AST_ExprValue* const ev =
139  get_annotation_member_ev(appl, member_name, AST_Expression::EV_string);
140  return ev->u.strval->get_string();
141 }
AST_Expression::AST_ExprValue * get_annotation_member_ev(AST_Annotation_Appl *appl, const char *member_name, AST_Expression::ExprType type)
Definition: annotations.cpp:93

◆ get_u32_annotation_member_value()

ACE_UINT32 get_u32_annotation_member_value ( AST_Annotation_Appl *  appl,
const char *  member_name 
)

Definition at line 127 of file annotations.cpp.

References get_annotation_member_ev().

Referenced by get_str_annotation_member_value(), AnnotationWithEnumValue< ExtensibilityKind >::value_from_appl(), and OpenDDS::DataRepresentationAnnotation::value_from_appl().

129 {
130  AST_Expression::AST_ExprValue* const ev =
131  get_annotation_member_ev(appl, member_name, AST_Expression::EV_ulong);
132  return ev->u.ulval;
133 }
AST_Expression::AST_ExprValue * get_annotation_member_ev(AST_Annotation_Appl *appl, const char *member_name, AST_Expression::ExprType type)
Definition: annotations.cpp:93