Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
1e01c905
Commit
1e01c905
authored
Aug 03, 2015
by
celinemercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
functions to get data type as a character string
parent
5f62cd85
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
5 deletions
+65
-5
python/obitools3/obidms/obidmscolumn/capidmscolumn.pxd
python/obitools3/obidms/obidmscolumn/capidmscolumn.pxd
+3
-1
python/obitools3/obidms/obidmscolumn/capidmscolumn.pyx
python/obitools3/obidms/obidmscolumn/capidmscolumn.pyx
+1
-1
src/obitypes.c
src/obitypes.c
+41
-1
src/obitypes.h
src/obitypes.h
+20
-2
No files found.
python/obitools3/obidms/obidmscolumn/capidmscolumn.pxd
View file @
1e01c905
...
...
@@ -12,6 +12,8 @@ cdef extern from "obitypes.h" nogil:
ctypedef
char
obichar_t
ctypedef
size_t
obiidx_t
char
*
name_data_type
(
int
data_type
)
cdef
extern
from
"obidmscolumn.h"
nogil
:
struct
OBIDMS_column_t
:
...
...
@@ -35,6 +37,6 @@ cdef extern from "obidmscolumn.h" nogil:
cdef
class
OBIDMS_column
:
cdef
OBIDMS_column_p
pointer
cdef
OBIDMS_p
dms
cdef
OBIType_t
data_type
cdef
str
data_type
# keep as OBIType_t? both?
cdef
str
dms_name
cdef
str
column_name
python/obitools3/obidms/obidmscolumn/capidmscolumn.pyx
View file @
1e01c905
...
...
@@ -14,7 +14,7 @@ cdef class OBIDMS_column:
dms_name_b
=
dms_name
.
encode
(
encoding
=
'UTF-8'
)
self
.
dms_name
=
dms_name
self
.
column_name
=
column_name
self
.
data_type
=
type
self
.
data_type
=
(
name_data_type
(
type
)).
decode
(
'UTF-8'
)
if
create
:
dms
=
obi_dms
(
dms_name_b
)
self
.
dms
=
dms
...
...
src/obitypes.c
View file @
1e01c905
...
...
@@ -5,7 +5,15 @@
* Author: coissac
*/
#include <obitypes.h>
#include <string.h>
#include "obitypes.h"
#include "obidebug.h"
#include "obierrno.h"
#define DEBUG_LEVEL 0
size_t
obi_sizeof
(
OBIType_t
type
)
...
...
@@ -53,3 +61,35 @@ size_t obi_array_sizeof(OBIType_t type, size_t nb_elements, size_t nb_elements_p
return
size
;
}
char
*
name_data_type
(
int
data_type
)
{
char
*
name
=
NULL
;
switch
(
data_type
)
{
case
OBI_VOID
:
name
=
strdup
(
"OBI_VOID"
);
break
;
case
OBI_INT
:
name
=
strdup
(
"OBI_INT"
);
break
;
case
OBI_FLOAT
:
name
=
strdup
(
"OBI_FLOAT"
);
break
;
case
OBI_CHAR
:
name
=
strdup
(
"OBI_CHAR"
);
break
;
case
OBI_IDX
:
name
=
strdup
(
"OBI_IDX"
);
break
;
}
if
(
name
==
NULL
)
obidebug
(
1
,
"Problem with the data type"
);
return
name
;
}
src/obitypes.h
View file @
1e01c905
...
...
@@ -17,10 +17,10 @@
#define OBIFloat_NA (NAN)
#define OBIIdx_NA (SIZE_MAX)
/**
* @brief enum for the boolean OBIType.
*/
typedef
enum
{
FALSE
=
0
,
TRUE
=
1
,
...
...
@@ -31,7 +31,6 @@ typedef enum {
/**
* @brief enum OBITypes for the data type of the OBIDMS columns.
*/
typedef
enum
OBIType
{
OBI_VOID
=
0
,
/**< data type not specified */
OBI_INT
,
/**< a signed integer value (C type : int32_t) */
...
...
@@ -40,11 +39,13 @@ typedef enum OBIType {
OBI_IDX
/**< an index in a data structure (C type : size_t) */
}
OBIType_t
,
*
OBIType_p
;
typedef
int32_t
obiint_t
;
typedef
double
obifloat_t
;
typedef
char
obichar_t
;
typedef
size_t
obiidx_t
;
/**
* @brief returns the memory size in bytes of an OBIType
*
...
...
@@ -58,6 +59,7 @@ typedef size_t obiidx_t;
*/
size_t
obi_sizeof
(
OBIType_t
type
);
/**
* @brief returns the size requested to store an array of OBIType
*
...
...
@@ -75,4 +77,20 @@ size_t obi_sizeof(OBIType_t type);
*/
size_t
obi_array_sizeof
(
OBIType_t
type
,
size_t
nbelements
,
size_t
nb_elements_per_line
);
/**
* @brief returns the name in the form of a character string of an OBIType
*
*
* @param data_type the OBIType code used as query
*
* @return the name of the OBIType
* @retval NULL on error (unknown type or error allocating the memory for the character string)
*
* @since August 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
char
*
name_data_type
(
int
data_type
);
#endif
/* OBITYPES_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment