File: cxx_dbc.cpp

package info (click to toggle)
db5.3 5.3.28-12%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 163,332 kB
  • ctags: 82,990
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,326; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,106; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (123 lines) | stat: -rw-r--r-- 3,384 bytes parent folder | download | duplicates (8)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1997, 2013 Oracle and/or its affiliates.  All rights reserved.
 *
 * $Id$
 */

#include "db_config.h"

#include "db_int.h"

#include "db_cxx.h"
#include "dbinc/cxx_int.h"

#include "dbinc/db_page.h"
#include "dbinc_auto/db_auto.h"
#include "dbinc_auto/crdel_auto.h"
#include "dbinc/db_dispatch.h"
#include "dbinc_auto/db_ext.h"
#include "dbinc_auto/common_ext.h"

// Helper macro for simple methods that pass through to the
// underlying C method. It may return an error or raise an exception.
// Note this macro expects that input _argspec is an argument
// list element (e.g., "char *arg") and that _arglist is the arguments
// that should be passed through to the C method (e.g., "(db, arg)")
//
#define	DBC_METHOD(_name, _argspec, _arglist, _retok)			\
int Dbc::_name _argspec							\
{									\
	int ret;							\
	DBC *dbc = this;						\
									\
	ret = dbc->_name _arglist;					\
	if (!_retok(ret))						\
		DB_ERROR(DbEnv::get_DbEnv(dbc->dbenv),			\
			"Dbc::" # _name, ret, ON_ERROR_UNKNOWN);	\
	return (ret);							\
}

// It's private, and should never be called, but VC4.0 needs it resolved
//
Dbc::~Dbc()
{
}

DBC_METHOD(close, (void), (dbc), DB_RETOK_STD)
DBC_METHOD(cmp, (Dbc *other_cursor, int *result, u_int32_t _flags),
    (dbc, other_cursor, result, _flags), DB_RETOK_STD)
DBC_METHOD(count, (db_recno_t *countp, u_int32_t _flags),
    (dbc, countp, _flags), DB_RETOK_STD)
DBC_METHOD(del, (u_int32_t _flags),
    (dbc, _flags), DB_RETOK_DBCDEL)

int Dbc::dup(Dbc** cursorp, u_int32_t _flags)
{
	int ret;
	DBC *dbc = this;
	DBC *new_cursor = 0;

	ret = dbc->dup(dbc, &new_cursor, _flags);

	if (DB_RETOK_STD(ret))
		// The following cast implies that Dbc can be no larger than DBC
		*cursorp = (Dbc*)new_cursor;
	else
		DB_ERROR(DbEnv::get_DbEnv(dbc->dbenv),
			"Dbc::dup", ret, ON_ERROR_UNKNOWN);

	return (ret);
}

int Dbc::get(Dbt* key, Dbt *data, u_int32_t _flags)
{
	int ret;
	DBC *dbc = this;

	ret = dbc->get(dbc, key, data, _flags);

	if (!DB_RETOK_DBCGET(ret)) {
		if (ret == DB_BUFFER_SMALL && DB_OVERFLOWED_DBT(key))
			DB_ERROR_DBT(DbEnv::get_DbEnv(dbc->dbenv),
				"Dbc::get", key, ON_ERROR_UNKNOWN);
		else if (ret == DB_BUFFER_SMALL && DB_OVERFLOWED_DBT(data))
			DB_ERROR_DBT(DbEnv::get_DbEnv(dbc->dbenv),
				"Dbc::get", data, ON_ERROR_UNKNOWN);
		else
			DB_ERROR(DbEnv::get_DbEnv(dbc->dbenv),
				"Dbc::get", ret, ON_ERROR_UNKNOWN);
	}

	return (ret);
}

int Dbc::pget(Dbt* key, Dbt *pkey, Dbt *data, u_int32_t _flags)
{
	int ret;
	DBC *dbc = this;

	ret = dbc->pget(dbc, key, pkey, data, _flags);

	/* Logic is the same as for Dbc::get - reusing macro. */
	if (!DB_RETOK_DBCGET(ret)) {
		if (ret == DB_BUFFER_SMALL && DB_OVERFLOWED_DBT(key))
			DB_ERROR_DBT(DbEnv::get_DbEnv(dbc->dbenv),
				"Dbc::pget", key, ON_ERROR_UNKNOWN);
		else if (ret == DB_BUFFER_SMALL && DB_OVERFLOWED_DBT(data))
			DB_ERROR_DBT(DbEnv::get_DbEnv(dbc->dbenv),
				"Dbc::pget", data, ON_ERROR_UNKNOWN);
		else
			DB_ERROR(DbEnv::get_DbEnv(dbc->dbenv),
				"Dbc::pget", ret, ON_ERROR_UNKNOWN);
	}

	return (ret);
}

DBC_METHOD(put, (Dbt* key, Dbt *data, u_int32_t _flags),
    (dbc, key, data, _flags), DB_RETOK_DBCPUT)
DBC_METHOD(get_priority, (DB_CACHE_PRIORITY *priorityp),
    (dbc, priorityp), DB_RETOK_STD)
DBC_METHOD(set_priority, (DB_CACHE_PRIORITY pri), (dbc, pri), DB_RETOK_STD)