/usr/include/qdbm/xadbm.h is in libxqdbm-dev 1.8.78-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | /*************************************************************************************************
* Abstraction for database managers compatible with DBM
* Copyright (C) 2000-2006 Mikio Hirabayashi
* This file is part of QDBM, Quick Database Manager.
* QDBM is free software; you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License or any later version. QDBM is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
* You should have received a copy of the GNU Lesser General Public License along with QDBM; if
* not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA.
*************************************************************************************************/
#ifndef _XADBM_H /* duplication check */
#define _XADBM_H
#include "xqdbm.h"
/**
* Error container for ADBM.
*/
class qdbm::DBM_error {
//----------------------------------------------------------------
// public member functions
//----------------------------------------------------------------
public:
/**
* Create an instance.
*/
DBM_error() throw();
/**
* Create an instance.
* @param message the string of a error message.
*/
DBM_error(const char* message) throw();
/**
* Release resources of the instance.
*/
virtual ~DBM_error() throw();
/**
* Cast operator into pointer to char.
* @return the pointer to the string.
*/
virtual operator const char*() const throw();
/**
* Get the message.
* @return the pointer to the string.
*/
virtual const char* message() const throw();
//----------------------------------------------------------------
// private member variables
//----------------------------------------------------------------
private:
/** The pointer to the region of the error message. */
char* errmsg;
};
//----------------------------------------------------------------
// Outer operators for Datum
//----------------------------------------------------------------
/**
* Temporary concatenation operator for Datum.
* @param former the former datum.
* @param latter the latter datum.
* @return reference to a temporary instance.
*/
qdbm::Datum qdbm::operator +(const qdbm::Datum& former, const qdbm::Datum& latter);
/**
* Temporary concatenation operator for Datum.
* @param datum the former datum.
* @param str the latter string.
* @return reference to a temporary instance.
*/
qdbm::Datum qdbm::operator +(const qdbm::Datum& datum, const char* str);
/**
* Temporary concatenation operator for Datum.
* @param str the former string.
* @param datum the latter datum.
* @return reference to a temporary instance.
*/
qdbm::Datum qdbm::operator +(const char* str, const qdbm::Datum& datum);
/**
* Datum of records for ADBM.
*/
class qdbm::Datum {
//----------------------------------------------------------------
// public member functions
//----------------------------------------------------------------
public:
/**
* Create an instance.
* @param dptr the pointer to the region of data.
* @param dsize the size of the region. If it is negative, the size is assigned
* with `std::strlen(dptr)'.
*/
Datum(const char* dptr = "", int dsize = -1);
/**
* Create an instance.
* @param num an integer number.
*/
Datum(int num);
/**
* Copy constructor.
* @param datum a source instance.
*/
Datum(const Datum& datum);
/**
* Release resources of the instance.
*/
virtual ~Datum() throw();
/**
* Assignment operator.
* @param datum a source instance.
* @return reference to itself.
*/
Datum& operator =(const Datum& datum);
/**
* Assignment operator.
* @param str a source string.
* @return reference to itself.
*/
Datum& operator =(const char* str);
/**
* Concatenation operator.
* @param datum a latter instance.
* @return reference to itself.
*/
virtual Datum& operator <<(const Datum& datum);
/**
* Concatenation operator.
* @param str a latter string.
* @return reference to itself.
*/
virtual Datum& operator <<(const char* str);
/**
* Equality operator.
* @param datum a comparing instance.
* @return true if both equal, else, false.
*/
virtual bool operator ==(const Datum& datum) const;
/**
* Inequality operator.
* @param datum a comparing instance.
* @return true if both do not equal, else, false.
*/
virtual bool operator !=(const Datum& datum) const;
/**
* Equality operator.
* @param str a comparing string.
* @return true if both equal, else, false.
*/
virtual bool operator ==(const char* str) const;
/**
* Inequality operator.
* @param str a comparing string.
* @return true if both do not equal, else, false.
*/
virtual bool operator !=(const char* str) const;
/**
* Subscripting operator.
* @param idx the index of a character.
* @return reference of the character.
*/
virtual char& operator [](int idx) const;
/**
* Cast operator into pointer to char.
* @return the pointer of the region of the datum.
* @note Because an additional zero code is appended at the end of the region of the return
* value, the return value can be treated as a character string.
*/
virtual operator const char*() const;
/**
* Get the pointer of the region of the datum.
* @return the pointer of the region of the datum.
* @note Because an additional zero code is appended at the end of the region of the return
* value, the return value can be treated as a character string.
*/
virtual const char* ptr() const;
/**
* Get the size of the region of the datum.
* @return the size of the region of the datum.
*/
virtual int size() const;
//----------------------------------------------------------------
// private member variables
//----------------------------------------------------------------
private:
/** The pointer to the region. */
char* dptr;
/** The size of the region. */
int dsize;
//----------------------------------------------------------------
// private member functions
//----------------------------------------------------------------
private:
/**
* Create an instance.
* @param dptr the region allocated with `std::malloc' or `std::realloc'.
* @param dsize the size of the region.
* @param dummy ignored. It is for difference of signature.
* @note the specified region is released with `std::free' at the destruction of the instance.
*/
Datum(char* dptr, int dsize, bool dummy);
//----------------------------------------------------------------
// friend classes and functions
//----------------------------------------------------------------
friend class qdbm::Depot;
friend class qdbm::Curia;
friend class qdbm::Villa;
friend Datum qdbm::operator +(const Datum& former, const Datum& latter);
friend Datum qdbm::operator +(const Datum& datum, const char* str);
friend Datum qdbm::operator +(const char* str, const Datum& datum);
};
/**
* Aabstraction for database managers compatible with DBM.
*/
class qdbm::ADBM {
//----------------------------------------------------------------
// public member functions
//----------------------------------------------------------------
public:
/**
* Release resources of the instance.
*/
virtual ~ADBM(){}
/**
* Close the database connection.
* @throw DBM_error if an error occurs.
*/
virtual void close() throw(DBM_error) = 0;
/**
* Store a record.
* @param key reference to a key object.
* @param val reference to a value object.
* @param replace whether the existing value is to be overwritten or not.
* @throw DBM_error if an error occurs or replace is cancelled.
*/
virtual void storerec(const Datum& key, const Datum& val, bool replace = true)
throw(DBM_error) = 0;
/**
* Delete a record.
* @param key reference to a key object.
* @throw DBM_error if an error occurs or no record corresponds.
*/
virtual void deleterec(const Datum& key) throw(DBM_error) = 0;
/**
* Fetch a record.
* @param key reference to a key object.
* @return a temporary instance of the value of the corresponding record.
* @throw DBM_error if an error occurs or no record corresponds.
*/
virtual Datum fetchrec(const Datum& key) throw(DBM_error) = 0;
/**
* Get the first key.
* @return a temporary instance of the key of the first record.
* @throw DBM_error if an error occurs or no record corresponds.
*/
virtual Datum firstkey() throw(DBM_error) = 0;
/**
* Get the next key.
* @return a temporary instance of the key of the next record.
* @throw DBM_error if an error occurs or no record corresponds.
*/
virtual Datum nextkey() throw(DBM_error) = 0;
/**
* Check whether a fatal error occured or not.
* @return true if the database has a fatal error, false if not.
* @throw DBM_error if an error occurs.
*/
virtual bool error() throw(DBM_error) = 0;
};
#endif /* duplication check */
/* END OF FILE */
|