30 #include "ScopeStack.h"
32 #include "BESInternalError.h"
42 const string ScopeStack::Entry::sTypeStrings[NUM_SCOPE_TYPES] = {
"<GLOBAL>",
"<Variable_Atomic>",
43 "<Variable_Constructor>",
"<Attribute_Atomic>",
"<Attribute_Container>", };
45 ScopeStack::Entry::Entry(ScopeType theType,
const string& theName) :
46 type(theType), name(theName)
48 if (theType < 0 || theType >= NUM_SCOPE_TYPES) {
50 "ScopeStack::Entry(): Invalid scope type = " << theType <<
" for scope name=" << theName << endl);
57 ScopeStack::ScopeStack() :
62 ScopeStack::~ScopeStack()
68 void ScopeStack::clear()
73 void ScopeStack::pop()
78 const ScopeStack::Entry&
79 ScopeStack::top()
const
84 bool ScopeStack::empty()
const
86 return _scope.empty();
89 int ScopeStack::size()
const
94 string ScopeStack::getScopeString()
const
97 vector<Entry>::const_iterator iter;
98 for (iter = _scope.begin(); iter != _scope.end(); iter++) {
99 if (iter != _scope.begin()) {
102 scope.append((*iter).name);
107 string ScopeStack::getTypedScopeString()
const
110 vector<Entry>::const_iterator iter;
111 for (iter = _scope.begin(); iter != _scope.end(); iter++) {
112 if (iter != _scope.begin()) {
115 scope.append((*iter).getTypedName());
122 if (_scope.empty() && type == GLOBAL) {
125 else if (_scope.empty()) {
129 return (_scope.back().type == type);
135 void ScopeStack::push(
const Entry& entry)
137 if (entry.type == GLOBAL) {
138 BESDEBUG(
"ncml",
"Logic error: can't push a GLOBAL scope type, ignoring." << endl);
141 _scope.push_back(entry);