OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
CollectionElement.hpp
1 /*
2  * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
3  *
4  * Website: http://www.ocilib.net
5  *
6  * Copyright (c) 2007-2023 Vincent ROGIER <vince.rogier@ocilib.net>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #pragma once
22 
23 #include "ocilibcpp/types.hpp"
24 
25 // ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment
26 
27 namespace ocilib
28 {
29 
30 template<class T>
31 CollectionElement<T>::CollectionElement() : _coll(nullptr), _pos(0)
32 {
33 
34 }
35 
36 template<class T>
37 CollectionElement<T>::CollectionElement(CollectionType *coll, unsigned int pos) : _coll(coll), _pos(pos)
38 {
39 
40 }
41 
42 template<class T>
43 CollectionElement<T>::operator T() const
44 {
45  return _coll->Get(_pos);
46 }
47 
48 template<class T>
49 CollectionElement<T>& CollectionElement<T>::operator = (const ValueType& other)
50 {
51  if (this != &other)
52  {
53  _coll->Set(_pos, other);
54  }
55 
56  return *this;
57 }
58 
59 template<class T>
60 CollectionElement<T>& CollectionElement<T>::operator = (const CollectionElement &other)
61 {
62  if (this != &other)
63  {
64  _coll->Set(_pos, static_cast<T>(other));
65  }
66 
67  return *this;
68 }
69 
70 template<class T>
71 bool CollectionElement<T>::IsNull() const
72 {
73  return _coll->IsElementNull(_pos);
74 }
75 
76 template<class T>
77 void CollectionElement<T>::SetNull()
78 {
79  _coll->SetElementNull(_pos);
80 }
81 
82 }
OCILIB ++ Namespace.