forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResultMetadata.h
More file actions
79 lines (57 loc) · 1.7 KB
/
ResultMetadata.h
File metadata and controls
79 lines (57 loc) · 1.7 KB
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
75
76
77
78
79
//
// ResultMetadata.h
//
// Library: Data/MySQL
// Package: MySQL
// Module: ResultMetadata
//
// Definition of the ResultMetadata class.
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_MySQL_ResultMetadata_INCLUDED
#define Data_MySQL_ResultMetadata_INCLUDED
#include <mysql.h>
#include <vector>
#include "Poco/Data/MetaColumn.h"
#if LIBMYSQL_VERSION_ID >= 80000
typedef bool my_bool; // Workaround to make library work with MySQL client 8.0 as well as earlier versions
typedef char my_boolv; // Workaround for std::vector<bool>
#else
typedef my_bool my_boolv;
#endif
namespace Poco {
namespace Data {
namespace MySQL {
class ResultMetadata
/// MySQL result metadata
{
public:
void reset();
/// Resets the metadata.
void init(MYSQL_STMT* stmt);
/// Initializes the metadata.
std::size_t columnsReturned() const;
/// Returns the number of columns in resultset.
const MetaColumn& metaColumn(std::size_t pos) const;
/// Returns the reference to the specified metacolumn.
MYSQL_BIND* row();
/// Returns pointer to native row.
std::size_t length(std::size_t pos) const;
/// Returns the length.
const unsigned char* rawData(std::size_t pos) const;
/// Returns raw data.
bool isNull(std::size_t pos) const;
/// Returns true if value at pos is null.
private:
std::vector<MetaColumn> _columns;
std::vector<MYSQL_BIND> _row;
std::vector<char> _buffer;
std::vector<unsigned long> _lengths;
std::vector<my_boolv> _isNull; // using char instead of bool to avoid std::vector<bool> disaster
};
} } } // namespace Poco::Data::MySQL
#endif //Data_MySQL_ResultMetadata_INCLUDED