Free Electron
assertCore.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __core_assertCore_h__
8 #define __core_assertCore_h__
9 
10 namespace fe
11 {
12 
13 FE_DL_EXPORT void assertCore(sp<TypeMaster> spTypeMaster);
14 
15 template <class T>
16 class FE_DL_EXPORT TypeInfoInteger : public BaseType::Info
17 {
18  public:
19 
20 virtual String print(void *instance)
21  {
22  T value= *(T *)instance;
23  String string;
24  string.sPrintf("%d",value);
25  return string;
26  }
27 
28 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode)
29  {
30  if(mode == e_binary)
31  {
32  T value = *(T *)instance;
33  ostrm.write((char *)&value, sizeof(T));
34  return sizeof(T);
35  }
36  else
37  {
38  T value= *(T *)instance;
39  ostrm << std::dec << value;
40  return c_ascii;
41  }
42  }
43 
44 virtual void input(std::istream &istrm, void *instance, t_serialMode mode)
45  {
46  T value;
47  if(mode == e_binary)
48  {
49  istrm.read((char *)&value, sizeof(T));
50  *(T *)instance = value;
51  }
52  else
53  {
54  istrm >> value;
55  *(T *)instance = value;
56  }
57  }
58 
59 virtual void construct(void *instance) { *(T *)instance=0; }
60 
61 virtual IWORD iosize(void) { return sizeof(T); }
62 };
63 
64 class FE_DL_EXPORT InfoU8 : public TypeInfoInteger<U8>
65 {
66  public:
67 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
68 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
69 };
70 
71 class FE_DL_EXPORT InfoU16 : public TypeInfoInteger<U16>
72 {
73  public:
74 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
75 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
76 };
77 
78 class FE_DL_EXPORT InfoI16 : public TypeInfoInteger<I16>
79 {
80  public:
81 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
82 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
83 };
84 
85 class FE_DL_EXPORT InfoU32 : public TypeInfoInteger<U32>
86 {
87  public:
88 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
89 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
90 };
91 
92 class FE_DL_EXPORT InfoI32 : public TypeInfoInteger<I32>
93 {
94  public:
95 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
96 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
97 };
98 
99 class FE_DL_EXPORT InfoU64 : public TypeInfoInteger<U64>
100 {
101  public:
102 virtual String print(void *instance);
103 };
104 
105 class FE_DL_EXPORT InfoI64 : public TypeInfoInteger<I64>
106 {
107  public:
108 virtual String print(void *instance);
109 };
110 
111 class FE_DL_EXPORT InfoIWORD : public TypeInfoInteger<IWORD>
112 {
113  public:
114 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
115 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
116 };
117 
118 class FE_DL_EXPORT InfoF32 : public BaseType::Info
119 {
120  public:
121 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
122 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
123 virtual String print(void *instance);
124 virtual void construct(void *instance);
125 virtual IWORD iosize(void);
126 };
127 
128 class FE_DL_EXPORT InfoF64 : public BaseType::Info
129 {
130  public:
131 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
132 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
133 virtual String print(void *instance);
134 virtual void construct(void *instance);
135 virtual IWORD iosize(void);
136 };
137 
138 class FE_DL_EXPORT InfoBool : public BaseType::Info
139 {
140  public:
141 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
142 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
143 virtual String print(void *instance);
144 virtual void construct(void *instance);
145 virtual IWORD iosize(void);
146 };
147 
148 class FE_DL_EXPORT InfoVoid : public BaseType::Info
149 {
150  public:
151 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
152 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
153 virtual String print(void *instance);
154 virtual void construct(void *instance);
155 virtual IWORD iosize(void);
156 };
157 
158 class FE_DL_EXPORT InfoVoidStar : public BaseType::Info
159 {
160  public:
161 virtual IWORD output(std::ostream &ostrm, void *instance, t_serialMode mode);
162 virtual void input(std::istream &istrm, void *instance, t_serialMode mode);
163 virtual String print(void *instance);
164 virtual void construct(void *instance);
165 virtual IWORD iosize(void);
166 };
167 
168 
169 } /* namespace */
170 
171 #endif /* __core_assertCore_h__ */
kernel
Definition: namespace.dox:3