xquery_stack_trace.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZORBA_XQUERY_STACK_TRACE_API_H
18 #define ZORBA_XQUERY_STACK_TRACE_API_H
19 
20 #include <string>
21 #include <vector>
22 
23 #include <zorba/internal/qname.h>
24 
25 namespace zorba {
26 
27 class XQueryStackTrace;
28 
29 namespace serialization {
30  class Archiver;
31  void operator&( Archiver&, XQueryStackTrace& );
32 }
33 
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 public:
39  typedef unsigned short fn_arity_type;
40  typedef unsigned line_type;
41  typedef unsigned short column_type;
42 
43  class Entry {
44  public:
45  Entry( fn_name_type const &fn_name, fn_arity_type fn_arity,
46  char const *file_name, line_type line, column_type column,
47  line_type line_end, column_type column_end);
48 
49  fn_name_type const& getFnName() const {
50  return fn_name_;
51  }
52 
53  fn_arity_type const& getFnArity() const {
54  return fn_arity_;
55  }
56 
57  std::string const& getFileName() const {
58  return filename_;
59  }
60 
61  line_type getLine() const {
62  return line_;
63  }
64 
66  return col_;
67  }
68 
70  return line_end_;
71  }
72 
74  return col_end_;
75  }
76 
78  return fn_name_;
79  }
80 
82  return fn_arity_;
83  }
84 
85  std::string& getFileNameRef() {
86  return filename_;
87  }
88 
90  return line_;
91  }
92 
94  return col_;
95  }
96 
98  return line_end_;
99  }
100 
102  return col_end_;
103  }
104 
105  private:
106  fn_name_type fn_name_;
107  fn_arity_type fn_arity_;
108  std::string filename_;
109  line_type line_;
110  column_type col_;
111  line_type line_end_;
112  column_type col_end_;
113  public:
114  // for plan serialization
115  Entry();
116  };
117 
118  typedef std::vector<Entry> trace_t;
119  typedef trace_t::size_type size_type;
120  typedef trace_t::const_iterator const_iterator;
121  typedef trace_t::const_reverse_iterator const_reverse_iterator;
122 
123  bool empty() const {
124  return trace_.empty();
125  }
126 
128  return trace_.begin();
129  }
130 
131  const_iterator end() const {
132  return trace_.end();
133  }
134 
136  return trace_.rbegin();
137  }
138 
140  return trace_.rend();
141  }
142 
143  void push( Entry const &entry );
144 
145  size_type size() const {
146  return trace_.size();
147  }
148 
149 private:
150  trace_t trace_;
151 
152  friend void serialization::operator&( serialization::Archiver&,
153  XQueryStackTrace& );
154 };
155 
156 ///////////////////////////////////////////////////////////////////////////////
157 
158 } // namespace zorba
159 
160 #endif /* ZORBA_XQUERY_STACK_TRACE_API_H */
161 /*
162  * Local variables:
163  * mode: c++
164  * End:
165  */
166 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus