OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
TypeInfo.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 namespace ocilib
26 {
27 
28 inline TypeInfo::TypeInfo(const Connection &connection, const ostring& name, TypeInfoType type)
29 {
30  AcquireTransient
31  (
32  core::Check(OCI_TypeInfoGet(connection, name.c_str(), type)),
33  connection.GetHandle()
34  );
35 }
36 
37 inline TypeInfo::TypeInfo(OCI_TypeInfo *pTypeInfo, core::Handle* parent)
38 {
39  AcquireTransient(pTypeInfo, parent);
40 }
41 
43 {
44  return TypeInfoType(static_cast<TypeInfoType::Type>(core::Check(OCI_TypeInfoGetType(*this))));
45 }
46 
47 inline ostring TypeInfo::GetName() const
48 {
49  return core::Check(OCI_TypeInfoGetName(*this));
50 }
51 
53 {
54  return Connection
55  (
57  Environment::GetEnvironmentHandle()
58  );
59 }
60 
61 inline unsigned int TypeInfo::GetColumnCount() const
62 {
64 }
65 
66 inline Column TypeInfo::GetColumn(unsigned int index) const
67 {
68  return Column(core::Check(OCI_TypeInfoGetColumn(*this, index)), GetHandle());
69 }
70 
71 inline boolean TypeInfo::IsFinalType() const
72 {
73  return (core::Check(OCI_TypeInfoIsFinalType(*this)) == TRUE);
74 }
75 
77 {
78  Connection connection = GetConnection();
79 
80  return TypeInfo(core::Check(OCI_TypeInfoGetSuperType(*this)), connection.GetHandle());
81 }
82 
83 }
Encapsulate a Resultset column or object member properties.
Definition: types.hpp:6867
A connection or session with a specific database.
Definition: types.hpp:1580
Provides type information on Oracle Database objects.
Definition: types.hpp:4531
TypeInfo(const Connection &connection, const ostring &name, TypeInfoType type)
Parametrized constructor.
Definition: TypeInfo.hpp:28
boolean IsFinalType() const
Indicate if the given UDT type is final.
Definition: TypeInfo.hpp:71
Connection GetConnection() const
Return the connection associated with a statement.
Definition: TypeInfo.hpp:52
ostring GetName() const
Return the type info name.
Definition: TypeInfo.hpp:47
unsigned int GetColumnCount() const
Return the number of columns contained in the type.
Definition: TypeInfo.hpp:61
Column GetColumn(unsigned int index) const
Return the column from its index in the resultset.
Definition: TypeInfo.hpp:66
core::Enum< TypeInfoTypeValues > TypeInfoType
Type of object information.
Definition: types.hpp:4561
TypeInfoType GetType() const
Return the type of the given TypeInfo object.
Definition: TypeInfo.hpp:42
TypeInfo GetSuperType() const
Return the super type of the given type (e.g. parent type for a derived ORACLE UDT type)
Definition: TypeInfo.hpp:76
Template Enumeration template class providing some type safety to some extends for manipulating enume...
Definition: core.hpp:118
Internal usage. Interface for handling ownership and relationship of a C API handle.
Definition: core.hpp:325
struct OCI_TypeInfo OCI_TypeInfo
Type info metadata handle.
Definition: types.h:366
OCI_SYM_PUBLIC OCI_TypeInfo *OCI_API OCI_TypeInfoGet(OCI_Connection *con, const otext *name, unsigned int type)
Retrieve the available type info information.
OCI_SYM_PUBLIC OCI_Connection *OCI_API OCI_TypeInfoGetConnection(OCI_TypeInfo *typinf)
Retrieve connection handle from the type info handle.
OCI_SYM_PUBLIC OCI_TypeInfo *OCI_API OCI_TypeInfoGetSuperType(OCI_TypeInfo *typinf)
Return the super type of the given type (e.g. parent type for a derived ORACLE UDT type)
OCI_SYM_PUBLIC boolean OCI_API OCI_TypeInfoIsFinalType(OCI_TypeInfo *typinf)
Indicate if the given UDT type if final.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_TypeInfoGetColumnCount(OCI_TypeInfo *typinf)
Return the number of columns of a table/view/object.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_TypeInfoGetType(OCI_TypeInfo *typinf)
Return the type of the type info object.
OCI_SYM_PUBLIC const otext *OCI_API OCI_TypeInfoGetName(OCI_TypeInfo *typinf)
Return the name described by the type info object.
OCI_SYM_PUBLIC OCI_Column *OCI_API OCI_TypeInfoGetColumn(OCI_TypeInfo *typinf, unsigned int index)
Return the column object handle at the given index in the table.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so,...
Definition: Utils.hpp:53
OCILIB ++ Namespace.
std::basic_string< otext, std::char_traits< otext >, std::allocator< otext > > ostring
string class wrapping the OCILIB otext * type and OTEXT() macros ( see Character sets )
Definition: config.hpp:120