summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/ast/ast_annotation_appls.cpp
blob: c943c2a641a503c8febbf094962b1689d14a8b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "ast_annotation_appls.h"
#include "ast_annotation_appl.h"

AST_Annotation_Appls::AST_Annotation_Appls ()
{
}

AST_Annotation_Appls::AST_Annotation_Appls (const AST_Annotation_Appls& other)
{
  *this = other;
}

AST_Annotation_Appls::~AST_Annotation_Appls ()
{
}

AST_Annotation_Appls &
AST_Annotation_Appls::operator= (const AST_Annotation_Appls& other)
{
  vector_.clear ();
  add (other);
  return *this;
}

void
AST_Annotation_Appls::add (AST_Annotation_Appl *appl)
{
  vector_.push_back (AST_Annotation_Appl_Ptr (appl));
}

void
AST_Annotation_Appls::add (const AST_Annotation_Appls &other)
{
  for (const_iterator i = other.begin (); i != other.end (); ++i)
    {
      vector_.push_back (*i);
    }
}

bool
AST_Annotation_Appls::empty () const
{
  return !vector_.size ();
}

size_t
AST_Annotation_Appls::size () const
{
  return vector_.size ();
}

AST_Annotation_Appls::iterator
AST_Annotation_Appls::begin ()
{
  return vector_.begin ();
}

AST_Annotation_Appls::iterator
AST_Annotation_Appls::end ()
{
  return vector_.end ();
}

AST_Annotation_Appls::const_iterator
AST_Annotation_Appls::begin () const
{
  return vector_.begin ();
}

AST_Annotation_Appls::const_iterator
AST_Annotation_Appls::end () const
{
  return vector_.end ();
}

AST_Annotation_Appl *
AST_Annotation_Appls::operator[] (size_t index)
{
  return vector_[index].get ();
}

AST_Annotation_Appl *
AST_Annotation_Appls::find (AST_Annotation_Decl *annotation)
{
  AST_Annotation_Appl *result = nullptr;
  for (iterator i = begin (); i != end (); ++i)
    {
      AST_Annotation_Appl *appl = i->get ();
      if (appl && appl->annotation_decl () == annotation)
        {
          result = appl;
        }
    }
  return result;
}

AST_Annotation_Appl *
AST_Annotation_Appls::find (const char *annotation)
{
  if (!annotation)
    {
      return nullptr;
    }

  UTL_Scope* bottom = idl_global->scopes ().bottom ();
  if (!bottom)
    {
      return nullptr;
    }

  AST_Decl* decl = bottom->lookup_by_name (annotation);
  if (!decl)
    {
      return nullptr;
    }

  return find (dynamic_cast<AST_Annotation_Decl*> (decl));
}