This repository has been archived on 2024-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
hedera/db/db-iter.c

73 lines
1.9 KiB
C

/*
* Copyright (C) 2012 - Juan Ferrer Toribio
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "db-iter.h"
/**
* SECTION: db-iter
* @Short_description: an iterator for the #DbModel
* @Title: DbIter
* @See_also: #DbModel
*
* The #DbIter is the structure used to navigate through a #DbModel. See #DbModel
* for the methods required to do it.
**/
G_DEFINE_BOXED_TYPE (DbIter, db_iter, db_iter_copy, db_iter_free);
/**
* db_model_iter_compare:
* @a: a #DbIter
* @b: a #DbIter
*
* Compares the two given iters for equality. The equality between two
* #DbIter is determined by its stamp and the row of a #DbModel they are
* pointing to.
*
* Return value: #TRUE if the two iters are the same
**/
gboolean db_iter_compare (DbIter * a, DbIter * b)
{
return (a->stamp == b->stamp && a->data == b->data);
}
/**
* db_iter_copy:
* @obj: the #DbIter to copy
*
* Copies a #DbIter. Note that this function copies only the reference to the
* data in @obj. This is so due to the nature of #DbIter and it's use.
*
* Return value: a new #DbIter
**/
DbIter * db_iter_copy (DbIter * obj)
{
g_return_val_if_fail (obj, NULL);
DbIter * dst = g_new (DbIter, 1);
dst->stamp = obj->stamp;
dst->data = obj->data;
dst->data2 = obj->data2;
dst->data3 = obj->data3;
return dst;
}
void db_iter_free (DbIter * obj)
{
g_return_if_fail (obj);
g_free (obj);
}