db_value.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_value_h
#define __db_value_h
struct db_value;
struct db_value_set;
typedef struct db_value db_value_t;
typedef struct db_value_set db_value_set_t;
#include "config.h"
#include "db_type.h"
#include "db_enum.h"
#include <stdlib.h>
struct db_value {
db_type_t type;
int primary_key;
char* text;
db_type_int32_t int32;
db_type_uint32_t uint32;
db_type_int64_t int64;
db_type_uint64_t uint64;
int enum_value;
const char* enum_text;
};
#define DB_VALUE_EMPTY { DB_TYPE_EMPTY, 0, NULL, 0, 0, 0, 0, 0, NULL }
db_value_t* db_value_new(void);
void db_value_free(db_value_t* value);
void db_value_reset(db_value_t* value);
int db_value_copy(db_value_t* value, const db_value_t* from_value);
int db_value_cmp(const db_value_t* value_a, const db_value_t* value_b, int* result);
db_type_t db_value_type(const db_value_t* value);
const db_type_int32_t* db_value_int32(const db_value_t* value);
const db_type_uint32_t* db_value_uint32(const db_value_t* value);
const db_type_int64_t* db_value_int64(const db_value_t* value);
const db_type_uint64_t* db_value_uint64(const db_value_t* value);
const char* db_value_text(const db_value_t* value);
int db_value_enum_value(const db_value_t* value, int* enum_value);
int db_value_not_empty(const db_value_t* value);
int db_value_to_int32(const db_value_t* value, db_type_int32_t* to_int32);
int db_value_to_uint32(const db_value_t* value, db_type_uint32_t* to_uint32);
int db_value_to_int64(const db_value_t* value, db_type_int64_t* to_int64);
int db_value_to_uint64(const db_value_t* value, db_type_uint64_t* to_uint64);
int db_value_to_text(const db_value_t* value, char** to_text);
int db_value_to_enum_value(const db_value_t* value, int* to_int, const db_enum_t* enum_set);
int db_value_from_int32(db_value_t* value, db_type_int32_t from_int32);
int db_value_from_uint32(db_value_t* value, db_type_uint32_t from_uint32);
int db_value_from_int64(db_value_t* value, db_type_int64_t from_int64);
int db_value_from_uint64(db_value_t* value, db_type_uint64_t from_uint64);
int db_value_from_text(db_value_t* value, const char* from_text);
int db_value_from_text2(db_value_t* value, const char* from_text, size_t size);
int db_value_from_enum_value(db_value_t* value, int enum_value, const db_enum_t* enum_set);
int db_value_set_primary_key(db_value_t* value);
struct db_value_set {
db_value_t* values;
size_t size;
};
db_value_set_t* db_value_set_new(size_t size);
db_value_set_t* db_value_set_new_copy(const db_value_set_t* from_value_set);
void db_value_set_free(db_value_set_t* value_set);
size_t db_value_set_size(const db_value_set_t* value_set);
const db_value_t* db_value_set_at(const db_value_set_t* value_set, size_t at);
db_value_t* db_value_set_get(db_value_set_t* value_set, size_t at);
#endif
db_value_enum_value
int db_value_enum_value(const db_value_t *value, int *enum_value)
Definition: db_value.c:332
db_value_free
void db_value_free(db_value_t *value)
Definition: db_value.c:51
db_value::text
char * text
Definition: db_value.h:51
db_type_int64_t
int64_t db_type_int64_t
Definition: db_type.h:46
db_type.h
db_value::int32
db_type_int32_t int32
Definition: db_value.h:52
db_value_set_get
db_value_t * db_value_set_get(db_value_set_t *value_set, size_t at)
Definition: db_value.c:756
db_value_to_int64
int db_value_to_int64(const db_value_t *value, db_type_int64_t *to_int64)
Definition: db_value.c:387
db_value_set_primary_key
int db_value_set_primary_key(db_value_t *value)
Definition: db_value.c:595
db_value_to_int32
int db_value_to_int32(const db_value_t *value, db_type_int32_t *to_int32)
Definition: db_value.c:357
db_enum.h
db_value_set_new_copy
db_value_set_t * db_value_set_new_copy(const db_value_set_t *from_value_set)
Definition: db_value.c:670
db_value_from_enum_value
int db_value_from_enum_value(db_value_t *value, int enum_value, const db_enum_t *enum_set)
Definition: db_value.c:572
db_value_to_text
int db_value_to_text(const db_value_t *value, char **to_text)
Definition: db_value.c:417
db_value_text
const char * db_value_text(const db_value_t *value)
Definition: db_value.c:321
db_value_to_enum_value
int db_value_to_enum_value(const db_value_t *value, int *to_int, const db_enum_t *enum_set)
Definition: db_value.c:438
db_value_set
Definition: db_value.h:281
db_value
Definition: db_value.h:48
db_value_to_uint32
int db_value_to_uint32(const db_value_t *value, db_type_uint32_t *to_uint32)
Definition: db_value.c:372
db_value_set_free
void db_value_set_free(db_value_set_t *value_set)
Definition: db_value.c:697
db_value_set_new
db_value_set_t * db_value_set_new(size_t size)
Definition: db_value.c:622
db_value_uint64
const db_type_uint64_t * db_value_uint64(const db_value_t *value)
Definition: db_value.c:310
db_value_new
db_value_t * db_value_new(void)
Definition: db_value.c:40
db_value_from_uint32
int db_value_from_uint32(db_value_t *value, db_type_uint32_t from_uint32)
Definition: db_value.c:492
db_value::uint32
db_type_uint32_t uint32
Definition: db_value.h:53
db_value_from_text2
int db_value_from_text2(db_value_t *value, const char *from_text, size_t size)
Definition: db_value.c:550
db_value_set::size
size_t size
Definition: db_value.h:283
db_value_to_uint64
int db_value_to_uint64(const db_value_t *value, db_type_uint64_t *to_uint64)
Definition: db_value.c:402
db_value_int64
const db_type_int64_t * db_value_int64(const db_value_t *value)
Definition: db_value.c:299
db_value_int32
const db_type_int32_t * db_value_int32(const db_value_t *value)
Definition: db_value.c:277
db_value_from_int32
int db_value_from_int32(db_value_t *value, db_type_int32_t from_int32)
Definition: db_value.c:479
db_value_set_size
size_t db_value_set_size(const db_value_set_t *value_set)
Definition: db_value.c:734
db_value_from_text
int db_value_from_text(db_value_t *value, const char *from_text)
Definition: db_value.c:531
db_value_from_uint64
int db_value_from_uint64(db_value_t *value, db_type_uint64_t from_uint64)
Definition: db_value.c:518
db_value::int64
db_type_int64_t int64
Definition: db_value.h:54
db_type_t
db_type_t
Definition: db_type.h:54
db_value_type
db_type_t db_value_type(const db_value_t *value)
Definition: db_value.c:269
db_type_int32_t
int32_t db_type_int32_t
Definition: db_type.h:38
db_value_reset
void db_value_reset(db_value_t *value)
Definition: db_value.c:60
db_value_from_int64
int db_value_from_int64(db_value_t *value, db_type_int64_t from_int64)
Definition: db_value.c:505
db_value::enum_value
int enum_value
Definition: db_value.h:56
db_enum
Definition: db_enum.h:38
db_value_uint32
const db_type_uint32_t * db_value_uint32(const db_value_t *value)
Definition: db_value.c:288
db_value::type
db_type_t type
Definition: db_value.h:49
db_value_not_empty
int db_value_not_empty(const db_value_t *value)
Definition: db_value.c:347
db_value_copy
int db_value_copy(db_value_t *value, const db_value_t *from_value)
Definition: db_value.c:77
db_value_set::values
db_value_t * values
Definition: db_value.h:282
db_value::uint64
db_type_uint64_t uint64
Definition: db_value.h:55
db_type_uint64_t
uint64_t db_type_uint64_t
Definition: db_type.h:50
db_value_cmp
int db_value_cmp(const db_value_t *value_a, const db_value_t *value_b, int *result)
Definition: db_value.c:102
db_value::primary_key
int primary_key
Definition: db_value.h:50
db_value::enum_text
const char * enum_text
Definition: db_value.h:57
db_type_uint32_t
uint32_t db_type_uint32_t
Definition: db_type.h:42
db_value_set_at
const db_value_t * db_value_set_at(const db_value_set_t *value_set, size_t at)
Definition: db_value.c:742