/usr/include/tjutils/tjtypes.h is in libodin-dev 1.8.8-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | /***************************************************************************
tjtypes.h - description
-------------------
begin : Thu Jul 24 2001
copyright : (C) 2000-2014 by Thies H. Jochimsen
email : thies@jochimsen.de
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TJTYPES_H
#define TJTYPES_H
#include <tjutils/tjutils.h>
#include <tjutils/tjcomplex.h>
/**
* @addtogroup tjutils
* @{
*/
// Get appropriate data types for signed/unsigned 8, 16 and 32 bit data on this platform
#if SIZEOF_CHAR == 1
typedef char s8bit;
typedef unsigned char u8bit;
#else
#error "sizeof(char)!=1"
#endif
#if SIZEOF_SHORT == 2
typedef short s16bit;
typedef unsigned short u16bit;
#else
#error "sizeof(short)!=2"
#endif
#if SIZEOF_INT == 4
typedef int s32bit;
typedef unsigned int u32bit;
#else
#if SIZEOF_LONG == 4
typedef long s32bit;
typedef unsigned long u32bit;
#else
#error "sizeof(int)!=4 and sizeof(long)!=4"
#endif
#endif
/**
* Class to manage string conversions and properties of
* simple (i.e. atomic) types. To be used in higher level
* template classes to dispatch functionality according
* to type.
*/
class TypeTraits {
public:
// Convert a type's value to a string
static STD_string type2string(s8bit v) {return itos(v);}
static STD_string type2string(u8bit v) {return itos(v);}
static STD_string type2string(s16bit v) {return itos(v);}
static STD_string type2string(u16bit v) {return itos(v);}
static STD_string type2string(s32bit v) {return itos(v);}
static STD_string type2string(u32bit v) {return itos(v);}
static STD_string type2string(float v) {return ftos(v);}
static STD_string type2string(double v) {return ftos(float(v));}
static STD_string type2string(const STD_complex& v) {return ctos(v);}
static STD_string type2string(const STD_string& v) {return v;}
// Parses type's value from string
static void string2type(const STD_string& s, s8bit& v) {v=(s8bit)atoi(s.c_str());}
static void string2type(const STD_string& s, u8bit& v) {v=(u8bit)atoi(s.c_str());}
static void string2type(const STD_string& s, s16bit& v) {v=(s16bit)atoi(s.c_str());}
static void string2type(const STD_string& s, u16bit& v) {v=(u16bit)atoi(s.c_str());}
static void string2type(const STD_string& s, s32bit& v) {v=(s32bit)atoi(s.c_str());}
static void string2type(const STD_string& s, u32bit& v) {v=(u32bit)atoi(s.c_str());}
static void string2type(const STD_string& s, float& v) {v=(float)atof(s.c_str());}
static void string2type(const STD_string& s, double& v) {v=atof(s.c_str());}
static void string2type(const STD_string& s, STD_complex& v) {v=stoc(s);}
static void string2type(const STD_string& s, STD_string& v) {v=s;}
// Type label (identifier) as string
static const char* type2label(s8bit) {return "s8bit";}
static const char* type2label(u8bit) {return "u8bit";}
static const char* type2label(s16bit) {return "s16bit";}
static const char* type2label(u16bit) {return "u16bit";}
static const char* type2label(s32bit) {return "s32bit";}
static const char* type2label(u32bit) {return "u32bit";}
static const char* type2label(float) {return "float";}
static const char* type2label(double) {return "double";}
static const char* type2label(const STD_complex&) {return "complex";}
static const char* type2label(const STD_string&) {return "string";}
/**
* Returns size of data type
*/
static unsigned int typesize(const STD_string& typelabel);
};
/** @}
*/
#endif
|