SourceForge.net Logo
Result.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2008
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004-2008
5  * Oracle. All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * $Id$
20  */
21 
22 #ifndef _RESULT_HPP
23 #define _RESULT_HPP
24 
25 #include <string>
26 #include <xercesc/util/XercesDefs.hpp>
27 
28 #include <xqilla/framework/XQillaExport.hpp>
29 #include <xqilla/items/Item.hpp>
31 #include <xqilla/runtime/EmptyResult.hpp>
32 
33 class Sequence;
34 class SequenceType;
35 class DynamicContext;
36 class StaticType;
37 
39 class XQILLA_API Result
40 {
41 public:
42  Result(const Item::Ptr &item);
43  Result(const Sequence &seq);
44  Result(ResultImpl *impl);
45  Result(const Result &o);
46  Result &operator=(const Result &o);
47  ~Result();
48 
50  ResultImpl *operator->();
51 
53  const ResultImpl *operator->() const;
54 
56  ResultImpl *get();
57 
59  const ResultImpl *get() const;
60 
62  bool isNull() const;
63 
64  EmptyResult* getEmpty() const;
65 
66 private:
67  ResultImpl *_impl;
68 
69  static EmptyResult _empty;
70 };
71 
72 inline bool Result::isNull() const
73 {
74  return _impl == 0;
75 }
76 
78 {
79  if(_impl) return _impl;
80  return getEmpty();
81 }
82 
83 inline const ResultImpl *Result::get() const
84 {
85  if(_impl) return _impl;
86  return getEmpty();
87 }
88 
90 {
91  return get();
92 }
93 
94 inline const ResultImpl *Result::operator->() const
95 {
96  return get();
97 }
98 
99 #endif
A scoped pointer wrapper for the lazily evaluated query result.
Definition: Result.hpp:39
bool isNull() const
Returns true if the underlying pointer is null.
Definition: Result.hpp:72
The execution time dynamic context interface.
Definition: DynamicContext.hpp:39
EmptyResult * getEmpty() const
ResultImpl * get()
Returns the underlying ResultImpl object.
Definition: Result.hpp:77
Class that represents the static type of an expression.
Definition: StaticType.hpp:35
An eagerly evaluated result of a query execution.
Definition: Sequence.hpp:41
A lazily evaluated query result.
Definition: ResultImpl.hpp:35
ResultImpl * operator->()
Returns the underlying ResultImpl object.
Definition: Result.hpp:89