Covalent Bond  0.0.1-alpha
'covalent bond' is a data middle office. As a 2022-2023 Fall SWE final project.
cbTable.hpp
Go to the documentation of this file.
1 
11 #ifndef __SERVER_CB_TABLE_HPP_
12 #define __SERVER_CB_TABLE_HPP_
13 
14 #ifdef _WIN32
15 #if _MSC_VER > 1000
16 #pragma once
17 #endif
18 #endif
19 
20 #if defined(__unix__) && defined(__clang__)
21 #pragma once
22 #endif
23 #include <variant>
24 
25 #include "../../pch.hpp"
26 
27 #include "sol/sol.hpp"
28 #include <workflow/MySQLResult.h>
29 
30 // ------------------------- The code below is dropped.--------------
31 // --- Go to len=340 for latest code. -------------------------------
32 // ------------------------- The code below is dropped.--------------
33 
35 typedef std::variant<int32_t, float, std::string, bool> __metaObj;
36 
38 #define Seq(x, y) std::pair<int32_t, int32_t>(x, y)
39 
44 enum class cbTableSlice : uint8_t {
45  all = 0,
46  seq = 1,
47  no = 2,
48 };
49 
54 enum class typeType : uint32_t {
55  Int = 0,
56  Float = 1,
57  String = 2,
58  Bool = 3,
59 };
60 
65 struct cbCell {
66  cbCell() = default;
67  cbCell(const cbCell& rhs) = delete;
68  cbCell operator=(const cbCell& rhs) = delete;
69  cbCell(int32_t rhs) : data(rhs) {}
70  cbCell(float rhs) : data(rhs) {}
71  cbCell(bool rhs) : data(rhs) {}
72  cbCell(const std::string& rhs) : data(rhs) {}
73  // get data
74  int asInt();
75  float asFloat();
76  bool asBool();
77  std::string& asString();
78  // set data
79  void setAsLuaInt(sol::object rhs);
80  void setAsLuaFloat(sol::object rhs);
81  void setAsLuaBool(sol::object rhs);
82  void setAsLuaString(sol::object rhs);
83  // set data
84  void setAsCppInt(int32_t rhs);
85  void setAsCppFloat(float rhs);
86  void setAsCppBool(bool rhs);
87  void setAsCppString(std::string rhs);
89 };
90 
95 struct cbTableHead {
96  public:
97  cbTableHead();
98  cbTableHead(const int32_t& nums) : m_nums(nums), m_data(nums), m_types(nums) {}
99  cbTableHead(const int32_t& nums, const std::initializer_list<std::string>& data,
100  const std::initializer_list<typeType>& types)
101  : m_nums(nums), m_data(data) {}
102 
103  std::vector<std::string>::iterator begin() { return m_data.begin(); }
104  std::vector<std::string>::iterator end() { return m_data.end(); }
105  const std::vector<std::string>::const_iterator cbegin() { return m_data.cbegin(); }
106  const std::vector<std::string>::const_iterator cend() { return m_data.cend(); }
107 
108  std::pair<std::string&, typeType&> operator[](int32_t idx) { return {m_data[idx], m_types[idx]}; }
109 
110  void set(const std::string& n, int32_t idx) {
111  if (idx >= 0 && idx < m_nums) m_data[idx] = n;
112  }
113 
114  void set(const typeType& t, int32_t idx) {
115  if (idx >= 0 && idx < m_nums) m_types[idx] = t;
116  }
117 
118  void addNameAndType(const std::string& name, const typeType& t) {
119  m_data.push_back(name);
120  m_types.push_back(t);
121  }
122 
123  private:
124  int32_t m_nums = 0;
125  std::vector<std::string> m_data;
126  std::vector<typeType> m_types;
127 };
128 
134 template<int32_t Dims>
135 struct cbShape {
136  cbShape() = default;
137  cbShape(const cbShape<Dims>& rhs) {
138 #pragma unroll
139  for (int32_t i = 0; i < Dims; ++i) { this->m_dims[i] = rhs.m_dims[i]; }
140  this->m_stride = rhs.m_stride;
141  }
142  cbShape(const std::initializer_list<int32_t>& rhs) : m_dims(rhs) {}
143  // cbShape<Dims> operator=(const cbShape<Dims>& s) {
144  // cbShape<Dims> ans;
145  // #pragma unroll
146  // for (int32_t i = 0; i < Dims; ++i) { ans.m_dims[i] = s.m_dims[i]; }
147  // ans.m_stride = s.m_stride;
148  // return ans;
149  // }
150 
151  inline int32_t& operator[](int32_t idx) { return m_dims[idx]; }
152  inline int32_t const operator[](int32_t idx) const { return m_dims[idx]; }
153 
154  inline int32_t numElements() {
155  int32_t ans = 1;
156 #pragma unroll
157  for (int32_t i = 0; i < Dims; ++i) { ans *= m_dims[i]; }
158  return ans;
159  }
160 
161  int32_t m_stride;
162  int32_t m_dims[Dims];
163 };
164 
171 inline cbShape<2> makeShapeRow(int32_t a) {
172  cbShape<2> ans;
173  ans[0] = 1;
174  ans[1] = a;
175  return ans;
176 }
177 
184 inline cbShape<2> makeShapeCol(int32_t a) {
185  cbShape<2> ans;
186  ans[0] = a;
187  ans[1] = 1;
188  return ans;
189 }
190 
198 inline cbShape<2> makeShapeFull(int32_t a, int32_t b) {
199  cbShape<2> ans;
200  ans[0] = a;
201  ans[1] = b;
202  return ans;
203 }
204 
210 template<int32_t Dims>
211 struct __metaMatrix {
212  __metaMatrix() = default;
213  __metaMatrix(const cbShape<Dims>& shape) : m_shape(shape) {}
214  __metaMatrix(const cbShape<Dims>& shape, cbCell* dataptr) : m_shape(shape), __dataptr(dataptr) {}
216  this->m_shape = rhs.m_shape;
217  this->__dataptr = rhs.__dataptr;
218  }
219 
220  void free() {
221  if (m_trueDataContainer) { delete __dataptr; }
222  }
223 
225  cbCell* __dataptr = nullptr;
226  bool m_trueDataContainer = false;
227 };
228 
233 struct cbTableRow : public __metaMatrix<2> {
234  public:
235  cbTableRow() = delete;
236  cbTableRow(const cbShape<2>& shape) : __metaMatrix<2>(shape) {}
237  cbTableRow(const cbShape<2>& shape, cbCell* dataptr) : __metaMatrix<2>(shape, dataptr) {}
238  cbTableRow(const cbTableRow& rhs) {
239  this->__dataptr = rhs.__dataptr;
240  this->m_shape = rhs.m_shape;
241  }
242 
244 
245  cbCell* at(int32_t i) { return __dataptr + i; }
246 
248 };
249 
254 struct cbTableCol : public __metaMatrix<2> {
255  public:
256  cbTableCol() = delete;
257  cbTableCol(const cbShape<2>& shape) : __metaMatrix<2>(shape), m_stride(1) {}
258  cbTableCol(const cbShape<2>& shape, int32_t stride) : __metaMatrix<2>(shape), m_stride(stride) {}
259  cbTableCol(const cbShape<2>& shape, int32_t stride, cbCell* dataptr)
260  : __metaMatrix<2>(shape, dataptr), m_stride(stride) {}
261  cbTableCol(const cbTableCol& rhs) {
262  this->__dataptr = rhs.__dataptr;
263  this->m_shape = rhs.m_shape;
264  this->m_stride = rhs.m_stride;
265  }
266 
267  cbCell* at(int32_t i) { return __dataptr + i * m_stride; }
268 
270 
271  void setStride(int32_t rhs) { m_stride = rhs; }
272 
274 
275  private:
276  int32_t m_stride = 0;
277 };
278 
283 class cbTable : public __metaMatrix<2> {
284  public:
285  cbTable() = delete;
286  cbTable(const cbTable& rhs) {
287  this->m_shape = rhs.m_shape;
288  this->__dataptr = rhs.__dataptr;
289  this->m_stride = this->m_shape[1];
290  }
291  cbTable(cbShape<2>& shape) : __metaMatrix<2>(shape), m_stride(shape[1]) {}
292  cbTable(cbShape<2>& shape, cbCell* dataptr)
293  : __metaMatrix<2>(shape, dataptr), m_stride(shape[1]) {}
294 
296 
297  inline cbCell* at(int32_t i, int32_t j) { return __dataptr + (i * m_stride + j); }
298 
299  inline cbCell* operator()(int32_t i, int32_t j) { return at(i, j); }
300 
301  inline cbTable operator()(const std::pair<int32_t, int32_t>& row_i, const cbTableSlice& cbSl) {
302  int32_t rows = row_i.second - row_i.first;
303  int32_t cols = 0;
304  switch (cbSl) {
305  case cbTableSlice::all: cols = m_shape[1]; break;
306  case cbTableSlice::no: break;
307  case cbTableSlice::seq: break;
308  }
309  cbShape<2> res = makeShapeFull(rows, cols);
310 
311  cbTable ans(res, __dataptr);
312  ans.head = this->head;
313 
314  return ans;
315  }
316 
317  inline cbTableRow getRow(int32_t i) {
319  ans.head = this->head;
320  return ans;
321  }
322 
323  inline cbTableCol getCol(int32_t i) {
325  auto tmp_heads_ele = this->head[i];
326  ans.head = cbTableHead(1);
327  ans.head.set(tmp_heads_ele.first, i);
328  ans.head.set(tmp_heads_ele.second, i);
329  return ans;
330  }
331 
333 
334  private:
335  int32_t m_stride = 0;
336 };
337 
343 inline void mallocMetaMatrix(cbTable& rhs) {
344  rhs.__dataptr = new cbCell[rhs.m_shape.numElements()];
346 }
347 
353 inline void mallocMetaMatrix(cbTableCol& rhs) {
354  rhs.__dataptr = new cbCell[rhs.m_shape.numElements()];
355  rhs.setStride(1);
357 }
358 
359 // -------------- below is for actually use. ---------------------------------
360 // -------------- below is for actually use. ---------------------------------
361 // -------------- below is for actually use. ---------------------------------
362 
363 // And I will provide a bunch of function for sol::lua to use.
364 
369 typedef std::variant<std::string, float, double, int, unsigned long long> __cbMySQLMeta;
370 
375 enum class cbMySQLType {
376  Float,
377  Double,
378  Int,
379  ULL,
380  String,
381  Date,
382  Time,
383  DataTime,
384  Null,
385 };
386 
405  public:
410  cbMySQLField();
411 
417  cbMySQLField(const protocol::MySQLField* wfPtr);
418 
419  cbMySQLField(const cbMySQLField* ptr);
420 
421  // get data.
422  std::string getName() const;
423  std::string getOrgName() const;
424  std::string getTable() const;
425  std::string getOrgTable() const;
426  std::string getDB() const;
427  std::string getCatalog() const;
428  std::string getDef() const;
429  int getCharsetnr() const;
430  int getLength() const;
431  int getFlags() const;
432  int getDecimals() const;
433  int getDataType() const;
434 
435  // set data.
436  void setName(const std::string& value);
437  void setOrgName(const std::string& value);
438  void setTable(const std::string& value);
439  void setOrgTable(const std::string& value);
440  void setDB(const std::string& value);
441  void setCatalog(const std::string& value);
442  void setDef(const std::string& value);
443  void setCharsetnr(int32_t value);
444  void setLength(int32_t value);
445  void setFlags(int32_t value);
446  void setDecimals(int32_t value);
447  void setDataType(int32_t value);
448 
449  private:
450  std::string m_name; /* Name of column */
451  std::string m_orgName; /* Original column name, if an alias */
452  std::string m_table; /* Table of column if column was a field */
453  std::string m_orgTable; /* Org table name, if table was an alias */
454  std::string m_db; /* Database for table */
455  std::string m_catalog; /* Catalog for table */
456  std::string m_def; /* Default value (set by mysql_list_fields) */
457  int m_length; /* Width of column (create length) */
458  int m_flags; /* Div flags */
459  int m_decimals; /* Number of decimals in field */
460  int m_charsetnr; /* Character set */
461  int m_data_type; /* Type of field. See mysql_types.h for types */
462 };
463 
468 class cbMySQLCell {
469  public:
471  cbMySQLCell(const protocol::MySQLCell& m);
472  cbMySQLCell(int value) : m_type(cbMySQLType::Int), m_data(value) {}
473  cbMySQLCell(float value) : m_type(cbMySQLType::Float), m_data(value) {}
474  cbMySQLCell(double value) : m_type(cbMySQLType::Double), m_data(value) {}
475  cbMySQLCell(unsigned long long value) : m_type(cbMySQLType::ULL), m_data(value) {}
476  cbMySQLCell(const std::string& value) : m_type(cbMySQLType::String), m_data(value) {}
477  cbMySQLCell(const std::string& value, const cbMySQLType& t) : m_type(t), m_data(value) {}
478 
479  bool isNull() const;
480  bool isInt() const;
481  bool isString() const;
482  bool isFloat() const;
483  bool isDouble() const;
484  bool isULL() const;
485  bool isDate() const;
486  bool isTime() const;
487  bool isDatetime() const;
488 
489  int asInt() const;
490  std::string asString() const;
491  float asFloat() const;
492  double asDouble() const;
493  unsigned long long asULL() const;
494  std::string asDate() const;
495  std::string asTime() const;
496  std::string asDatetime() const;
497 
498  void setInt(int value);
499  void setString(const std::string& value);
500  void setFloat(float value);
501  void setDouble(double value);
502  void setULL(unsigned long long value);
503  void setDate(const std::string& value);
504  void setTime(const std::string& value);
505  void setDatetime(const std::string& value);
506 
508 
509  private:
512 };
513 
519  public:
525 
530  cbVirtualSharedTable() = default;
531 
537  cbVirtualSharedTable(protocol::MySQLResultCursor* cursor);
538 
544  const cbShape<2> getShape() const { return m_shape; }
545 
553  cbMySQLCell* atPtr(int32_t i, int32_t j);
554 
562  cbMySQLCell* atPtrRef(int32_t i, int32_t j);
563 
569  cbMySQLField** getInfo() { return m_info; }
570 
576  int32_t getFiledCount() { return m_fieldCount; }
577 
583  void resetShape(cbShape<2>& shape);
584 
591  void resetFieldInfo(int32_t fieldCount, cbMySQLField** info);
592 
593  private:
594  int32_t m_fieldCount = 0;
596  cbMySQLField** m_info = nullptr;
597  std::vector<std::vector<cbMySQLCell>> m_data;
598 };
599 
606  public:
607  cbVirtualTable() = default;
609  if (m_isInfoExtent) { delete[] m_info; }
610  }
612  this->m_shape = rhs.m_shape;
613  this->m_data = rhs.m_data;
614  this->m_info = rhs.m_info;
615  }
617  : m_info(nullptr), m_shape(shape), m_data(shape[0], std::vector<cbMySQLCell*>(shape[1])) {
618  m_data.shrink_to_fit();
619  }
621  : m_info(nullptr), m_shape(shape), m_data(shape[0], std::vector<cbMySQLCell*>(shape[1])) {
622  m_data.shrink_to_fit();
623  }
624 
625  // cbVirtualTable operator=(const cbVirtualTable& rhsOp) {
626  // cbVirtualTable ans;
627  // ans.m_data = rhsOp.m_data;
628  // ans.m_info = rhsOp.m_info;
629  // ans.m_shape = rhsOp.m_shape;
630  // return ans;
631  // }
632 
638  void resetShape(const cbShape<2>& shape);
639 
646  void resetShapeH(const cbShape<2>& shape);
647 
653  cbMySQLField** getInfo();
654 
660  void setInfo(cbMySQLField** v);
661 
667  void setInfoAt(int32_t i, cbMySQLField* v);
668 
673  cbMySQLField* getInfoAt(int32_t i);
674 
680  std::vector<std::vector<cbMySQLCell*>>& getData();
681 
688 
696  cbMySQLCell* atPtr(int32_t i, int32_t j);
697 
705  cbMySQLCell*& atPtrRef(int32_t i, int32_t j);
706 
714  void setPtrAt(int32_t i, int32_t j, cbMySQLCell* v);
715 
722  cbVirtualTable getRow(int32_t i);
723 
730  cbVirtualTable getCol(int32_t i);
731 
738  std::map<int32_t, int32_t> keyBy(const std::string& colName) const;
739 
745  void pushRow(const std::vector<cbMySQLCell*>& row);
746 
753  std::string colNameAt(int32_t i);
754 
761  std::string colTypeAt(int32_t i);
762 
767  void str();
768 
769  private:
770  bool m_isInfoExtent = false;
771  cbMySQLField** m_info = nullptr;
773  std::vector<std::vector<cbMySQLCell*>> m_data;
774 };
775 
777  cbOutputTableStruct() = delete;
778  cbOutputTableStruct(const cbShape<2>& shape, cbMySQLField** info);
779 
780  void clear();
781 
782  void update(const cbShape<2>& shape, cbMySQLField** info);
783 
784  std::string genKey4Redis(int32_t row, int32_t col);
785 
787  std::vector<cbMySQLField> m_info;
788 };
789 
790 void mapShared2Virtual(cbVirtualSharedTable* sharedT, cbVirtualTable* virtualT);
791 
792 template<typename T>
793 auto fetchShapeIndex(T& c, int32_t idx) -> int32_t& {
794  return c[idx];
795 }
796 
797 template<typename T>
798 auto storeShapeIndex(T& c, int32_t idx, int32_t const& v) -> void {
799  c[idx] = v;
800 }
801 
802 std::vector<cbMySQLCell*> __luaPackedCellAsVec(cbMySQLCell* v = nullptr);
803 
804 std::vector<std::string> __luaPackedStringAsVec();
805 
806 #endif //! __SERVER_CB_TABLE_HPP_
cbCell::asBool
bool asBool()
Definition: cbTable.cpp:22
cbOutputTableStruct::m_info
std::vector< cbMySQLField > m_info
Definition: cbTable.hpp:787
cbMySQLField::m_length
int m_length
Definition: cbTable.hpp:457
cbTable::cbTable
cbTable(cbShape< 2 > &shape, cbCell *dataptr)
Definition: cbTable.hpp:292
cbTableCol::cbTableCol
cbTableCol()=delete
cbTableRow::at
cbCell * at(int32_t i)
Definition: cbTable.hpp:245
cbMySQLField::getFlags
int getFlags() const
Definition: cbTable.cpp:288
cbMySQLCell::isTime
bool isTime() const
Definition: cbTable.cpp:388
cbVirtualSharedTable::cbVirtualSharedTable
cbVirtualSharedTable()=default
Construct a new cb Virtual Shared Table object.
cbTable::getCol
cbTableCol getCol(int32_t i)
Definition: cbTable.hpp:323
__metaMatrix::free
void free()
Definition: cbTable.hpp:220
cbVirtualSharedTable::m_fieldCount
int32_t m_fieldCount
Definition: cbTable.hpp:594
cbTableRow::setThisAsTrueDataContainer
void setThisAsTrueDataContainer()
Definition: cbTable.hpp:243
cbVirtualTable::str
void str()
Definition: cbTable.cpp:199
cbTableHead::set
void set(const typeType &t, int32_t idx)
Definition: cbTable.hpp:114
cbMySQLField::getName
std::string getName() const
Definition: cbTable.cpp:278
cbOutputTableStruct::genKey4Redis
std::string genKey4Redis(int32_t row, int32_t col)
Definition: cbTable.cpp:226
cbVirtualTable::m_shape
cbShape< 2 > m_shape
Definition: cbTable.hpp:772
cbMySQLField::setDataType
void setDataType(int32_t value)
Definition: cbTable.cpp:304
cbCell::setAsCppBool
void setAsCppBool(bool rhs)
Definition: cbTable.cpp:38
typeType
typeType
Definition: cbTable.hpp:54
cbCell::data
__metaObj data
Definition: cbTable.hpp:88
cbMySQLCell::cbMySQLCell
cbMySQLCell(int value)
Definition: cbTable.hpp:472
cbVirtualTable::colTypeAt
std::string colTypeAt(int32_t i)
Definition: cbTable.cpp:197
cbMySQLCell::asDate
std::string asDate() const
Definition: cbTable.cpp:427
cbVirtualTable::atPtr
cbMySQLCell * atPtr(int32_t i, int32_t j)
row major
Definition: cbTable.cpp:128
cbCell::cbCell
cbCell(bool rhs)
Definition: cbTable.hpp:71
cbTable::operator()
cbCell * operator()(int32_t i, int32_t j)
Definition: cbTable.hpp:299
cbVirtualTable::getInfoAt
cbMySQLField * getInfoAt(int32_t i)
Get the Info At object.
Definition: cbTable.cpp:124
cbTable::cbTable
cbTable(const cbTable &rhs)
Definition: cbTable.hpp:286
cbVirtualTable::getInfo
cbMySQLField ** getInfo()
Get the Info object.
Definition: cbTable.cpp:115
cbVirtualTable
cbVirtualTable works as a reference from shared memory. It only use a shape and SqlCell to define dif...
Definition: cbTable.hpp:605
__metaMatrix::__dataptr
cbCell * __dataptr
Definition: cbTable.hpp:225
cbMySQLCell::isDouble
bool isDouble() const
Definition: cbTable.cpp:367
cbMySQLCell::setDate
void setDate(const std::string &value)
Definition: cbTable.cpp:453
cbShape::operator[]
const int32_t operator[](int32_t idx) const
Definition: cbTable.hpp:152
cbVirtualTable::~cbVirtualTable
~cbVirtualTable()
Definition: cbTable.hpp:608
cbTableCol::m_stride
int32_t m_stride
Definition: cbTable.hpp:276
cbTableHead::cbTableHead
cbTableHead(const int32_t &nums, const std::initializer_list< std::string > &data, const std::initializer_list< typeType > &types)
Definition: cbTable.hpp:99
cbMySQLField::getTable
std::string getTable() const
Definition: cbTable.cpp:281
mapShared2Virtual
void mapShared2Virtual(cbVirtualSharedTable *sharedT, cbVirtualTable *virtualT)
Definition: cbTable.cpp:232
cbOutputTableStruct::clear
void clear()
Definition: cbTable.cpp:210
cbShape::operator[]
int32_t & operator[](int32_t idx)
Definition: cbTable.hpp:151
cbVirtualTable::getRow
cbVirtualTable getRow(int32_t i)
Get the Row object.
Definition: cbTable.cpp:134
cbMySQLCell::cbMySQLCell
cbMySQLCell(float value)
Definition: cbTable.hpp:473
cbVirtualTable::cbVirtualTable
cbVirtualTable(const cbVirtualTable &rhs)
Definition: cbTable.hpp:611
cbTableRow::cbTableRow
cbTableRow()=delete
cbOutputTableStruct
Definition: cbTable.hpp:776
cbTableCol::setThisAsTrueDataContainer
void setThisAsTrueDataContainer()
Definition: cbTable.hpp:269
cbMySQLField::cbMySQLField
cbMySQLField()
Construct a new cb My S Q L Field object.
Definition: cbTable.cpp:245
cbCell::cbCell
cbCell(int32_t rhs)
Definition: cbTable.hpp:69
cbMySQLCell::getType
cbMySQLType getType()
Definition: cbTable.cpp:465
cbMySQLCell::setTime
void setTime(const std::string &value)
Definition: cbTable.cpp:457
cbCell::setAsCppInt
void setAsCppInt(int32_t rhs)
Definition: cbTable.cpp:34
cbMySQLField::getDataType
int getDataType() const
Definition: cbTable.cpp:290
cbMySQLField
A copy move from workflow MySQLResult.h and .inl file.
Definition: cbTable.hpp:404
cbMySQLType::Time
@ Time
cbVirtualSharedTable::atPtr
cbMySQLCell * atPtr(int32_t i, int32_t j)
Definition: cbTable.cpp:77
cbCell::setAsLuaBool
void setAsLuaBool(sol::object rhs)
Definition: cbTable.cpp:30
cbTableHead
Definition: cbTable.hpp:95
cbVirtualSharedTable::resetShape
void resetShape(cbShape< 2 > &shape)
Definition: cbTable.cpp:81
cbTableCol::cbTableCol
cbTableCol(const cbShape< 2 > &shape)
Definition: cbTable.hpp:257
cbMySQLCell::asTime
std::string asTime() const
Definition: cbTable.cpp:429
cbVirtualTable::setPtrAt
void setPtrAt(int32_t i, int32_t j, cbMySQLCell *v)
Set the Ptr At object.
Definition: cbTable.cpp:132
cbMySQLCell::isDate
bool isDate() const
Definition: cbTable.cpp:381
cbTableHead::cbegin
const std::vector< std::string >::const_iterator cbegin()
Definition: cbTable.hpp:105
cbShape::numElements
int32_t numElements()
Definition: cbTable.hpp:154
cbCell::setAsCppFloat
void setAsCppFloat(float rhs)
Definition: cbTable.cpp:36
cbTableRow::cbTableRow
cbTableRow(const cbShape< 2 > &shape)
Definition: cbTable.hpp:236
cbVirtualSharedTable::atPtrRef
cbMySQLCell * atPtrRef(int32_t i, int32_t j)
Definition: cbTable.cpp:79
cbMySQLField::m_orgName
std::string m_orgName
Definition: cbTable.hpp:451
cbTableRow::cbTableRow
cbTableRow(const cbShape< 2 > &shape, cbCell *dataptr)
Definition: cbTable.hpp:237
cbTableHead::m_data
std::vector< std::string > m_data
Definition: cbTable.hpp:125
cbTableHead::cbTableHead
cbTableHead(const int32_t &nums)
Definition: cbTable.hpp:98
cbTableHead::begin
std::vector< std::string >::iterator begin()
Definition: cbTable.hpp:103
cbMySQLType::DataTime
@ DataTime
cbTable::at
cbCell * at(int32_t i, int32_t j)
Definition: cbTable.hpp:297
storeShapeIndex
auto storeShapeIndex(T &c, int32_t idx, int32_t const &v) -> void
Definition: cbTable.hpp:798
cbMySQLCell::asDouble
double asDouble() const
Definition: cbTable.cpp:417
cbTableHead::cend
const std::vector< std::string >::const_iterator cend()
Definition: cbTable.hpp:106
makeShapeCol
cbShape< 2 > makeShapeCol(int32_t a)
Definition: cbTable.hpp:184
cbCell::cbCell
cbCell(const std::string &rhs)
Definition: cbTable.hpp:72
__metaMatrix::m_shape
cbShape< Dims > m_shape
Definition: cbTable.hpp:224
cbTableSlice::seq
@ seq
cbOutputTableStruct::update
void update(const cbShape< 2 > &shape, cbMySQLField **info)
Definition: cbTable.cpp:217
cbCell::asFloat
float asFloat()
Definition: cbTable.cpp:20
cbMySQLCell::cbMySQLCell
cbMySQLCell(unsigned long long value)
Definition: cbTable.hpp:475
cbMySQLCell
Definition: cbTable.hpp:468
cbMySQLField::m_data_type
int m_data_type
Definition: cbTable.hpp:461
cbTableCol::cbTableCol
cbTableCol(const cbShape< 2 > &shape, int32_t stride)
Definition: cbTable.hpp:258
cbMySQLCell::isFloat
bool isFloat() const
Definition: cbTable.cpp:360
cbVirtualTable::resetShapeH
void resetShapeH(const cbShape< 2 > &shape)
Definition: cbTable.cpp:109
cbTableHead::operator[]
std::pair< std::string &, typeType & > operator[](int32_t idx)
Definition: cbTable.hpp:108
cbMySQLCell::isDatetime
bool isDatetime() const
Definition: cbTable.cpp:395
cbTableHead::addNameAndType
void addNameAndType(const std::string &name, const typeType &t)
Definition: cbTable.hpp:118
__metaMatrix::__metaMatrix
__metaMatrix(const cbShape< Dims > &shape)
Definition: cbTable.hpp:213
cbMySQLCell::isInt
bool isInt() const
Definition: cbTable.cpp:343
cbMySQLCell::setDatetime
void setDatetime(const std::string &value)
Definition: cbTable.cpp:461
cbMySQLCell::m_type
cbMySQLType m_type
Definition: cbTable.hpp:510
cbVirtualTable::pushRow
void pushRow(const std::vector< cbMySQLCell * > &row)
Definition: cbTable.cpp:189
cbVirtualTable::setInfoAt
void setInfoAt(int32_t i, cbMySQLField *v)
Set the Info At object.
Definition: cbTable.cpp:119
cbVirtualTable::getCol
cbVirtualTable getCol(int32_t i)
Get the Col object.
Definition: cbTable.cpp:145
cbMySQLCell::asULL
unsigned long long asULL() const
Definition: cbTable.cpp:422
cbMySQLCell::cbMySQLCell
cbMySQLCell(double value)
Definition: cbTable.hpp:474
cbMySQLField::m_catalog
std::string m_catalog
Definition: cbTable.hpp:455
cbMySQLField::setTable
void setTable(const std::string &value)
Definition: cbTable.cpp:295
cbTable
Definition: cbTable.hpp:283
cbMySQLField::getLength
int getLength() const
Definition: cbTable.cpp:287
cbMySQLType::Double
@ Double
cbMySQLField::setOrgName
void setOrgName(const std::string &value)
Definition: cbTable.cpp:294
cbMySQLField::setDef
void setDef(const std::string &value)
Definition: cbTable.cpp:299
cbMySQLCell::isNull
bool isNull() const
Definition: cbTable.cpp:336
mallocMetaMatrix
void mallocMetaMatrix(cbTable &rhs)
Definition: cbTable.hpp:343
cbTableRow::head
cbTableHead head
Definition: cbTable.hpp:247
fetchShapeIndex
auto fetchShapeIndex(T &c, int32_t idx) -> int32_t &
Definition: cbTable.hpp:793
cbMySQLField::getOrgTable
std::string getOrgTable() const
Definition: cbTable.cpp:282
cbTableCol::cbTableCol
cbTableCol(const cbShape< 2 > &shape, int32_t stride, cbCell *dataptr)
Definition: cbTable.hpp:259
cbMySQLField::setDB
void setDB(const std::string &value)
Definition: cbTable.cpp:297
cbMySQLField::getDef
std::string getDef() const
Definition: cbTable.cpp:285
cbMySQLCell::setFloat
void setFloat(float value)
Definition: cbTable.cpp:441
cbMySQLField::setLength
void setLength(int32_t value)
Definition: cbTable.cpp:301
__luaPackedCellAsVec
std::vector< cbMySQLCell * > __luaPackedCellAsVec(cbMySQLCell *v=nullptr)
Definition: cbTable.cpp:467
__metaMatrix::__metaMatrix
__metaMatrix()=default
cbCell::asInt
int asInt()
Definition: cbTable.cpp:18
cbVirtualTable::cbVirtualTable
cbVirtualTable()=default
cbMySQLField::getOrgName
std::string getOrgName() const
Definition: cbTable.cpp:280
cbMySQLCell::isULL
bool isULL() const
Definition: cbTable.cpp:374
cbVirtualTable::m_data
std::vector< std::vector< cbMySQLCell * > > m_data
Definition: cbTable.hpp:773
cbTableCol::setStride
void setStride(int32_t rhs)
Definition: cbTable.hpp:271
cbMySQLField::m_name
std::string m_name
Definition: cbTable.hpp:450
cbTableSlice
cbTableSlice
Definition: cbTable.hpp:44
cbMySQLType::ULL
@ ULL
cbShape
Definition: cbTable.hpp:135
typeType::Bool
@ Bool
cbMySQLField::setName
void setName(const std::string &value)
Definition: cbTable.cpp:293
cbShape::m_stride
int32_t m_stride
Definition: cbTable.hpp:161
cbShape::m_dims
int32_t m_dims[Dims]
Definition: cbTable.hpp:162
cbMySQLField::getCharsetnr
int getCharsetnr() const
Definition: cbTable.cpp:286
cbMySQLCell::cbMySQLCell
cbMySQLCell(const std::string &value)
Definition: cbTable.hpp:476
cbTableSlice::no
@ no
cbMySQLCell::asInt
int asInt() const
Definition: cbTable.cpp:402
cbTableCol::head
cbTableHead head
Definition: cbTable.hpp:273
cbVirtualSharedTable::m_info
cbMySQLField ** m_info
Definition: cbTable.hpp:596
cbTableRow::cbTableRow
cbTableRow(const cbTableRow &rhs)
Definition: cbTable.hpp:238
cbTableCol::cbTableCol
cbTableCol(const cbTableCol &rhs)
Definition: cbTable.hpp:261
cbTable::m_stride
int32_t m_stride
Definition: cbTable.hpp:335
cbMySQLCell::isString
bool isString() const
Definition: cbTable.cpp:350
cbMySQLCell::setInt
void setInt(int value)
Definition: cbTable.cpp:433
cbVirtualSharedTable::~cbVirtualSharedTable
~cbVirtualSharedTable()
Destroy the cb Virtual Shared Table object.
Definition: cbTable.cpp:48
__cbMySQLMeta
std::variant< std::string, float, double, int, unsigned long long > __cbMySQLMeta
Definition: cbTable.hpp:369
cbMySQLField::m_decimals
int m_decimals
Definition: cbTable.hpp:459
cbCell::operator=
cbCell operator=(const cbCell &rhs)=delete
cbMySQLField::setCatalog
void setCatalog(const std::string &value)
Definition: cbTable.cpp:298
cbVirtualSharedTable::getInfo
cbMySQLField ** getInfo()
Get the Info object.
Definition: cbTable.hpp:569
cbVirtualSharedTable
cbVirtualSharedTable is a container of shared memory.
Definition: cbTable.hpp:518
cbVirtualTable::m_info
cbMySQLField ** m_info
Definition: cbTable.hpp:771
__metaMatrix::__metaMatrix
__metaMatrix(const __metaMatrix &rhs)
Definition: cbTable.hpp:215
cbMySQLCell::setString
void setString(const std::string &value)
Definition: cbTable.cpp:437
cbVirtualSharedTable::getShape
const cbShape< 2 > getShape() const
Get the Shape object.
Definition: cbTable.hpp:544
cbVirtualTable::cbVirtualTable
cbVirtualTable(const cbShape< 2 > &shape)
Definition: cbTable.hpp:620
cbVirtualSharedTable::resetFieldInfo
void resetFieldInfo(int32_t fieldCount, cbMySQLField **info)
Definition: cbTable.cpp:91
cbVirtualTable::atPtrRef
cbMySQLCell *& atPtrRef(int32_t i, int32_t j)
Definition: cbTable.cpp:130
cbMySQLField::m_def
std::string m_def
Definition: cbTable.hpp:456
__luaPackedStringAsVec
std::vector< std::string > __luaPackedStringAsVec()
Definition: cbTable.cpp:474
cbTableHead::m_nums
int32_t m_nums
Definition: cbTable.hpp:124
cbCell::setAsCppString
void setAsCppString(std::string rhs)
Definition: cbTable.cpp:40
cbMySQLCell::cbMySQLCell
cbMySQLCell(const std::string &value, const cbMySQLType &t)
Definition: cbTable.hpp:477
cbMySQLType::Null
@ Null
cbMySQLField::setDecimals
void setDecimals(int32_t value)
Definition: cbTable.cpp:303
cbVirtualTable::getData
std::vector< std::vector< cbMySQLCell * > > & getData()
Get the Data object.
Definition: cbTable.cpp:126
typeType::Int
@ Int
cbMySQLField::getDB
std::string getDB() const
Definition: cbTable.cpp:283
cbShape::cbShape
cbShape(const std::initializer_list< int32_t > &rhs)
Definition: cbTable.hpp:142
cbVirtualTable::colNameAt
std::string colNameAt(int32_t i)
Definition: cbTable.cpp:195
cbTable::cbTable
cbTable()=delete
cbMySQLType
cbMySQLType
Definition: cbTable.hpp:375
cbTable::getRow
cbTableRow getRow(int32_t i)
Definition: cbTable.hpp:317
cbMySQLField::m_orgTable
std::string m_orgTable
Definition: cbTable.hpp:453
cbVirtualSharedTable::m_data
std::vector< std::vector< cbMySQLCell > > m_data
Definition: cbTable.hpp:597
cbVirtualTable::resetShape
void resetShape(const cbShape< 2 > &shape)
Definition: cbTable.cpp:98
cbCell
Definition: cbTable.hpp:65
__metaMatrix::m_trueDataContainer
bool m_trueDataContainer
Definition: cbTable.hpp:226
cbTableCol::at
cbCell * at(int32_t i)
Definition: cbTable.hpp:267
cbTableRow
Definition: cbTable.hpp:233
__metaObj
std::variant< int32_t, float, std::string, bool > __metaObj
_WIN32
Definition: cbTable.hpp:35
cbTableHead::cbTableHead
cbTableHead()
cbTable::operator()
cbTable operator()(const std::pair< int32_t, int32_t > &row_i, const cbTableSlice &cbSl)
Definition: cbTable.hpp:301
cbVirtualTable::cbVirtualTable
cbVirtualTable(cbShape< 2 > &shape)
Definition: cbTable.hpp:616
cbTable::setThisAsTrueDataContainer
void setThisAsTrueDataContainer()
Definition: cbTable.hpp:295
cbMySQLCell::asDatetime
std::string asDatetime() const
Definition: cbTable.cpp:431
cbMySQLField::m_db
std::string m_db
Definition: cbTable.hpp:454
cbMySQLField::m_table
std::string m_table
Definition: cbTable.hpp:452
cbMySQLField::m_flags
int m_flags
Definition: cbTable.hpp:458
cbVirtualSharedTable::getFiledCount
int32_t getFiledCount()
Get the Filed Count object.
Definition: cbTable.hpp:576
makeShapeFull
cbShape< 2 > makeShapeFull(int32_t a, int32_t b)
Definition: cbTable.hpp:198
cbMySQLCell::asFloat
float asFloat() const
Definition: cbTable.cpp:412
cbMySQLField::setCharsetnr
void setCharsetnr(int32_t value)
Definition: cbTable.cpp:300
cbCell::setAsLuaInt
void setAsLuaInt(sol::object rhs)
Definition: cbTable.cpp:26
cbCell::setAsLuaString
void setAsLuaString(sol::object rhs)
Definition: cbTable.cpp:32
cbMySQLField::setFlags
void setFlags(int32_t value)
Definition: cbTable.cpp:302
cbVirtualSharedTable::m_shape
cbShape< 2 > m_shape
Definition: cbTable.hpp:595
typeType::String
@ String
cbCell::setAsLuaFloat
void setAsLuaFloat(sol::object rhs)
Definition: cbTable.cpp:28
cbCell::cbCell
cbCell(float rhs)
Definition: cbTable.hpp:70
cbOutputTableStruct::cbOutputTableStruct
cbOutputTableStruct()=delete
cbMySQLCell::setDouble
void setDouble(double value)
Definition: cbTable.cpp:445
cbTableHead::set
void set(const std::string &n, int32_t idx)
Definition: cbTable.hpp:110
cbShape::cbShape
cbShape()=default
cbMySQLCell::m_data
__cbMySQLMeta m_data
Definition: cbTable.hpp:511
cbShape::cbShape
cbShape(const cbShape< Dims > &rhs)
Definition: cbTable.hpp:137
__metaMatrix::__metaMatrix
__metaMatrix(const cbShape< Dims > &shape, cbCell *dataptr)
Definition: cbTable.hpp:214
cbTableHead::end
std::vector< std::string >::iterator end()
Definition: cbTable.hpp:104
cbMySQLField::getDecimals
int getDecimals() const
Definition: cbTable.cpp:289
cbMySQLCell::cbMySQLCell
cbMySQLCell()
Definition: cbTable.hpp:470
cbTableSlice::all
@ all
cbMySQLField::setOrgTable
void setOrgTable(const std::string &value)
Definition: cbTable.cpp:296
cbVirtualTable::getShape
cbShape< 2 > getShape()
Get the Shape object.
Definition: cbTable.hpp:687
cbOutputTableStruct::m_shape
cbShape< 2 > m_shape
Definition: cbTable.hpp:786
cbVirtualTable::keyBy
std::map< int32_t, int32_t > keyBy(const std::string &colName) const
Definition: cbTable.cpp:156
cbCell::cbCell
cbCell()=default
cbMySQLCell::asString
std::string asString() const
Definition: cbTable.cpp:407
__metaMatrix
row major table.
Definition: cbTable.hpp:211
cbMySQLField::m_charsetnr
int m_charsetnr
Definition: cbTable.hpp:460
cbMySQLField::getCatalog
std::string getCatalog() const
Definition: cbTable.cpp:284
cbTableHead::m_types
std::vector< typeType > m_types
Definition: cbTable.hpp:126
cbTable::head
cbTableHead head
Definition: cbTable.hpp:332
typeType::Float
@ Float
cbCell::asString
std::string & asString()
Definition: cbTable.cpp:24
cbVirtualTable::setInfo
void setInfo(cbMySQLField **v)
Set the Info object.
Definition: cbTable.cpp:117
cbTable::cbTable
cbTable(cbShape< 2 > &shape)
Definition: cbTable.hpp:291
makeShapeRow
cbShape< 2 > makeShapeRow(int32_t a)
Definition: cbTable.hpp:171
cbMySQLType::Date
@ Date
cbTableCol
Definition: cbTable.hpp:254
cbVirtualTable::m_isInfoExtent
bool m_isInfoExtent
Definition: cbTable.hpp:770
cbMySQLCell::setULL
void setULL(unsigned long long value)
Definition: cbTable.cpp:449