1//
2// DynamicLOB.cpp
3//
4// Library: Data
5// Package: DataCore
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/Data/DynamicLOB.h"
19#include "Poco/Data/LOB.h"
20#include "Poco/Dynamic/Var.h"
21
22
23namespace Poco {
24namespace Dynamic {
25
26
27using Poco::Data::CLOB;
28using Poco::Data::BLOB;
29
30
31template <>
32Var::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
50template <>
51Var::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::Data
71
72
73#endif // __GNUC__
74
75