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, 2018 Oracle and/or its affiliates. All rights reserved.
5  *
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 
20 #ifndef _RESULT_HPP
21 #define _RESULT_HPP
22 
23 #include <string>
24 #include <xercesc/util/XercesDefs.hpp>
25 
26 #include <xqilla/framework/XQillaExport.hpp>
27 #include <xqilla/items/Item.hpp>
29 #include <xqilla/runtime/EmptyResult.hpp>
30 
31 class Sequence;
32 class SequenceType;
33 class DynamicContext;
34 class StaticType;
35 
37 class XQILLA_API Result
38 {
39 public:
40  Result(const Item::Ptr &item);
41  Result(const Sequence &seq);
42  Result(ResultImpl *impl);
43  Result(const Result &o);
44  Result &operator=(const Result &o);
45  ~Result();
46 
48  ResultImpl *operator->();
49 
51  const ResultImpl *operator->() const;
52 
54  ResultImpl *get();
55 
57  const ResultImpl *get() const;
58 
60  bool isNull() const;
61 
62  EmptyResult* getEmpty() const;
63 
64 private:
65  ResultImpl *_impl;
66 
67  static EmptyResult _empty;
68 };
69 
70 inline bool Result::isNull() const
71 {
72  return _impl == 0;
73 }
74 
76 {
77  if(_impl) return _impl;
78  return getEmpty();
79 }
80 
81 inline const ResultImpl *Result::get() const
82 {
83  if(_impl) return _impl;
84  return getEmpty();
85 }
86 
88 {
89  return get();
90 }
91 
92 inline const ResultImpl *Result::operator->() const
93 {
94  return get();
95 }
96 
97 #endif
A scoped pointer wrapper for the lazily evaluated query result.
Definition: Result.hpp:37
bool isNull() const
Returns true if the underlying pointer is null.
Definition: Result.hpp:70
The execution time dynamic context interface.
Definition: DynamicContext.hpp:38
EmptyResult * getEmpty() const
ResultImpl * get()
Returns the underlying ResultImpl object.
Definition: Result.hpp:75
Class that represents the static type of an expression.
Definition: StaticType.hpp:33
An eagerly evaluated result of a query execution.
Definition: Sequence.hpp:39
A lazily evaluated query result.
Definition: ResultImpl.hpp:33
ResultImpl * operator->()
Returns the underlying ResultImpl object.
Definition: Result.hpp:87