全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 ページ
field.h
1 #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_FIELD_H
2 #define BZS_DB_PROTOCOL_TDAP_CLIENT_FIELD_H
3 /*=================================================================
4  Copyright (C) 2014 BizStation Corp All rights reserved.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20 =================================================================*/
21 #include "nsTable.h"
22 #include "fieldNameAlias.h"
23 
24 class CField; // atl interface
25 
26 namespace bzs
27 {
28 namespace rtl
29 {
30 class stringBuffer;
31 }
32 namespace db
33 {
34 namespace protocol
35 {
36 namespace tdap
37 {
38 namespace client
39 {
40 
41 class stringConverter;
42 /** @cond INTERNAL */
43 
44 /* non copyable */
45 class DLLLIB fieldShare
46 {
47  friend class field;
48  friend class table;
49  friend class recordCache;
50 
51 private:
52  struct Imple* m_imple;
53  struct
54  {
55  unsigned char myDateTimeValueByBtrv : 1;
56  unsigned char logicalToString : 1;
57  };
58  fieldShare(const fieldShare&); // no implememt
59  fieldShare& operator=(const fieldShare&); // no implememt
60 
61 protected:
62  fieldShare();
63 
64  virtual ~fieldShare();
65  stringConverter* cv() const;
66  bzs::rtl::stringBuffer* strBufs() const;
67  void blobPushBack(char* p);
68  void blobClear();
69  void blobResize(size_t size);
70 };
71 
72 /** @endcond */
73 
74 class DLLLIB fielddefs : public fieldShare
75 {
76  friend class table;
77  friend class recordsetImple;
78  friend class writableRecord;
79  friend class memoryRecord;
80  friend class recordsetQuery;
81  friend struct recordsetQueryImple;
82  friend class fieldsBase;
83  friend class fields;
84  friend class field;
85 
86  struct infoImple* m_imple;
87  void aliasing(fielddef* p) const;
88  fielddefs();
89  ~fielddefs();
90  fielddefs(const fielddefs& r);
91  fielddefs& operator=(const fielddefs& r);
92  bool mysqlnullEnable() const;
93  bool canUnion(const fielddefs& r) const;
94  size_t totalFieldLen() const;
95  void resetUpdateIndicator();
96  void setAliases(const aliasMap_type* p);
97  void push_back(const fielddef* p);
98  void calcFieldPos(int startIndex, bool mysqlNull);
99  void remove(int index);
100  void reserve(size_t size);
101 public:
102  void clear();
103  fielddefs* clone() const;
104  void addAliasName(int index, const _TCHAR* name);
105  int indexByName(const std::_tstring& name) const;
106  const fielddef& operator[](int index) const;
107  const fielddef& operator[](const _TCHAR* name) const;
108  const fielddef& operator[](const std::_tstring& name) const;
109  bool checkIndex(int index) const;
110  size_t size() const;
111  void addAllFields(const tabledef* def);
112  void addSelectedFields(const class table* tb);
113  void append(const fielddefs* fds);
114  void release();
115  static fielddefs* create();
116 };
117 
118 class DLLLIB field
119 {
120  friend class table;
121  friend class fieldsBase;
122  friend class CField; // atl interface
123  friend class memoryRecord; // nullPtr()
124  friend class recordsetQuery; //nullcomp
125  friend class recordsetImple; //offsetBlobPtr
126  friend struct logic; //isCompPartAndMakeValue
127  /** @cond INTERNAL */
128  friend int compBlob(const field& l, const field& r, char logType);
129  /** @endcond */
130  fielddef* m_fd;
131  unsigned char* m_ptr;
132  const class fielddefs* m_fds;
133  mutable unsigned char* m_cachedNullPtr;
134  mutable unsigned char m_nullbit;
135  unsigned char m_nullSign;
136 
137  void nullPtrCache() const;
138  int blobLenBytes() const { return m_fd->blobLenBytes(); }
139  __int64 readValue64() const;
140  void storeValue64(__int64 value);
141  double readValueDbl() const;
142  void storeValueDbl(double value);
143  void storeValueStrA(const char* data);
144  const char* readValueStrA() const;
145 #ifdef _WIN32
146  void storeValueStrW(const WCHAR* data);
147  const WCHAR* readValueStrW() const;
148 #endif
149  void storeValueNumeric(double data);
150  double readValueNumeric() const;
151  void storeValueDecimal(double data);
152  double readValueDecimal() const;
153  void* nullPtr() const;
154  int nullComp(const field& r, char log) const;
155  int nullComp(char log) const;
156  int nullCompMatch(const field& r, char log) const;
157  bool isCompPartAndMakeValue();
158  void offsetBlobPtr(size_t offset);
159 
160  // ---- bigin regacy interfaces ---- //
161  const char* getFVAstr() const;
162 #ifdef _WIN32
163  const wchar_t* getFVWstr() const;
164 #endif
165  __int64 getFV64() const;
166  double getFVdbl() const;
167  void* getFVbin(uint_td& size) const;
168  inline unsigned char getFVbyt() const { return (unsigned char)getFV64();}
169  inline short getFVsht() const { return (short)getFV64();}
170  inline int getFVint() const { return (int)getFV64();}
171  inline int getFVlng() const { return (int)getFV64();}
172  inline float getFVflt() const { return (float)getFVdbl();}
173 
174 #ifdef _WIN32
175  void setFVW(const wchar_t* data);
176 #endif
177  void setFV(double data);
178  void setFV(__int64 data);
179  void setFVA(const char* data);
180  void setFV(const void* data, uint_td size);
181 #ifdef _UNICODE
182  inline const wchar_t* getFVstr() const { return getFVWstr(); };
183  inline void setFV(const wchar_t* data) { setFVW(data); };
184  inline void setFV(const std::wstring& p) { setFVW(p.c_str()); }
185 #else
186  inline const char* getFVstr() const { return getFVAstr(); };
187 #endif
188  inline void setFV(const char* data) { setFVA(data); };
189  inline void setFV(float data){ setFV((double)data); }
190  inline void setFV(unsigned char data) { setFV((__int64)data); }
191  inline void setFV(short data) { setFV((__int64)data); }
192  inline void setFV(int data) { setFV((__int64)data); }
193  inline void setFV(const std::string& p) { setFVA(p.c_str()); };
194  inline void setFV(const bitset& v) { setFV(v.internalValue()); };
195 
196  // ---- end regacy interfaces ---- //
197 
198 /** @cond INTERNAL */
199 #if defined(SWIG) || \
200  defined(SWIG_BUILDING) // SWIG Wrapper need public constructor
201 public:
202 #endif
203  inline field() : m_fd(NULL), m_ptr(NULL), m_fds(NULL){};
204 /** @endcond */
205 
206 public:
207 /** @cond INTERNAL */
208  // nullPtr and nullbit is all field same.
209  inline field(unsigned char* ptr, const fielddef& fd, const fielddefs* fds,
210  bool nullField = false)
211  : m_fd((fielddef*)&fd), m_ptr(ptr), m_fds(fds), m_cachedNullPtr(NULL), m_nullbit(0)
212  {
213  if (nullField)
214  {
215  m_cachedNullPtr = (unsigned char*)&m_nullSign;
216  m_nullSign = 0xff;
217  m_nullbit = 1;
218  }
219  }
220 /** @endcond */
221 
222  /* swig using copy constructor */
223  inline field(const field& r) : m_fd(r.m_fd), m_ptr(r.m_ptr), m_fds(r.m_fds),
224  m_cachedNullPtr(NULL),m_nullbit(r.m_nullbit), m_nullSign(r.m_nullSign)
225  {
226  if (r.m_cachedNullPtr == (unsigned char*)&r.m_nullSign)
227  m_cachedNullPtr = (unsigned char*)&m_nullSign;
228  }
229 
230  inline field& operator=(const field& r)
231  {
232  m_fd = r.m_fd;
233  m_ptr = r.m_ptr;
234  m_fds = r.m_fds;
235  m_nullSign = r.m_nullSign;
236  m_nullbit = r.m_nullbit;
237  if (r.m_cachedNullPtr == (unsigned char*)&r.m_nullSign)
238  m_cachedNullPtr = (unsigned char*)&m_nullSign;
239  else
240  m_cachedNullPtr = NULL;
241  return *this;
242  }
243 
244  void* ptr() const;
245 
246  inline const fielddef* def() const {return m_fd;}
247 
248  inline unsigned char type() const { return m_fd->type; }
249 
250  inline unsigned short len() const { return m_fd->len; }
251 
252  inline const _TCHAR* c_str() const { return getFVstr(); }
253 
254  inline const char* a_str() const { return getFVAstr(); }
255 
256  inline int i() const { return getFVint(); }
257 
258  inline int i8() const { return getFVbyt(); }
259 
260  inline short i16() const { return getFVsht(); }
261 
262  inline __int64 i64() const { return getFV64(); }
263 
264  inline float f() const { return getFVflt(); }
265 
266  inline double d() const { return getFVdbl(); }
267 
268  bool isNull() const;
269 
270  void setNull(bool v);
271 
272  template <class T>
273  inline field& operator=(const T c)
274  {
275  setFV(c);
276  m_fd->enableFlags.bitE = true;
277  return *this;
278  }
279 
280  inline bool operator!=(const _TCHAR* p) const { return !operator==(p); }
281 
282  inline bool operator==(const _TCHAR* p) const
283  {
284  return (isNull() == false) && (_tcscmp(p, c_str()) == 0);
285  }
286 
287  inline bool operator!=(int v) const { return !operator==(v); }
288  inline bool operator==(int v) const { return (isNull() == false) && (v == i()); }
289 
290  inline bool operator!=(short v) const { return !operator==(v); }
291  inline bool operator==(short v) const { return (isNull() == false) && (v == i16()); }
292 
293  inline bool operator!=(__int64 v) const { return !operator==(v); }
294  inline bool operator==(__int64 v) const { return (isNull() == false) && (v == i64()); }
295 
296  inline bool operator!=(float v) const { return !operator==(v); }
297  inline bool operator==(float v) const { return (isNull() == false) && (v == f()); }
298 
299  inline bool operator!=(double v) const { return !operator==(v); }
300  inline bool operator==(double v) const { return (isNull() == false) && (v == d()); }
301 
302  inline void setBin(const void* data, uint_td size)
303  {
304  setFV(data, size);
305  m_fd->enableFlags.bitE = true;
306  }
307  inline void* getBin(uint_td& size) const { return getFVbin(size); };
308 
309  inline bitset getBits() const { return bitset(i64());}
310 
311  int comp(const field& r, char logType = CMPLOGICAL_VAR_COMP_ALL) const;
312 };
313 
314 
315 /** @cond INTERNAL */
316 #ifndef SWIG
317 /* For template tget type num by type.*/
318 
319 inline int getFieldType(int)
320 {
321  return ft_integer;
322 }
323 
324 inline int getFieldType(__int64)
325 {
326  return ft_integer;
327 }
328 
329 inline int getFieldType(short)
330 {
331  return ft_integer;
332 }
333 
334 inline int getFieldType(char)
335 {
336  return ft_integer;
337 }
338 
339 inline int getFieldType(double)
340 {
341  return ft_float;
342 }
343 
344 inline int getFieldType(float)
345 {
346  return ft_float;
347 }
348 
349 inline __int64 fieldValue(const field& fd, __int64)
350 {
351  return fd.i64();
352 }
353 
354 inline int fieldValue(const field& fd, int)
355 {
356  return fd.i();
357 }
358 
359 inline short fieldValue(const field& fd, short)
360 {
361  return (short)fd.i();
362 }
363 
364 inline char fieldValue(const field& fd, char)
365 {
366  return (char)fd.i();
367 }
368 
369 inline double fieldValue(const field& fd, double)
370 {
371  return fd.d();
372 }
373 
374 inline float fieldValue(const field& fd, float)
375 {
376  return fd.f();
377 }
378 
379 inline const _TCHAR* fieldValue(const field& fd, const _TCHAR*)
380 {
381  return fd.c_str();
382 }
383 
384 DLLLIB const fielddef& dummyFd();
385 
386 #endif // ndef SWIG
387 /** @endcond */
388 
389 } // namespace client
390 } // namespace tdap
391 } // namespace protocol
392 } // namespace db
393 } // namespace bzs
394 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_FIELD_H
bool operator!=(double v) const
Definition: field.h:299
bool operator!=(__int64 v) const
Definition: field.h:293
field & operator=(const T c)
Definition: field.h:273
field(const field &r)
Definition: field.h:223
const _TCHAR * c_str() const
Definition: field.h:252
bool operator==(float v) const
Definition: field.h:297
bool operator==(int v) const
Definition: field.h:288
bool operator==(const _TCHAR *p) const
Definition: field.h:282
bool operator==(__int64 v) const
Definition: field.h:294
__int64 i64() const
Definition: field.h:262
フィールド定義構造体
Definition: tdapSchema.h:419
unsigned short len() const
Definition: field.h:250
フィールドコレクションクラス
Definition: fields.h:256
bool operator!=(int v) const
Definition: field.h:287
float f() const
Definition: field.h:264
const char * a_str() const
Definition: field.h:254
short i16() const
Definition: field.h:260
bool operator==(short v) const
Definition: field.h:291
void setBin(const void *data, uint_td size)
Definition: field.h:302
テーブルアクセスクラス (nocopyable)
Definition: table.h:91
int i8() const
Definition: field.h:258
bool operator!=(const _TCHAR *p) const
Definition: field.h:280
fielddef のコレクションクラス
Definition: field.h:74
int i() const
Definition: field.h:256
bitset getBits() const
Definition: field.h:309
recordset フィルタリングクエリー
Definition: groupQuery.h:107
フィールドコレクションのベースクラス
Definition: fields.h:123
const fielddef * def() const
Definition: field.h:246
bool operator!=(short v) const
Definition: field.h:290
bool operator!=(float v) const
Definition: field.h:296
unsigned char type() const
Definition: field.h:248
bool operator==(double v) const
Definition: field.h:300
書き込み可能な行のクラスです。
Definition: memRecord.h:170
ビット集合アクセスクラス
Definition: tdapSchema.h:294
double d() const
Definition: field.h:266
field & operator=(const field &r)
Definition: field.h:230
const _TCHAR * c_str(const btrDate &d)
Definition: btrDate.h:232
rowの実装クラス
Definition: memRecord.h:69
テーブル定義構造体
Definition: tdapSchema.h:1051
void * getBin(uint_td &size) const
Definition: field.h:307
フィールドアクセスクラス
Definition: field.h:118

Transactd SDK 2018年07月31日(火) 19時40分21秒 doxygen