OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
ThreadKey.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 void ThreadKey::Create(const ostring& name, ThreadKeyFreeProc freeProc)
29 {
30  core::Check(OCI_ThreadKeyCreate(name.c_str(), freeProc));
31 }
32 
33 inline void ThreadKey::SetValue(const ostring& name, AnyPointer value)
34 {
35  core::Check(OCI_ThreadKeySetValue(name.c_str(), value));
36 }
37 
39 {
40  return core::Check(OCI_ThreadKeyGetValue(name.c_str()));
41 }
42 
43 }
POCI_THREADKEYDEST ThreadKeyFreeProc
Thread Key callback for freeing resources.
Definition: types.hpp:1305
static void SetValue(const ostring &name, AnyPointer value)
Set a thread key value.
Definition: ThreadKey.hpp:33
static void Create(const ostring &name, ThreadKeyFreeProc freeProc=nullptr)
Create a thread key object.
Definition: ThreadKey.hpp:28
static AnyPointer GetValue(const ostring &name)
Get a thread key value.
Definition: ThreadKey.hpp:38
OCI_SYM_PUBLIC boolean OCI_API OCI_ThreadKeySetValue(const otext *name, void *value)
Set a thread key value.
OCI_SYM_PUBLIC boolean OCI_API OCI_ThreadKeyCreate(const otext *name, POCI_THREADKEYDEST destfunc)
Create a thread key object.
OCI_SYM_PUBLIC void *OCI_API OCI_ThreadKeyGetValue(const otext *name)
Get a thread key value.
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
void * AnyPointer
Alias for the generic void pointer.
Definition: config.hpp:129