retdec
parameter.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_CTYPES_PARAMETER_H
8 #define RETDEC_CTYPES_PARAMETER_H
9 
10 #include <memory>
11 #include <set>
12 #include <string>
13 
14 namespace retdec {
15 namespace ctypes {
16 
17 class Annotation;
18 class Type;
19 
23 class Parameter
24 {
25  public:
26  using Annotations = std::set<std::shared_ptr<Annotation>>;
27  using annotation_iterator = Annotations::iterator;
28  using const_annotation_iterator = Annotations::const_iterator;
29 
30  public:
31  Parameter(
32  const std::string &name,
33  const std::shared_ptr<Type> &type,
34  const Annotations &annotations = {});
35 
36  const std::string &getName() const;
37  std::shared_ptr<Type> getType() const;
38 
45 
46  bool isIn() const;
47  bool isOut() const;
48  bool isInOut() const;
49  bool isOptional() const;
51 
52  bool operator==(const Parameter &other) const;
53  bool operator!=(const Parameter &other) const;
54 
55  private:
57  using AnnotationTypeHandler = bool (Annotation::*)() const;
58 
59  bool hasAnnotationOfType(const AnnotationTypeHandler &annotationType) const;
60 
61  private:
62  std::string name;
63  std::shared_ptr<Type> type;
65 };
66 
67 } // namespace ctypes
68 } // namespace retdec
69 
70 #endif
A representation of annotation.
Definition: annotation.h:24
A representation of a function parameter.
Definition: parameter.h:24
Parameter(const std::string &name, const std::shared_ptr< Type > &type, const Annotations &annotations={})
Constructs a new parameter.
Definition: parameter.cpp:17
Annotations::iterator annotation_iterator
Definition: parameter.h:27
bool isIn() const
Returns true when parameter is input, false otherwise.
Definition: parameter.cpp:84
std::shared_ptr< Type > getType() const
Returns parameter's type.
Definition: parameter.cpp:32
bool(Annotation::*)() const AnnotationTypeHandler
Pointer to Annotation's member functions.
Definition: parameter.h:57
Annotations::const_iterator const_annotation_iterator
Definition: parameter.h:28
bool hasAnnotationOfType(const AnnotationTypeHandler &annotationType) const
Definition: parameter.cpp:69
Annotations annotations
Definition: parameter.h:64
std::shared_ptr< Type > type
Definition: parameter.h:63
annotation_iterator annotation_begin()
Returns an iterator to the annotation.
Definition: parameter.cpp:40
std::set< std::shared_ptr< Annotation > > Annotations
Definition: parameter.h:26
bool operator!=(const Parameter &other) const
Definition: parameter.cpp:118
bool operator==(const Parameter &other) const
Definition: parameter.cpp:113
annotation_iterator annotation_end()
Returns an iterator past the last annotation.
Definition: parameter.cpp:56
bool isInOut() const
Returns true when parameter will be changed by the function, false otherwise.
Definition: parameter.cpp:100
bool isOut() const
Returns true when parameter is output, false otherwise.
Definition: parameter.cpp:92
const std::string & getName() const
Returns parameter's name.
Definition: parameter.cpp:24
std::string name
Definition: parameter.h:62
bool isOptional() const
Returns true when parameter may be null, false otherwise.
Definition: parameter.cpp:108
Definition: archive_wrapper.h:19