PVData C++  8.0.2
pvType.h
1 /* pvType.h */
2 /*
3  * Copyright information and license terms for this software can be
4  * found in the file LICENSE that is included with the distribution
5  */
6 /**
7  * @author mrk
8  */
9 
10 /* Definitions for the primitive types for pvData.
11  * It also defines the arrays of the primitive types
12  */
13 
14 #ifndef PVTYPE_H
15 #define PVTYPE_H
16 
17 #if defined(_WIN32) && !defined(_MINGW)
18 #pragma warning( push )
19 #pragma warning(disable: 4251)
20 #endif
21 
22 #include <string>
23 #include <vector>
24 
25 #if defined(vxWorks) &&
26  (_WRS_VXWORKS_MAJOR+0 <= 6) && (_WRS_VXWORKS_MINOR+0 < 9)
27 typedef int intptr_t;
28 typedef unsigned int uintptr_t;
29 #ifndef INT64_MAX
30 #define INT64_MAX (0x7fffffffffffffffLL)
31 #define UINT64_MAX (0xffffffffffffffffULL)
32 #endif
33 #elif _MSC_VER==1500
34 #include <epicsTypes.h>
35 typedef epicsUInt8 uint8_t;
36 typedef epicsInt8 int8_t;
37 typedef epicsUInt16 uint16_t;
38 typedef epicsInt16 int16_t;
39 typedef epicsUInt32 uint32_t;
40 typedef epicsInt32 int32_t;
41 typedef epicsUInt64 uint64_t;
42 typedef epicsInt64 int64_t;
43 #else
44 #include <stdint.h>
45 #endif
46 
47 #include <pv/sharedPtr.h>
48 
49 //! epics
50 namespace epics {
51 //! pvData
52 namespace pvData {
53 
54 namespace detail {
55  // Pick either type If or type Else to not be Cond
56  template<typename Cond, typename If, typename Else>
57  struct pick_type { typedef If type; };
58  template<typename Cond, typename Else>
59  struct pick_type<Cond,Cond,Else> { typedef Else type; };
60 }
61 
62 /**
63  * This is a set of typedefs used by pvData.
64  */
65 
66 /**
67  * boolean, i.e. can only have the values @c false or @c true
68  */
69 typedef detail::pick_type<int8_t, signed char,
70  detail::pick_type<uint8_t, char, unsigned char>::type
71  >::type boolean;
72 /**
73  * A 8 bit signed integer
74  */
75 typedef int8_t int8;
76 /**
77  * A 16 bit signed integer
78  */
79 typedef int16_t int16;
80 /**
81  * A 32 bit signed integer
82  */
83 typedef int32_t int32;
84 /**
85  * A 64 bit signed integer
86  */
87 typedef int64_t int64;
88 /**
89  * A 8 bit unsigned integer
90  */
91 typedef uint8_t uint8;
92 /**
93  * A 16 bit unsigned integer
94  */
95 typedef uint16_t uint16;
96 /**
97  * A 32 bit unsigned integer
98  */
99 typedef uint32_t uint32;
100 /**
101  * A 64 bit unsigned integer
102  */
103 typedef uint64_t uint64;
104 
105 // float and double are types
106 
107 /**
108  * A string array.
109  */
111 typedef std::tr1::shared_ptr<StringArray> StringArrayPtr;
112 inline std::string * get(StringArray &value)
113 {
114  return &value[0];
115 }
116 inline std::string const * get(StringArray const &value)
117 {
118  return static_cast<std::string const *>(&value[0]);
119 }
120 inline std::string * get(StringArrayPtr &value)
121 {
122  return get(*value.get());
123 }
124 inline std::string const * get(StringArrayPtr const &value)
125 {
126  return get(*value.get());
127 }
128 inline StringArray & getVector(StringArrayPtr &value)
129 {
130  return *value.get();
131 }
132 inline StringArray const & getVector(StringArrayPtr const &value)
133 {
134  return *value.get();
135 }
136 typedef std::vector<std::string>::iterator StringArray_iterator;
137 typedef std::vector<std::string>::const_iterator StringArray_const_iterator;
138 
139 }}
140 
141 #if defined(_WIN32) && !defined(_MINGW)
142 #pragma warning( pop )
143 #endif
144 
145 #endif /* PVTYPE_H */
uint32_t uint32
Definition: pvType.h:99
std::vector< std::string > StringArray
Definition: pvType.h:110
uint8_t uint8
Definition: pvType.h:91
int16_t int16
Definition: pvType.h:79
virtual void serialize(ByteBuffer *buffer, SerializableControl *flusher, std::size_t offset, std::size_t count) const =0
int64_t int64
Definition: pvType.h:87
int32_t int32
Definition: pvType.h:83
uint16_t uint16
Definition: pvType.h:95
int8_t int8
Definition: pvType.h:75
uint64_t uint64
Definition: pvType.h:103