Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

cxx_multi.cpp

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: cxx_multi.cpp,v 12.3 2005/09/30 07:40:20 mjc Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #include "db_cxx.h"
00013 
00014 DbMultipleIterator::DbMultipleIterator(const Dbt &dbt)
00015  : data_((u_int8_t*)dbt.get_data()),
00016    p_((u_int32_t*)(data_ + dbt.get_size() - sizeof(u_int32_t)))
00017 {
00018 }
00019 
00020 bool DbMultipleDataIterator::next(Dbt &data)
00021 {
00022         if (*p_ == (u_int32_t)-1) {
00023                 data.set_data(0);
00024                 data.set_size(0);
00025                 p_ = 0;
00026         } else {
00027                 data.set_data(data_ + *p_--);
00028                 data.set_size(*p_--);
00029                 if (data.get_size() == 0 && data.get_data() == data_)
00030                         data.set_data(0);
00031         }
00032         return (p_ != 0);
00033 }
00034 
00035 bool DbMultipleKeyDataIterator::next(Dbt &key, Dbt &data)
00036 {
00037         if (*p_ == (u_int32_t)-1) {
00038                 key.set_data(0);
00039                 key.set_size(0);
00040                 data.set_data(0);
00041                 data.set_size(0);
00042                 p_ = 0;
00043         } else {
00044                 key.set_data(data_ + *p_--);
00045                 key.set_size(*p_--);
00046                 data.set_data(data_ + *p_--);
00047                 data.set_size(*p_--);
00048         }
00049         return (p_ != 0);
00050 }
00051 
00052 bool DbMultipleRecnoDataIterator::next(db_recno_t &recno, Dbt &data)
00053 {
00054         if (*p_ == (u_int32_t)0) {
00055                 recno = 0;
00056                 data.set_data(0);
00057                 data.set_size(0);
00058                 p_ = 0;
00059         } else {
00060                 recno = *p_--;
00061                 data.set_data(data_ + *p_--);
00062                 data.set_size(*p_--);
00063         }
00064         return (p_ != 0);
00065 }

Generated on Sun Dec 25 12:14:18 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2