error.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2008 The FLWOR Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef ZORBA_ERROR_API_H
00018 #define ZORBA_ERROR_API_H
00019 
00020 #include <zorba/internal/system_diagnostic.h>
00021 #include <zorba/internal/qname.h>
00022 
00023 namespace zorba {
00024 
00025 class Diagnostic;
00026 namespace serialization {
00027   class Archiver;
00028   void operator&( serialization::Archiver&, const Diagnostic*& );
00029 }
00030 
00031 ///////////////////////////////////////////////////////////////////////////////
00032 
00033 typedef Diagnostic Error;
00034 
00035 /**
00036  * An %XQueryErrorCode is a diagnostic for all XQuery-specific errors.
00037  */
00038 typedef internal::SystemDiagnostic<internal::XQueryErrQName> XQueryErrorCode;
00039 
00040 /**
00041  * A %ZorbaErrorCode is a diagnostic for all Zorba-specific errors.
00042  */
00043 typedef internal::SystemDiagnostic<internal::ZorbaErrQName> ZorbaErrorCode;
00044 
00045 ///////////////////////////////////////////////////////////////////////////////
00046 
00047 /**
00048  * A %UserError is-a Diagnostic for user-defined errors via \c fn:error().
00049  */
00050 class ZORBA_DLL_PUBLIC UserError : public Diagnostic {
00051 public:
00052   /**
00053    * Copy-constructs a %UserError.
00054    *
00055    * @param from The %UserError to copy from.
00056    */
00057   UserError( UserError const &from );
00058 
00059   /**
00060    * Destroys this %UserError.
00061    */
00062   ~UserError();
00063 
00064   /**
00065    * Assigns this %UserError from another.
00066    *
00067    * @param from The %UserError to assign from.
00068    * @return Returns \c *this.
00069    */
00070   UserError& operator=( UserError const &from );
00071 
00072   // inherited
00073   diagnostic::QName const& qname() const;
00074   diagnostic::category category() const;
00075 
00076 protected:
00077   // inherited
00078   Diagnostic const* clone() const;
00079 
00080 private:
00081   typedef internal::VariableQName<std::string> QName;
00082   QName qname_;
00083 
00084   /**
00085    * Constructs a %UserError.
00086    *
00087    * @param ns The error's namespace URI.
00088    * @param prefix The error's prefix.
00089    * @param localname The error's local-name.
00090    */
00091   UserError( char const *ns, char const *prefix, char const *localname );
00092 
00093   friend class UserException;
00094   friend UserError make_user_error( char const*, char const*, char const* );
00095 
00096   // for plan serialization
00097   UserError( serialization::Archiver& );
00098   friend void serialization::operator&( serialization::Archiver&,
00099                                         const Diagnostic*& );
00100 };
00101 
00102 ///////////////////////////////////////////////////////////////////////////////
00103 
00104 } // namespace zorba
00105 #endif /* ZORBA_ERROR_API_H */
00106 /*
00107  * Local variables:
00108  * mode: c++
00109  * End:
00110  */
00111 /* vim:set et sw=2 ts=2: */
blog comments powered by Disqus