error.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_ERROR_API_H
18 #define ZORBA_ERROR_API_H
19 
21 #include <zorba/internal/qname.h>
22 
23 namespace zorba {
24 
25 class Diagnostic;
26 namespace serialization {
27  class Archiver;
28  void operator&( serialization::Archiver&, const Diagnostic*& );
29 }
30 
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 typedef Diagnostic Error;
34 
35 /**
36  * An %XQueryErrorCode is a diagnostic for all XQuery-specific errors.
37  */
39 
40 /**
41  * A %ZorbaErrorCode is a diagnostic for all Zorba-specific errors.
42  */
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 
47 /**
48  * A %UserError is-a Diagnostic for user-defined errors via \c fn:error().
49  */
50 class ZORBA_DLL_PUBLIC UserError : public Diagnostic {
51 public:
52  /**
53  * Copy-constructs a %UserError.
54  *
55  * @param from The %UserError to copy from.
56  */
57  UserError( UserError const &from );
58 
59  /**
60  * Destroys this %UserError.
61  */
62  ~UserError();
63 
64  /**
65  * Assigns this %UserError from another.
66  *
67  * @param from The %UserError to assign from.
68  * @return Returns \c *this.
69  */
70  UserError& operator=( UserError const &from );
71 
72  // inherited
73  diagnostic::QName const& qname() const;
75 
76 protected:
77  // inherited
78  Diagnostic const* clone() const;
79 
80 private:
82  QName qname_;
83 
84  /**
85  * Constructs a %UserError.
86  *
87  * @param ns The error's namespace URI.
88  * @param prefix The error's prefix.
89  * @param localname The error's local-name.
90  */
91  UserError( char const *ns, char const *prefix, char const *localname );
92 
93  friend class UserException;
94  friend UserError make_user_error( char const*, char const*, char const* );
95 
96  // for plan serialization
97  UserError( serialization::Archiver& );
98  friend void serialization::operator&( serialization::Archiver&,
99  const Diagnostic*& );
100 };
101 
102 ///////////////////////////////////////////////////////////////////////////////
103 
104 } // namespace zorba
105 #endif /* ZORBA_ERROR_API_H */
106 /*
107  * Local variables:
108  * mode: c++
109  * End:
110  */
111 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus