aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Data/src/DynamicLOB.cpp
blob: 5dfe3df8574bbf2f27072b16dad95b6cdec497dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// DynamicLOB.cpp
//
// Library: Data
// Package: DataCore
// Module:  DynamicLOB
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifdef __GNUC__
// TODO: determine g++ version able to do the right thing without these specializations

#include "Poco/Data/DynamicLOB.h"
#include "Poco/Data/LOB.h"
#include "Poco/Dynamic/Var.h"


namespace Poco {
namespace Dynamic {


using Poco::Data::CLOB;
using Poco::Data::BLOB;


template <>
Var::operator CLOB () const
{
	VarHolder* pHolder = content();

	if (!pHolder)
		throw InvalidAccessException("Can not convert empty value.");

	if (typeid(CLOB) == pHolder->type())
		return extract<CLOB>();
	else
	{
		std::string result;
		pHolder->convert(result);
		return CLOB(result);
	}
}


template <>
Var::operator BLOB () const
{
	VarHolder* pHolder = content();

	if (!pHolder)
		throw InvalidAccessException("Can not convert empty value.");

	if (typeid(BLOB) == pHolder->type())
		return extract<BLOB>();
	else
	{
		std::string result;
		pHolder->convert(result);
		return BLOB(reinterpret_cast<const unsigned char*>(result.data()),
			result.size());
	}
}


} } // namespace Poco::Data


#endif // __GNUC__