SourceForge.net Logo

Result.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001, 2008,
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004, 2011,
00005  *     Oracle and/or its affiliates. All rights reserved.
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 
00020 #ifndef _RESULT_HPP
00021 #define _RESULT_HPP
00022 
00023 #include <string>
00024 #include <xercesc/util/XercesDefs.hpp>
00025 
00026 #include <xqilla/framework/XQillaExport.hpp>
00027 #include <xqilla/items/Item.hpp>
00028 #include <xqilla/runtime/ResultImpl.hpp>
00029 #include <xqilla/runtime/EmptyResult.hpp>
00030 
00031 class Sequence;
00032 class SequenceType;
00033 class DynamicContext;
00034 class StaticType;
00035 
00037 class XQILLA_API Result
00038 {
00039 public:
00040   Result(const Item::Ptr &item);
00041   Result(const Sequence &seq);
00042   Result(ResultImpl *impl);
00043   Result(const Result &o);
00044   Result &operator=(const Result &o);
00045   ~Result();
00046 
00048   ResultImpl *operator->();
00049 
00051   const ResultImpl *operator->() const;
00052 
00054   ResultImpl *get();
00055 
00057   const ResultImpl *get() const;
00058 
00060   bool isNull() const;
00061 
00062   EmptyResult* getEmpty() const;
00063   
00064 private:
00065   ResultImpl *_impl;
00066 
00067   static EmptyResult _empty;
00068 };
00069 
00070 inline bool Result::isNull() const
00071 {
00072   return _impl == 0;
00073 }
00074 
00075 inline ResultImpl *Result::get()
00076 {
00077   if(_impl) return _impl;
00078   return getEmpty();
00079 }
00080 
00081 inline const ResultImpl *Result::get() const
00082 {
00083   if(_impl) return _impl;
00084   return getEmpty();
00085 }
00086 
00087 inline ResultImpl *Result::operator->()
00088 {
00089   return get();
00090 }
00091 
00092 inline const ResultImpl *Result::operator->() const
00093 {
00094   return get();
00095 }
00096 
00097 #endif