db_object.h
Go to the documentation of this file.
/*
* Copyright (c) 2014 Jerry Lundström <lundstrom.jerry@gmail.com>
* Copyright (c) 2014 .SE (The Internet Infrastructure Foundation).
* Copyright (c) 2014 OpenDNSSEC AB (svb)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __db_object_h
#define __db_object_h
struct db_object;
struct db_object_field;
struct db_object_field_list;
typedef struct db_object db_object_t;
typedef struct db_object_field db_object_field_t;
typedef struct db_object_field_list db_object_field_list_t;
#include "db_connection.h"
#include "db_result.h"
#include "db_join.h"
#include "db_clause.h"
#include "db_type.h"
#include "db_value.h"
#include "db_enum.h"
#include "db_backend.h"
struct db_object_field {
db_object_field_t* next;
const char* name;
db_type_t type;
const db_enum_t* enum_set;
};
db_object_field_t* db_object_field_new(void);
db_object_field_t* db_object_field_new_copy(const db_object_field_t* from_object_field);
void db_object_field_free(db_object_field_t* object_field);
int db_object_field_copy(db_object_field_t* object_field, const db_object_field_t* from_object_field);
const char* db_object_field_name(const db_object_field_t* object_field);
db_type_t db_object_field_type(const db_object_field_t* object_field);
int db_object_field_set_name(db_object_field_t* object_field, const char* name);
int db_object_field_set_type(db_object_field_t* object_field, db_type_t type);
int db_object_field_set_enum_set(db_object_field_t* object_field, const db_enum_t* enum_set);
int db_object_field_not_empty(const db_object_field_t* object_field);
const db_object_field_t* db_object_field_next(const db_object_field_t* object_field);
struct db_object_field_list {
db_object_field_t* begin;
db_object_field_t* end;
size_t size;
};
db_object_field_list_t* db_object_field_list_new(void);
db_object_field_list_t* db_object_field_list_new_copy(const db_object_field_list_t* from_object_field_list);
void db_object_field_list_free(db_object_field_list_t* object_field_list);
int db_object_field_list_copy(db_object_field_list_t* object_field_list, const db_object_field_list_t* from_object_field_list);
int db_object_field_list_add(db_object_field_list_t* object_field_list, db_object_field_t* object_field);
const db_object_field_t* db_object_field_list_begin(const db_object_field_list_t* object_field_list);
size_t db_object_field_list_size(const db_object_field_list_t* object_field_list);
struct db_object {
const db_connection_t* connection;
const char* table;
const char* primary_key_name;
db_object_field_list_t* object_field_list;
};
db_object_t* db_object_new(void);
void db_object_free(db_object_t* object);
const db_connection_t* db_object_connection(const db_object_t* object);
const char* db_object_table(const db_object_t* object);
const db_object_field_list_t* db_object_object_field_list(const db_object_t* object);
int db_object_set_connection(db_object_t* object, const db_connection_t* connection);
int db_object_set_table(db_object_t* object, const char* table);
int db_object_set_primary_key_name(db_object_t* object, const char* primary_key_name);
int db_object_set_object_field_list(db_object_t* object, db_object_field_list_t* object_field_list);
int db_object_create(const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set);
db_result_list_t* db_object_read(const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list);
int db_object_update(const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set, const db_clause_list_t* clause_list);
int db_object_delete(const db_object_t* object, const db_clause_list_t* clause_list);
int db_object_count(const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list, size_t* count);
#endif
db_connection.h
db_object_field_new
db_object_field_t * db_object_field_new(void)
Definition: db_object.c:40
db_object_field_list_free
void db_object_field_list_free(db_object_field_list_t *object_field_list)
Definition: db_object.c:199
db_value.h
db_object_field_list_begin
const db_object_field_t * db_object_field_list_begin(const db_object_field_list_t *object_field_list)
Definition: db_object.c:284
db_object::object_field_list
db_object_field_list_t * object_field_list
Definition: db_object.h:205
db_type.h
db_object_field_free
void db_object_field_free(db_object_field_t *object_field)
Definition: db_object.c:69
db_object_set_object_field_list
int db_object_set_object_field_list(db_object_t *object, db_object_field_list_t *object_field_list)
Definition: db_object.c:386
db_object_object_field_list
const db_object_field_list_t * db_object_object_field_list(const db_object_t *object)
Definition: db_object.c:334
db_object
Definition: db_object.h:201
db_object_count
int db_object_count(const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list, size_t *count)
Definition: db_object.c:481
db_object_field_set_enum_set
int db_object_field_set_enum_set(db_object_field_t *object_field, const db_enum_t *enum_set)
Definition: db_object.c:134
db_object_field_list_copy
int db_object_field_list_copy(db_object_field_list_t *object_field_list, const db_object_field_list_t *from_object_field_list)
Definition: db_object.c:216
db_object_create
int db_object_create(const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set)
Definition: db_object.c:401
db_object_connection
const db_connection_t * db_object_connection(const db_object_t *object)
Definition: db_object.c:320
db_clause_list
Definition: db_clause.h:226
db_object_field_list_new
db_object_field_list_t * db_object_field_list_new(void)
Definition: db_object.c:174
db_enum.h
db_object_field_list_add
int db_object_field_list_add(db_object_field_list_t *object_field_list, db_object_field_t *object_field)
Definition: db_object.c:254
db_object_field_list
Definition: db_object.h:142
db_result.h
db_object_field_list::begin
db_object_field_t * begin
Definition: db_object.h:143
db_object_free
void db_object_free(db_object_t *object)
Definition: db_object.c:311
db_object_field::next
db_object_field_t * next
Definition: db_object.h:53
db_value_set
Definition: db_value.h:281
db_result_list
Definition: db_result.h:114
db_object_table
const char * db_object_table(const db_object_t *object)
Definition: db_object.c:327
db_join_list
Definition: db_join.h:94
db_object_field_copy
int db_object_field_copy(db_object_field_t *object_field, const db_object_field_t *from_object_field)
Definition: db_object.c:76
db_object_field::name
const char * name
Definition: db_object.h:54
db_object_set_primary_key_name
int db_object_set_primary_key_name(db_object_t *object, const char *primary_key_name)
Definition: db_object.c:371
db_object_field::enum_set
const db_enum_t * enum_set
Definition: db_object.h:56
db_object_field_list::end
db_object_field_t * end
Definition: db_object.h:144
db_object_read
db_result_list_t * db_object_read(const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list)
Definition: db_object.c:424
db_object_field_set_name
int db_object_field_set_name(db_object_field_t *object_field, const char *name)
Definition: db_object.c:110
db_object_field_list_size
size_t db_object_field_list_size(const db_object_field_list_t *object_field_list)
Definition: db_object.c:292
db_object_field_list::size
size_t size
Definition: db_object.h:145
db_object_delete
int db_object_delete(const db_object_t *object, const db_clause_list_t *clause_list)
Definition: db_object.c:464
db_object_field_next
const db_object_field_t * db_object_field_next(const db_object_field_t *object_field)
Definition: db_object.c:162
db_object_new
db_object_t * db_object_new(void)
Definition: db_object.c:304
db_type_t
db_type_t
Definition: db_type.h:54
db_object_set_table
int db_object_set_table(db_object_t *object, const char *table)
Definition: db_object.c:356
db_clause.h
db_object_field_set_type
int db_object_field_set_type(db_object_field_t *object_field, db_type_t type)
Definition: db_object.c:122
db_object_field::type
db_type_t type
Definition: db_object.h:55
db_join.h
db_object_update
int db_object_update(const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set, const db_clause_list_t *clause_list)
Definition: db_object.c:441
db_object::primary_key_name
const char * primary_key_name
Definition: db_object.h:204
db_object_field_type
db_type_t db_object_field_type(const db_object_field_t *object_field)
Definition: db_object.c:102
db_object_set_connection
int db_object_set_connection(db_object_t *object, const db_connection_t *connection)
Definition: db_object.c:341
db_connection
Definition: db_connection.h:46
db_enum
Definition: db_enum.h:38
db_object_field_name
const char * db_object_field_name(const db_object_field_t *object_field)
Definition: db_object.c:94
db_object::table
const char * table
Definition: db_object.h:203
db_object_field_list_new_copy
db_object_field_list_t * db_object_field_list_new_copy(const db_object_field_list_t *from_object_field_list)
Definition: db_object.c:182
db_backend.h
db_object_field_new_copy
db_object_field_t * db_object_field_new_copy(const db_object_field_t *from_object_field)
Definition: db_object.c:52
db_object::connection
const db_connection_t * connection
Definition: db_object.h:202
db_object_field_not_empty
int db_object_field_not_empty(const db_object_field_t *object_field)
Definition: db_object.c:146
db_object_field
Definition: db_object.h:52