全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド ページ
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 };
70 
71 /** @endcond */
72 
73 class DLLLIB fielddefs : public fieldShare
74 {
75  struct infoImple* m_imple;
76  void aliasing(fielddef* p) const;
77  fielddefs();
78  ~fielddefs();
79  fielddefs(const fielddefs& r);
80  fielddefs& operator=(const fielddefs& r);
81  friend class table;
82  friend class recordsetImple;
83  friend class writableRecord;
84  friend class memoryRecord;
85  friend class recordsetQuery;
86  friend struct recordsetQueryImple;
87  friend class fieldsBase;
88 public:
89  void addAllFileds(tabledef* def);
90 protected:
91  void copyFrom(const class table* tb);
92  bool canUnion(const fielddefs& r) const;
93  size_t totalFieldLen() const;
94  void resetUpdateIndicator();
95  void setAliases(const aliasMap_type* p);
96  void push_back(const fielddef* p, bool rePosition = false);
97  void remove(int index);
98  void reserve(size_t size);
99 public:
100  void clear();
101 
102 public:
103  fielddefs* clone() const;
104  int indexByName(const std::_tstring& name) const;
105  const fielddef& operator[](int index) const;
106  const fielddef& operator[](const _TCHAR* name) const;
107  const fielddef& operator[](const std::_tstring& name) const;
108  bool checkIndex(int index) const;
109  size_t size() const;
110  void release();
111  static fielddefs* create();
112 };
113 
114 /** @cond INTERNAL */
115 
116 typedef int (*compFieldFunc)(const class field& l, const class field& r,
117  char logType);
118 extern int compWString(const field& l, const field& r, char logType);
119 extern int compiWString(const field& l, const field& r, char logType);
120 
121 /** @endcond */
122 
123 class DLLLIB field
124 {
125  friend class table;
126  friend class fieldsBase;
127  friend class CField; // atl interface
128  /** @cond INTERNAL */
129  friend int compBlob(const field& l, const field& r, char logType);
130  /** @endcond */
131  fielddef* m_fd;
132  unsigned char* m_ptr;
133  const class fielddefs* m_fds;
134 
135  int blobLenBytes() const { return m_fd->blobLenBytes(); }
136 
137 private:
138  // ---- bigin regacy interfaces ---- //
139  unsigned char getFVbyt() const;
140  short getFVsht() const;
141  int getFVint() const;
142  int getFVlng() const;
143  __int64 getFV64() const;
144  float getFVflt() const;
145  double getFVdbl() const;
146  void* getFVbin(uint_td& size) const;
147  const char* getFVAstr() const;
148 #ifdef _WIN32
149  const wchar_t* getFVWstr() const;
150  void setFVW(const wchar_t* data);
151 #endif
152  void setFV(float data);
153  void setFV(double data);
154  void setFV(unsigned char data);
155  void setFV(short data);
156  void setFV(int data);
157  void setFV(__int64 data);
158  void setFVA(const char* data);
159  void setFV(const void* data, uint_td size);
160 #ifdef _UNICODE
161  inline const wchar_t* getFVstr() const { return getFVWstr(); };
162  inline void setFV(const wchar_t* data) { setFVW(data); };
163 #else
164  inline const char* getFVstr() const { return getFVAstr(); };
165  inline void setFV(const char* data) { setFVA(data); };
166 #endif
167  double getFVnumeric() const;
168  double getFVDecimal() const;
169  void setFVDecimal(double data);
170  void setFVNumeric(double data);
171  // ---- end regacy interfaces ---- //
172 
173 
174 /** @cond INTERNAL */
175 #if defined(SWIG) || \
176  defined(SWIG_BUILDING) // SWIG Wrapper need public constructor
177 public:
178 #endif
179  inline field() : m_fd(NULL), m_ptr(NULL), m_fds(NULL){};
180 /** @endcond */
181 
182 public:
183 /** @cond INTERNAL */
184  inline field(unsigned char* ptr, const fielddef& fd, const fielddefs* fds)
185  : m_fd((fielddef*)&fd), m_ptr(ptr), m_fds(fds){};
186 /** @endcond */
187 
188  // To inline
189  inline field(const field& r) : m_fd(r.m_fd), m_ptr(r.m_ptr), m_fds(r.m_fds)
190  {
191  }
192 
193  inline field& operator=(const field& r)
194  {
195  m_fd = r.m_fd;
196  m_ptr = r.m_ptr;
197  m_fds = r.m_fds;
198  return *this;
199  }
200 
201  void* ptr() const;
202 
203  unsigned char type() const { return m_fd->type; }
204 
205  unsigned short len() const { return m_fd->len; }
206 
207  inline const _TCHAR* c_str() const { return getFVstr(); }
208 
209  inline const char* a_str() const { return getFVAstr(); }
210 
211  inline int i() const { return getFVint(); }
212 
213  inline int i8() const { return getFVbyt(); }
214 
215  inline short i16() const { return getFVsht(); }
216 
217  inline __int64 i64() const { return getFV64(); }
218 
219  inline float f() const { return getFVflt(); }
220 
221  inline double d() const { return getFVdbl(); }
222 
223  inline field& operator=(const _TCHAR* p)
224  {
225  setFV(p);
226  m_fd->enableFlags.bitE = true;
227  return *this;
228  }
229 
230  inline field& operator=(const std::_tstring& p)
231  {
232  setFV(p.c_str());
233  m_fd->enableFlags.bitE = true;
234  return *this;
235  }
236 
237 #ifdef _UNICODE
238  inline field& operator=(const char* p)
239  {
240  setFVA(p);
241  m_fd->enableFlags.bitE = true;
242  return *this;
243  }
244 
245  inline field& operator=(const std::string& p)
246  {
247  setFVA(p.c_str());
248  m_fd->enableFlags.bitE = true;
249  return *this;
250  }
251 
252 #endif
253 
254  inline field& operator=(int v)
255  {
256  setFV(v);
257  m_fd->enableFlags.bitE = true;
258  return *this;
259  }
260 
261  inline field& operator=(__int64 v)
262  {
263  setFV(v);
264  m_fd->enableFlags.bitE = true;
265  return *this;
266  }
267 
268  inline field& operator=(float v)
269  {
270  setFV(v);
271  m_fd->enableFlags.bitE = true;
272  return *this;
273  }
274 
275  inline field& operator=(double v)
276  {
277  setFV(v);
278  m_fd->enableFlags.bitE = true;
279  return *this;
280  }
281 
282  inline bool operator!=(const _TCHAR* p)
283  {
284  return (_tcscmp(p, c_str()) != 0);
285  };
286  inline bool operator==(const _TCHAR* p)
287  {
288  return (_tcscmp(p, c_str()) == 0);
289  };
290 
291  inline bool operator!=(int v) { return (v != i()); };
292  inline bool operator==(int v) { return (v == i()); };
293 
294  inline bool operator!=(short v) { return (v != i16()); };
295  inline bool operator==(short v) { return (v == i16()); };
296 
297  inline bool operator!=(__int64 v) { return (v != i64()); };
298  inline bool operator==(__int64 v) { return (v == i64()); };
299 
300  inline bool operator!=(float v) { return (v != f()); };
301  inline bool operator==(float v) { return (v == f()); };
302 
303  inline bool operator!=(double v) { return (v != d()); };
304  inline bool operator==(double v) { return (v == d()); };
305 
306  inline void setBin(const void* data, uint_td size)
307  {
308  setFV(data, size);
309  m_fd->enableFlags.bitE = true;
310  }
311  inline void* getBin(uint_td& size) { return getFVbin(size); };
312 
313  int comp(const field& r, char logType = CMPLOGICAL_VAR_COMP_ALL) const;
314 
315  /** @cond INTERNAL */
316  bool isCompPartAndMakeValue();
317  void offsetBlobPtr(size_t offset);
318  compFieldFunc getCompFunc(char logType) const;
319  /** @endcond */
320 };
321 
322 /** @cond INTERNAL */
323 /* For template tget type num by type.*/
324 
325 inline int getFieldType(int)
326 {
327  return ft_integer;
328 }
329 
330 inline int getFieldType(__int64)
331 {
332  return ft_integer;
333 }
334 
335 inline int getFieldType(short)
336 {
337  return ft_integer;
338 }
339 
340 inline int getFieldType(char)
341 {
342  return ft_integer;
343 }
344 
345 inline int getFieldType(double)
346 {
347  return ft_float;
348 }
349 
350 inline int getFieldType(float)
351 {
352  return ft_float;
353 }
354 
355 inline __int64 fieldValue(const field& fd, __int64)
356 {
357  return fd.i64();
358 }
359 
360 inline int fieldValue(const field& fd, int)
361 {
362  return fd.i();
363 }
364 
365 inline short fieldValue(const field& fd, short)
366 {
367  return (short)fd.i();
368 }
369 
370 inline char fieldValue(const field& fd, char)
371 {
372  return (char)fd.i();
373 }
374 
375 inline double fieldValue(const field& fd, double)
376 {
377  return fd.d();
378 }
379 
380 inline float fieldValue(const field& fd, float)
381 {
382  return fd.f();
383 }
384 
385 inline const _TCHAR* fieldValue(const field& fd, const _TCHAR*)
386 {
387  return fd.c_str();
388 }
389 
390 DLLLIB const fielddef& dummyFd();
391 
392 /** @endcond */
393 
394 } // namespace client
395 } // namespace tdap
396 } // namespace protocol
397 } // namespace db
398 } // namespace bzs
399 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_FIELD_H
bool operator!=(short v)
Definition: field.h:294
field(const field &r)
Definition: field.h:189
const _TCHAR * c_str() const
Definition: field.h:207
__int64 i64() const
Definition: field.h:217
フィールド定義構造体
Definition: tdapSchema.h:300
unsigned short len() const
Definition: field.h:205
bool operator!=(double v)
Definition: field.h:303
bool operator==(double v)
Definition: field.h:304
float f() const
Definition: field.h:219
field & operator=(const _TCHAR *p)
Definition: field.h:223
const char * a_str() const
Definition: field.h:209
short i16() const
Definition: field.h:215
void * getBin(uint_td &size)
Definition: field.h:311
bool operator!=(float v)
Definition: field.h:300
void setBin(const void *data, uint_td size)
Definition: field.h:306
テーブルアクセスクラス (nocopyable)
Definition: table.h:89
int i8() const
Definition: field.h:213
bool operator==(int v)
Definition: field.h:292
field & operator=(__int64 v)
Definition: field.h:261
fielddef のコレクションクラス
Definition: field.h:73
field & operator=(const std::_tstring &p)
Definition: field.h:230
int i() const
Definition: field.h:211
bool operator==(float v)
Definition: field.h:301
bool operator==(__int64 v)
Definition: field.h:298
recordset フィルタリングクエリー
Definition: groupQuery.h:95
フィールドコレクションのベースクラス
Definition: fields.h:123
bool operator!=(int v)
Definition: field.h:291
field & operator=(float v)
Definition: field.h:268
bool operator!=(__int64 v)
Definition: field.h:297
bool operator==(const _TCHAR *p)
Definition: field.h:286
bool operator!=(const _TCHAR *p)
Definition: field.h:282
field & operator=(double v)
Definition: field.h:275
unsigned char type() const
Definition: field.h:203
書き込み可能な行のクラスです。
Definition: memRecord.h:154
field & operator=(int v)
Definition: field.h:254
double d() const
Definition: field.h:221
field & operator=(const field &r)
Definition: field.h:193
const _TCHAR * c_str(const btrDate &d)
Definition: btrDate.h:207
rowの実装クラス
Definition: memRecord.h:68
テーブル定義構造体
Definition: tdapSchema.h:660
フィールドアクセスクラス
Definition: field.h:123
bool operator==(short v)
Definition: field.h:295

Transactd SDK 2015年09月08日(火) 19時13分35秒 doxygen