backends/oracle/blob.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #include "soci-oracle.h"
9 #include "error.h"
10 #include "statement.h"
11 #include <cstring>
12 #include <sstream>
13 #include <cstdio>
14 #include <ctime>
15 #include <cctype>
16 
17 #ifdef _MSC_VER
18 #pragma warning(disable:4355)
19 #endif
20 
21 using namespace soci;
22 using namespace soci::details;
23 using namespace soci::details::oracle;
24 
26  : session_(session)
27 {
28  sword res = OCIDescriptorAlloc(session.envhp_,
29  reinterpret_cast<dvoid**>(&lobp_), OCI_DTYPE_LOB, 0, 0);
30  if (res != OCI_SUCCESS)
31  {
32  throw soci_error("Cannot allocate the LOB locator");
33  }
34 }
35 
37 {
38  OCIDescriptorFree(lobp_, OCI_DTYPE_LOB);
39 }
40 
42 {
43  ub4 len;
44 
45  sword res = OCILobGetLength(session_.svchp_, session_.errhp_,
46  lobp_, &len);
47 
48  if (res != OCI_SUCCESS)
49  {
51  }
52 
53  return static_cast<std::size_t>(len);
54 }
55 
57  std::size_t offset, char *buf, std::size_t toRead)
58 {
59  ub4 amt = static_cast<ub4>(toRead);
60 
61  sword res = OCILobRead(session_.svchp_, session_.errhp_, lobp_, &amt,
62  static_cast<ub4>(offset), reinterpret_cast<dvoid*>(buf),
63  amt, 0, 0, 0, 0);
64  if (res != OCI_SUCCESS)
65  {
67  }
68 
69  return static_cast<std::size_t>(amt);
70 }
71 
73  std::size_t offset, char const *buf, std::size_t toWrite)
74 {
75  ub4 amt = static_cast<ub4>(toWrite);
76 
77  sword res = OCILobWrite(session_.svchp_, session_.errhp_, lobp_, &amt,
78  static_cast<ub4>(offset),
79  reinterpret_cast<dvoid*>(const_cast<char*>(buf)),
80  amt, OCI_ONE_PIECE, 0, 0, 0, 0);
81  if (res != OCI_SUCCESS)
82  {
84  }
85 
86  return static_cast<std::size_t>(amt);
87 }
88 
89 std::size_t oracle_blob_backend::append(char const *buf, std::size_t toWrite)
90 {
91  ub4 amt = static_cast<ub4>(toWrite);
92 
93  sword res = OCILobWriteAppend(session_.svchp_, session_.errhp_, lobp_,
94  &amt, reinterpret_cast<dvoid*>(const_cast<char*>(buf)),
95  amt, OCI_ONE_PIECE, 0, 0, 0, 0);
96  if (res != OCI_SUCCESS)
97  {
99  }
100 
101  return static_cast<std::size_t>(amt);
102 }
103 
104 void oracle_blob_backend::trim(std::size_t newLen)
105 {
106  sword res = OCILobTrim(session_.svchp_, session_.errhp_, lobp_,
107  static_cast<ub4>(newLen));
108  if (res != OCI_SUCCESS)
109  {
111  }
112 }
oracle_blob_backend(oracle_session_backend &session)
virtual std::size_t append(char const *buf, std::size_t toWrite)
virtual std::size_t write(std::size_t offset, char const *buf, std::size_t toWrite)
void throw_oracle_soci_error(sword res, OCIError *errhp)
oracle_session_backend & session_
Definition: soci-oracle.h:238
OCILobLocator * lobp_
Definition: soci-oracle.h:240
virtual void trim(std::size_t newLen)
virtual std::size_t read(std::size_t offset, char *buf, std::size_t toRead)
virtual std::size_t get_len()


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40