00001 /* 00002 * Copyright (c) 2001-2007 00003 * DecisionSoft Limited. All rights reserved. 00004 * Copyright (c) 2004-2007 00005 * Oracle. 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 * $Id: Result.hpp,v 1.12 2007/11/28 13:13:25 jpcs Exp $ 00020 */ 00021 00022 #ifndef _RESULT_HPP 00023 #define _RESULT_HPP 00024 00025 #include <string> 00026 #include <xercesc/util/XercesDefs.hpp> 00027 00028 #include <xqilla/framework/XQillaExport.hpp> 00029 #include <xqilla/items/Item.hpp> 00030 #include <xqilla/runtime/ResultImpl.hpp> 00031 #include <xqilla/runtime/EmptyResult.hpp> 00032 00033 class Sequence; 00034 class SequenceType; 00035 class DynamicContext; 00036 class StaticType; 00037 00039 class XQILLA_API Result 00040 { 00041 public: 00042 Result(const Item::Ptr &item); 00043 Result(const Sequence &seq); 00044 Result(ResultImpl *impl); 00045 Result(const Result &o); 00046 Result &operator=(const Result &o); 00047 ~Result(); 00048 00050 ResultImpl *operator->(); 00051 00053 const ResultImpl *operator->() const; 00054 00056 ResultImpl *get(); 00057 00059 const ResultImpl *get() const; 00060 00062 bool isNull() const; 00063 00064 EmptyResult* getEmpty() const; 00065 00066 private: 00067 ResultImpl *_impl; 00068 00069 static EmptyResult _empty; 00070 }; 00071 00072 inline bool Result::isNull() const 00073 { 00074 return _impl == 0; 00075 } 00076 00077 inline ResultImpl *Result::get() 00078 { 00079 if(_impl) return _impl; 00080 return getEmpty(); 00081 } 00082 00083 inline const ResultImpl *Result::get() const 00084 { 00085 if(_impl) return _impl; 00086 return getEmpty(); 00087 } 00088 00089 inline ResultImpl *Result::operator->() 00090 { 00091 return get(); 00092 } 00093 00094 inline const ResultImpl *Result::operator->() const 00095 { 00096 return get(); 00097 } 00098 00099 inline Result &Result::operator=(const Result &o) 00100 { 00101 if(o._impl != _impl) { 00102 if(_impl) _impl->decrementRefCount(); 00103 _impl = o._impl; 00104 if(_impl) _impl->incrementRefCount(); 00105 } 00106 return *this; 00107 } 00108 00109 #endif