1 | // |
---|---|
2 | // DynamicLOB.cpp |
3 | // |
4 | // Library: SQL |
5 | // Package: SQLCore |
6 | // Module: DynamicLOB |
7 | // |
8 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #ifdef __GNUC__ |
16 | // TODO: determine g++ version able to do the right thing without these specializations |
17 | |
18 | #include "Poco/SQL/DynamicLOB.h" |
19 | #include "Poco/SQL/LOB.h" |
20 | #include "Poco/Dynamic/Var.h" |
21 | |
22 | |
23 | namespace Poco { |
24 | namespace Dynamic { |
25 | |
26 | |
27 | using Poco::SQL::CLOB; |
28 | using Poco::SQL::BLOB; |
29 | |
30 | |
31 | template <> |
32 | Var::operator CLOB () const |
33 | { |
34 | VarHolder* pHolder = content(); |
35 | |
36 | if (!pHolder) |
37 | throw InvalidAccessException("Can not convert empty value."); |
38 | |
39 | if (typeid(CLOB) == pHolder->type()) |
40 | return extract<CLOB>(); |
41 | else |
42 | { |
43 | std::string result; |
44 | pHolder->convert(result); |
45 | return CLOB(result); |
46 | } |
47 | } |
48 | |
49 | |
50 | template <> |
51 | Var::operator BLOB () const |
52 | { |
53 | VarHolder* pHolder = content(); |
54 | |
55 | if (!pHolder) |
56 | throw InvalidAccessException("Can not convert empty value."); |
57 | |
58 | if (typeid(BLOB) == pHolder->type()) |
59 | return extract<BLOB>(); |
60 | else |
61 | { |
62 | std::string result; |
63 | pHolder->convert(result); |
64 | return BLOB(reinterpret_cast<const unsigned char*>(result.data()), |
65 | result.size()); |
66 | } |
67 | } |
68 | |
69 | |
70 | } } // namespace Poco::SQL |
71 | |
72 | |
73 | #endif // __GNUC__ |
74 | |
75 |