|
funkalicious 0.1
|
#include <glib-2.0/glib.h>
Include dependency graph for binary_data_common.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | dotcode_data |
| struct | dotcode_array |
| struct | dotcode_vector |
| struct | dotcode_tensor |
| struct | dotcode_grid |
Defines | |
| #define | DOTCODE_INT_SIZE 4 |
| #define | DOTCODE_FLOAT4_SIZE 4 |
| #define | DOTCODE_FLOAT8_SIZE 8 |
Enumerations | |
| enum | dotcode_type { DOTCODE_INVALID_TYPE = -1, DOTCODE_FLOAT8, DOTCODE_FLOAT4, DOTCODE_INT, DOTCODE_SSTRING, DOTCODE_VECTOR, DOTCODE_ARRAY, DOTCODE_TENSOR, DOTCODE_GRID } |
Functions | |
| enum dotcode_type | dotcode_type_from_string (const char *s) |
| char * | dotcode_string_from_type (enum dotcode_type t) |
| const char * | dotcode_string_from_type2 (enum dotcode_type t) |
| void | flip_endian (char *buffer, int bytes) |
| int | dotcode_get_tensor_index (const struct dotcode_tensor, unsigned int *index) |
| void | dotcode_free_type (enum dotcode_type t, void *ptr, long unsigned int count, GError **err, gboolean free_struct) |
| void | dotcode_determine_templated_type (const char *str, GList **tlist, GError **err) |
| #define DOTCODE_FLOAT4_SIZE 4 |
Definition at line 37 of file binary_data_common.h.
Referenced by dotcode_read_float4(), and dotcode_write_float4().
| #define DOTCODE_FLOAT8_SIZE 8 |
Definition at line 38 of file binary_data_common.h.
Referenced by dotcode_read_float8(), and dotcode_write_float8().
| #define DOTCODE_INT_SIZE 4 |
Definition at line 36 of file binary_data_common.h.
Referenced by dotcode_read_int(), and dotcode_write_int().
| enum dotcode_type |
| DOTCODE_INVALID_TYPE | |
| DOTCODE_FLOAT8 | |
| DOTCODE_FLOAT4 | |
| DOTCODE_INT | |
| DOTCODE_SSTRING | |
| DOTCODE_VECTOR | |
| DOTCODE_ARRAY | |
| DOTCODE_TENSOR | |
| DOTCODE_GRID |
Definition at line 40 of file binary_data_common.h.
| void dotcode_determine_templated_type | ( | const char * | str, |
| GList ** | tlist, | ||
| GError ** | err | ||
| ) |
Appends the type containers in str into a GList of
| str | string containing type template. |
| tlist | a pointer to a NULL-initialized GList pointer. |
| err | pointer to a NULL-initialized error pointer. |
This is the front-end to the determine_templated_type_ function.
| str | is the list |
| tlist | a pointer to an *existing* GList*, which will be set to NULL. |
| err | is a pointer to an existing NULL GError* |
Definition at line 226 of file binary_data_common.c.
References determine_templated_type_().
Referenced by dotcode_read_tensor(), and read_dotcode_generic_file().
{
*tlist = NULL;
/*Remove invalid chars; valid are alphanumeric, underscoe, and >; this will
remove '>', but that's fine; we don't really want it.
*/
char* dstr = g_strdup(str);
g_strcanon(dstr, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_<", ' ');
g_strchug(dstr);
char** sstr = g_strsplit(dstr, "<", 2);
determine_templated_type_(sstr[0], sstr[1], tlist, err);
g_free(dstr);
g_strfreev(sstr);
}
Here is the call graph for this function:
Here is the caller graph for this function:| void dotcode_free_type | ( | enum dotcode_type | t, |
| void * | ptr, | ||
| long unsigned int | count, | ||
| GError ** | err, | ||
| gboolean | free_struct | ||
| ) |
Definition at line 102 of file binary_data_common.c.
References dotcode_tensor::data, DOTCODE_ARRAY, DOTCODE_BINARY_DATA_COMMON_GERROR_DOMAN, DOTCODE_FLOAT4, DOTCODE_FLOAT8, dotcode_free_type(), DOTCODE_GRID, DOTCODE_INT, DOTCODE_SSTRING, dotcode_string_from_type2(), DOTCODE_TENSOR, DOTCODE_VECTOR, e, dotcode_tensor::indices, and dotcode_tensor::metadata.
Referenced by dotcode_free_type(), dotcode_grid_from_density(), dotcode_internal_read_gridspec(), dotcode_read_grid(), libdotcode_readwrite_suite_add_tests(), main(), read_dotcode_generic_file(), read_dotcode_typed_file(), and read_random_10x10x10_float8_grid().
{
GError *e = NULL;
/*If we have a buffer of a simple type, just free it.*/
switch(t) {
case DOTCODE_FLOAT8:
case DOTCODE_FLOAT4:
case DOTCODE_INT:
case DOTCODE_SSTRING:
free(ptr);
return;
default:
break;
}
long unsigned int size = 1;
for(long unsigned int i=0; i<count; i++) {
/*Since these are freeing an array of actual structures (as
opposed to an array of pointers to structures) we don't need to
free the struct at the end.*/
switch(t) {
case DOTCODE_VECTOR:
dotcode_free_type(((struct dotcode_vector*)ptr)->t,
((struct dotcode_vector*)ptr)->data,
3,
&e,
FALSE);
break;
case DOTCODE_ARRAY:
dotcode_free_type(((struct dotcode_array*)ptr)->t,
((struct dotcode_array*)ptr)->storage,
(((struct dotcode_array*)ptr)->imax - ((struct dotcode_array*)ptr)->imax +1),
&e,
FALSE);
break;
case DOTCODE_TENSOR:
/*need to know how many items there are, for the derived types
(irrelevant for float, int)*/
size = 1;
for(long unsigned int j=0; j<((struct dotcode_tensor*)ptr)->Nd; j++)
size*=((((struct dotcode_tensor*)ptr)->indices)[2*j+1]-(((struct dotcode_tensor*)ptr)->indices)[2*j]+1);
/*need to know how many items there are*/
dotcode_free_type(((struct dotcode_tensor*)ptr)->t,
((struct dotcode_tensor*)ptr)->data,
size,
&e,
FALSE);
free(((struct dotcode_tensor*)ptr)->indices);
free(((struct dotcode_tensor*)ptr)->metadata);
break;
case DOTCODE_GRID:
for(int i=0; i<3; i++) {
dotcode_free_type(DOTCODE_ARRAY,
((struct dotcode_grid*)ptr)->gridsites[i],
1,
&e,
TRUE);
}
dotcode_free_type(DOTCODE_TENSOR,
((struct dotcode_grid*)ptr)->data,
1,
&e,
TRUE);
break;
default:
*err = g_error_new(DOTCODE_BINARY_DATA_COMMON_GERROR_DOMAN, 1, "dotcode::binary_data_common::dotcode_free_type: Invalid type %d (%s)", t, dotcode_string_from_type2(t));
return;
}
if(e != NULL) {
g_propagate_prefixed_error(err, e, "dotcode::binary_data_common::dotcode_free_type: Failure when freeing type %d (%s)", t, dotcode_string_from_type2(t));
return;
}
}
if(free_struct) {
switch(t) {
case DOTCODE_VECTOR:
free((struct dotcode_vector*)ptr);
break;
case DOTCODE_ARRAY:
free((struct dotcode_array*)ptr);
break;
case DOTCODE_TENSOR:
free((struct dotcode_tensor*)ptr);
break;
case DOTCODE_GRID:
free((struct dotcode_grid*)ptr);
break;
default:
break;
}
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| int dotcode_get_tensor_index | ( | const struct dotcode_tensor | , |
| unsigned int * | index | ||
| ) |
| char* dotcode_string_from_type | ( | enum dotcode_type | t | ) |
Definition at line 58 of file binary_data_common.c.
References dotcode_string_from_type2().
Referenced by dotcode_write_array(), dotcode_write_tensor(), and main().
{
const char* s = dotcode_string_from_type2(t);
if(s == NULL) return NULL;
return g_strdup(s);
}
Here is the call graph for this function:
Here is the caller graph for this function:| const char* dotcode_string_from_type2 | ( | enum dotcode_type | t | ) |
This one is nice for using for one-off situations, e.g. error strings
Definition at line 64 of file binary_data_common.c.
References DOTCODE_ARRAY, DOTCODE_FLOAT4, DOTCODE_FLOAT8, DOTCODE_GRID, DOTCODE_INT, DOTCODE_INVALID_TYPE, DOTCODE_SSTRING, DOTCODE_TENSOR, and DOTCODE_VECTOR.
Referenced by dotcode_free_type(), dotcode_read_generic(), dotcode_read_tensor(), dotcode_string_from_type(), dotcode_write_array(), dotcode_write_float4(), dotcode_write_float8(), dotcode_write_generic(), dotcode_write_grid(), dotcode_write_int(), dotcode_write_sstring(), dotcode_write_tensor(), dotcode_write_typed_file(), main(), read_dotcode_generic_file(), and read_dotcode_typed_file().
{
switch(t) {
case DOTCODE_FLOAT8:
return g_strdup("float8");
case DOTCODE_FLOAT4:
return g_strdup("float4");
case DOTCODE_INT:
return g_strdup("int4");
case DOTCODE_VECTOR:
return g_strdup("Vector");
case DOTCODE_ARRAY:
return g_strdup("Array");
case DOTCODE_TENSOR:
return g_strdup("Tensor");
case DOTCODE_GRID:
return g_strdup("Grid");
case DOTCODE_SSTRING:
return g_strdup("SString");
case DOTCODE_INVALID_TYPE:
return g_strdup("INVALID TYPE");
default:
return NULL;
}
return NULL;
}
Here is the caller graph for this function:| enum dotcode_type dotcode_type_from_string | ( | const char * | s | ) |
Definition at line 35 of file binary_data_common.c.
References DOTCODE_ARRAY, DOTCODE_FLOAT4, DOTCODE_FLOAT8, DOTCODE_GRID, DOTCODE_INT, DOTCODE_INVALID_TYPE, DOTCODE_SSTRING, DOTCODE_TENSOR, and DOTCODE_VECTOR.
Referenced by determine_templated_type_().
{
if(!g_ascii_strncasecmp(s, "float8", strlen("float8"))){
return DOTCODE_FLOAT8;
}else if(!g_ascii_strncasecmp(s, "float4", strlen("float4"))){
return DOTCODE_FLOAT4;
}else if(!g_ascii_strncasecmp(s, "int", strlen("int"))){
return DOTCODE_INT;
}else if(!g_ascii_strncasecmp(s, "int4", strlen("int4"))){
return DOTCODE_INT;
}else if(!g_ascii_strncasecmp(s, "Vector", strlen("Vector"))){
return DOTCODE_VECTOR;
}else if(!g_ascii_strncasecmp(s, "Array", strlen("Array"))){
return DOTCODE_ARRAY;
}else if(!g_ascii_strncasecmp(s, "Tensor", strlen("Tensor"))){
return DOTCODE_TENSOR;
}else if(!g_ascii_strncasecmp(s, "Grid", strlen("Grid"))){
return DOTCODE_GRID;
}else if(!g_ascii_strncasecmp(s, "SString", strlen("SString"))){
return DOTCODE_SSTRING;
}
return DOTCODE_INVALID_TYPE;
}
Here is the caller graph for this function:| void flip_endian | ( | char * | buffer, |
| int | bytes | ||
| ) |
Definition at line 90 of file binary_data_common.c.
References c.
Referenced by dotcode_read_float4(), dotcode_read_float8(), and dotcode_read_int().
{
int i, j;
char c;
int max = num_bytes >> 1;
for(i=0, j=(num_bytes-1); i<max; ++i, --j) {
c=buffer[i];
buffer[i]=buffer[j];
buffer[j]=c;
}
}
Here is the caller graph for this function: