hikyuu 2.1.0__cp38-none-win_amd64.whl → 2.1.1__cp38-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  2. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  3. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  4. hikyuu/cpp/core38.pyd +0 -0
  5. hikyuu/cpp/hikyuu.dll +0 -0
  6. hikyuu/extend.py +3 -1
  7. hikyuu/gui/HikyuuTDX.py +11 -6
  8. hikyuu/include/hikyuu/DataType.h +2 -1
  9. hikyuu/include/hikyuu/KRecord.h +1 -1
  10. hikyuu/include/hikyuu/StockManager.h +3 -0
  11. hikyuu/include/hikyuu/analysis/combinate.h +1 -1
  12. hikyuu/include/hikyuu/config.h +0 -12
  13. hikyuu/include/hikyuu/strategy/AccountTradeManager.h +3 -1
  14. hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
  15. hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
  16. hikyuu/include/hikyuu/{Log.h → utilities/Log.h} +91 -113
  17. hikyuu/include/hikyuu/utilities/Null.h +1 -0
  18. hikyuu/include/hikyuu/utilities/Parameter.h +2 -1
  19. hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
  20. hikyuu/include/hikyuu/utilities/SpendTimer.h +10 -9
  21. hikyuu/include/hikyuu/utilities/TimerManager.h +2 -2
  22. hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
  23. hikyuu/include/hikyuu/utilities/arithmetic.h +69 -33
  24. hikyuu/include/hikyuu/utilities/base64.h +59 -0
  25. hikyuu/include/hikyuu/utilities/config.h +41 -0
  26. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +41 -31
  27. hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +24 -13
  28. hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +48 -48
  29. hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +10 -0
  30. hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +5 -22
  31. hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +3 -3
  32. hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +1 -1
  33. hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +1 -1
  34. hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +7 -7
  35. hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +1 -2
  36. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +9 -9
  37. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +18 -18
  38. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +3 -3
  39. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +2 -2
  40. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +6 -6
  41. hikyuu/include/hikyuu/{exception.h → utilities/exception.h} +1 -0
  42. hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
  43. hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
  44. hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
  45. hikyuu/include/hikyuu/utilities/{IniParser.h → ini_parser/IniParser.h} +10 -5
  46. hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
  47. hikyuu/include/hikyuu/utilities/md5.h +41 -0
  48. hikyuu/include/hikyuu/utilities/mo/__init__.py +1 -0
  49. hikyuu/include/hikyuu/utilities/mo/mo.h +48 -0
  50. hikyuu/include/hikyuu/utilities/mo/moFileReader.h +836 -0
  51. hikyuu/include/hikyuu/{global → utilities}/node/NodeClient.h +25 -18
  52. hikyuu/include/hikyuu/{global → utilities}/node/NodeError.h +1 -1
  53. hikyuu/include/hikyuu/{global → utilities}/node/NodeMessage.h +3 -2
  54. hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
  55. hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
  56. hikyuu/include/hikyuu/utilities/os.h +16 -15
  57. hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
  58. hikyuu/include/hikyuu/utilities/string_view.h +70 -0
  59. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +3 -3
  60. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +3 -3
  61. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +3 -3
  62. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +3 -3
  63. hikyuu/include/hikyuu/version.h +4 -4
  64. hikyuu/sqlite3.dll +0 -0
  65. hikyuu/vcruntime140.dll +0 -0
  66. hikyuu/vcruntime140_1.dll +0 -0
  67. hikyuu-2.1.1.dist-info/METADATA +115 -0
  68. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/RECORD +73 -53
  69. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/top_level.txt +4 -1
  70. hikyuu/README.rst +0 -79
  71. hikyuu-2.1.0.dist-info/METADATA +0 -126
  72. /hikyuu/include/hikyuu/{global/node → utilities/http_client}/__init__.py +0 -0
  73. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/LICENSE +0 -0
  74. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/WHEEL +0 -0
  75. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/entry_points.txt +0 -0
@@ -20,8 +20,8 @@
20
20
  #include <fmt/ostream.h>
21
21
  #include <boost/date_time/posix_time/posix_time.hpp>
22
22
 
23
- #ifndef HKU_API
24
- #define HKU_API
23
+ #ifndef HKU_UTILS_API
24
+ #define HKU_UTILS_API
25
25
  #endif
26
26
 
27
27
  namespace hku {
@@ -33,7 +33,7 @@ namespace bd = boost::gregorian;
33
33
  * 时长,用于时间计算
34
34
  * @ingroup DataType
35
35
  */
36
- class HKU_API TimeDelta {
36
+ class HKU_UTILS_API TimeDelta {
37
37
  public:
38
38
  /**
39
39
  * 构造函数
@@ -58,11 +58,14 @@ public:
58
58
  /** 通过 boost::posix_time::time_duration 构造 */
59
59
  explicit TimeDelta(bt::time_duration td);
60
60
 
61
+ /** 从字符串构造,格式:-1 days, hh:mm:ss.000000) */
62
+ explicit TimeDelta(const std::string& delta);
63
+
61
64
  /** 赋值构造函数 */
62
- TimeDelta(const TimeDelta&) = default;
65
+ TimeDelta(const TimeDelta &) = default;
63
66
 
64
67
  /** 赋值拷贝函数 */
65
- TimeDelta& operator=(const TimeDelta& other) {
68
+ TimeDelta &operator=(const TimeDelta &other) {
66
69
  if (this != &other) {
67
70
  m_duration = other.m_duration;
68
71
  }
@@ -259,8 +262,8 @@ private:
259
262
  static constexpr const int64_t m_one_day_ticks = 24 * 60 * 60 * 1000000LL;
260
263
  };
261
264
 
262
- std::ostream& operator<<(std::ostream& out, TimeDelta td);
263
- inline std::ostream& operator<<(std::ostream& out, TimeDelta td) {
265
+ std::ostream &operator<<(std::ostream &out, TimeDelta td);
266
+ inline std::ostream &operator<<(std::ostream &out, TimeDelta td) {
264
267
  out << td.str();
265
268
  return out;
266
269
  }
@@ -280,28 +283,28 @@ inline TimeDelta Days(int64_t days) {
280
283
  * @param hours 小时数
281
284
  * @ingroup DataType
282
285
  */
283
- TimeDelta HKU_API Hours(int64_t hours);
286
+ TimeDelta HKU_UTILS_API Hours(int64_t hours);
284
287
 
285
288
  /**
286
289
  * TimeDelta 快捷创建函数
287
290
  * @param mins 分钟数
288
291
  * @ingroup DataType
289
292
  */
290
- TimeDelta HKU_API Minutes(int64_t mins);
293
+ TimeDelta HKU_UTILS_API Minutes(int64_t mins);
291
294
 
292
295
  /**
293
296
  * TimeDelta 快捷创建函数
294
297
  * @param secs 秒数
295
298
  * @ingroup DataType
296
299
  */
297
- TimeDelta HKU_API Seconds(int64_t secs);
300
+ TimeDelta HKU_UTILS_API Seconds(int64_t secs);
298
301
 
299
302
  /**
300
303
  * TimeDelta 快捷创建函数
301
304
  * @param milliseconds 毫秒数
302
305
  * @ingroup DataType
303
306
  */
304
- TimeDelta HKU_API Milliseconds(int64_t milliseconds);
307
+ TimeDelta HKU_UTILS_API Milliseconds(int64_t milliseconds);
305
308
 
306
309
  /**
307
310
  * TimeDelta 快捷创建函数
@@ -315,15 +318,23 @@ inline TimeDelta Microseconds(int64_t microsecs) {
315
318
 
316
319
  } /* namespace hku */
317
320
 
321
+ namespace std {
322
+
323
+ inline string to_string(const hku::TimeDelta &delta) {
324
+ return delta.str();
325
+ }
326
+
327
+ } // namespace std
328
+
318
329
  #if FMT_VERSION >= 90000
319
330
  template <>
320
331
  struct fmt::formatter<hku::TimeDelta> {
321
- constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
332
+ constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
322
333
  return ctx.end();
323
334
  }
324
335
 
325
336
  template <typename FormatContext>
326
- auto format(const hku::TimeDelta& d, FormatContext& ctx) const -> decltype(ctx.out()) {
337
+ auto format(const hku::TimeDelta &d, FormatContext &ctx) const -> decltype(ctx.out()) {
327
338
  return fmt::format_to(ctx.out(), "{}", d.str());
328
339
  }
329
340
  };
@@ -13,23 +13,23 @@
13
13
  #include <vector>
14
14
  #include <fmt/format.h>
15
15
  #include <fmt/ranges.h>
16
- #include "../../Log.h"
16
+ #include "hikyuu/utilities/Log.h"
17
17
 
18
- #ifndef HKU_API
19
- #define HKU_API
18
+ #ifndef HKU_UTILS_API
19
+ #define HKU_UTILS_API
20
20
  #endif
21
21
 
22
22
  namespace hku {
23
23
 
24
24
  struct ASC {
25
- explicit ASC(const char* name) : name(name) {}
26
- explicit ASC(const std::string& name) : name(name) {}
25
+ explicit ASC(const char *name) : name(name) {}
26
+ explicit ASC(const std::string &name) : name(name) {}
27
27
  std::string name;
28
28
  };
29
29
 
30
30
  struct DESC {
31
- explicit DESC(const char* name) : name(name) {}
32
- explicit DESC(const std::string& name) : name(name) {}
31
+ explicit DESC(const char *name) : name(name) {}
32
+ explicit DESC(const std::string &name) : name(name) {}
33
33
  std::string name;
34
34
  };
35
35
 
@@ -38,50 +38,50 @@ struct LIMIT {
38
38
  int limit = 1;
39
39
  };
40
40
 
41
- class HKU_API DBCondition {
41
+ class HKU_UTILS_API DBCondition {
42
42
  public:
43
43
  DBCondition() = default;
44
- DBCondition(const DBCondition&) = default;
45
- DBCondition(DBCondition&& rv) : m_condition(std::move(rv.m_condition)) {}
44
+ DBCondition(const DBCondition &) = default;
45
+ DBCondition(DBCondition &&rv) : m_condition(std::move(rv.m_condition)) {}
46
46
 
47
- explicit DBCondition(const char* cond) : m_condition(cond) {}
48
- explicit DBCondition(const std::string& cond) : m_condition(cond) {}
47
+ explicit DBCondition(const char *cond) : m_condition(cond) {}
48
+ explicit DBCondition(const std::string &cond) : m_condition(cond) {}
49
49
 
50
- DBCondition& operator=(const DBCondition&) = default;
51
- DBCondition& operator=(DBCondition&& rv) {
50
+ DBCondition &operator=(const DBCondition &) = default;
51
+ DBCondition &operator=(DBCondition &&rv) {
52
52
  if (this != &rv) {
53
53
  m_condition = std::move(rv.m_condition);
54
54
  }
55
55
  return *this;
56
56
  }
57
57
 
58
- DBCondition& operator&(const DBCondition& other);
59
- DBCondition& operator|(const DBCondition& other);
58
+ DBCondition &operator&(const DBCondition &other);
59
+ DBCondition &operator|(const DBCondition &other);
60
60
 
61
61
  enum ORDERBY { ORDER_ASC, ORDER_DESC };
62
62
 
63
- void orderBy(const std::string& field, ORDERBY order) {
63
+ void orderBy(const std::string &field, ORDERBY order) {
64
64
  m_condition = order == ORDERBY::ORDER_ASC
65
65
  ? fmt::format("{} order by {} ASC", m_condition, field)
66
66
  : fmt::format("{} order by {} DESC", m_condition, field);
67
67
  }
68
68
 
69
- DBCondition& operator+(const ASC& asc) {
69
+ DBCondition &operator+(const ASC &asc) {
70
70
  orderBy(asc.name, ORDER_ASC);
71
71
  return *this;
72
72
  }
73
73
 
74
- DBCondition& operator+(const DESC& desc) {
74
+ DBCondition &operator+(const DESC &desc) {
75
75
  orderBy(desc.name, ORDER_DESC);
76
76
  return *this;
77
77
  }
78
78
 
79
- DBCondition& operator+(const LIMIT& limit) {
79
+ DBCondition &operator+(const LIMIT &limit) {
80
80
  m_condition = fmt::format("{} limit {}", m_condition, limit.limit);
81
81
  return *this;
82
82
  }
83
83
 
84
- const std::string& str() const {
84
+ const std::string &str() const {
85
85
  return m_condition;
86
86
  }
87
87
 
@@ -90,27 +90,27 @@ private:
90
90
  };
91
91
 
92
92
  struct Field {
93
- explicit Field(const char* name) : name(name) {}
94
- explicit Field(const std::string& name) : name(name) {}
93
+ explicit Field(const char *name) : name(name) {}
94
+ explicit Field(const std::string &name) : name(name) {}
95
95
 
96
96
  // in 和 not_in 不支持 字符串,一般不会用到 in ("stra", "strb") 的 SQL 操作
97
97
  template <typename T>
98
- DBCondition in(const std::vector<T>& vals) {
98
+ DBCondition in(const std::vector<T> &vals) {
99
99
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
100
100
  return DBCondition(fmt::format("({} in ({}))", name, fmt::join(vals, ",")));
101
101
  }
102
102
 
103
103
  template <typename T>
104
- DBCondition not_in(const std::vector<T>& vals) {
104
+ DBCondition not_in(const std::vector<T> &vals) {
105
105
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
106
106
  return DBCondition(fmt::format("({} not in ({}))", name, fmt::join(vals, ",")));
107
107
  }
108
108
 
109
- DBCondition like(const std::string& pattern) {
109
+ DBCondition like(const std::string &pattern) {
110
110
  return DBCondition(fmt::format(R"(({} like "{}"))", name, pattern));
111
111
  }
112
112
 
113
- DBCondition like(const char* pattern) {
113
+ DBCondition like(const char *pattern) {
114
114
  return DBCondition(fmt::format(R"(({} like "{}"))", name, pattern));
115
115
  }
116
116
 
@@ -120,7 +120,7 @@ struct Field {
120
120
  // linux下类成员函数模板特化必须放在类外实现
121
121
  // 否则编译时会报:explicit specialization in non-namespace scope
122
122
  template <>
123
- inline DBCondition Field::in<std::string>(const std::vector<std::string>& vals) {
123
+ inline DBCondition Field::in<std::string>(const std::vector<std::string> &vals) {
124
124
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
125
125
  std::ostringstream out;
126
126
  out << "(" << name << " in (";
@@ -133,7 +133,7 @@ inline DBCondition Field::in<std::string>(const std::vector<std::string>& vals)
133
133
  }
134
134
 
135
135
  template <>
136
- inline DBCondition Field::not_in<std::string>(const std::vector<std::string>& vals) {
136
+ inline DBCondition Field::not_in<std::string>(const std::vector<std::string> &vals) {
137
137
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
138
138
  std::ostringstream out;
139
139
  out << "(" << name << " not in (";
@@ -145,103 +145,103 @@ inline DBCondition Field::not_in<std::string>(const std::vector<std::string>& va
145
145
  return DBCondition(out.str());
146
146
  }
147
147
 
148
- inline std::ostream& operator<<(std::ostream& out, const DBCondition& d) {
148
+ inline std::ostream &operator<<(std::ostream &out, const DBCondition &d) {
149
149
  out << d.str();
150
150
  return out;
151
151
  }
152
152
 
153
153
  template <typename T>
154
- inline DBCondition operator==(const Field& field, T val) {
154
+ inline DBCondition operator==(const Field &field, T val) {
155
155
  std::ostringstream out;
156
156
  out << "(" << field.name << "=" << val << ")";
157
157
  return DBCondition(out.str());
158
158
  }
159
159
 
160
160
  template <typename T>
161
- inline DBCondition operator!=(const Field& field, T val) {
161
+ inline DBCondition operator!=(const Field &field, T val) {
162
162
  std::ostringstream out;
163
163
  out << "(" << field.name << "<>" << val << ")";
164
164
  return DBCondition(out.str());
165
165
  }
166
166
 
167
167
  template <typename T>
168
- inline DBCondition operator>(const Field& field, T val) {
168
+ inline DBCondition operator>(const Field &field, T val) {
169
169
  std::ostringstream out;
170
170
  out << "(" << field.name << ">" << val << ")";
171
171
  return DBCondition(out.str());
172
172
  }
173
173
 
174
174
  template <typename T>
175
- inline DBCondition operator>=(const Field& field, T val) {
175
+ inline DBCondition operator>=(const Field &field, T val) {
176
176
  std::ostringstream out;
177
177
  out << "(" << field.name << ">=" << val << ")";
178
178
  return DBCondition(out.str());
179
179
  }
180
180
 
181
181
  template <typename T>
182
- inline DBCondition operator<(const Field& field, T val) {
182
+ inline DBCondition operator<(const Field &field, T val) {
183
183
  std::ostringstream out;
184
184
  out << "(" << field.name << "<" << val << ")";
185
185
  return DBCondition(out.str());
186
186
  }
187
187
 
188
188
  template <typename T>
189
- inline DBCondition operator<=(const Field& field, T val) {
189
+ inline DBCondition operator<=(const Field &field, T val) {
190
190
  std::ostringstream out;
191
191
  out << "(" << field.name << "<=" << val << ")";
192
192
  return DBCondition(out.str());
193
193
  }
194
194
 
195
195
  template <>
196
- inline DBCondition operator!=(const Field& field, const char* val) {
196
+ inline DBCondition operator!=(const Field &field, const char *val) {
197
197
  return DBCondition(fmt::format(R"(({}<>"{}"))", field.name, val));
198
198
  }
199
199
 
200
200
  template <>
201
- inline DBCondition operator>(const Field& field, const char* val) {
201
+ inline DBCondition operator>(const Field &field, const char *val) {
202
202
  return DBCondition(fmt::format(R"(({}>"{}"))", field.name, val));
203
203
  }
204
204
 
205
205
  template <>
206
- inline DBCondition operator<(const Field& field, const char* val) {
206
+ inline DBCondition operator<(const Field &field, const char *val) {
207
207
  return DBCondition(fmt::format(R"(({}<"{}"))", field.name, val));
208
208
  }
209
209
 
210
210
  template <>
211
- inline DBCondition operator>=(const Field& field, const char* val) {
211
+ inline DBCondition operator>=(const Field &field, const char *val) {
212
212
  return DBCondition(fmt::format(R"(({}>="{}"))", field.name, val));
213
213
  }
214
214
 
215
215
  template <>
216
- inline DBCondition operator<=(const Field& field, const char* val) {
216
+ inline DBCondition operator<=(const Field &field, const char *val) {
217
217
  return DBCondition(fmt::format(R"(({}<="{}"))", field.name, val));
218
218
  }
219
219
 
220
- inline DBCondition operator==(const Field& field, const std::string& val) {
220
+ inline DBCondition operator==(const Field &field, const std::string &val) {
221
221
  return DBCondition(fmt::format(R"(({}="{}"))", field.name, val));
222
222
  }
223
223
 
224
- inline DBCondition operator!=(const Field& field, const std::string& val) {
224
+ inline DBCondition operator!=(const Field &field, const std::string &val) {
225
225
  return DBCondition(fmt::format(R"(({}<>"{}"))", field.name, val));
226
226
  }
227
227
 
228
- inline DBCondition operator>(const Field& field, const std::string& val) {
228
+ inline DBCondition operator>(const Field &field, const std::string &val) {
229
229
  return DBCondition(fmt::format(R"(({}>"{}"))", field.name, val));
230
230
  }
231
231
 
232
- inline DBCondition operator<(const Field& field, const std::string& val) {
232
+ inline DBCondition operator<(const Field &field, const std::string &val) {
233
233
  return DBCondition(fmt::format(R"(({}<"{}"))", field.name, val));
234
234
  }
235
235
 
236
- inline DBCondition operator>=(const Field& field, const std::string& val) {
236
+ inline DBCondition operator>=(const Field &field, const std::string &val) {
237
237
  return DBCondition(fmt::format(R"(({}>="{}"))", field.name, val));
238
238
  }
239
239
 
240
- inline DBCondition operator<=(const Field& field, const std::string& val) {
240
+ inline DBCondition operator<=(const Field &field, const std::string &val) {
241
241
  return DBCondition(fmt::format(R"(({}<="{}"))", field.name, val));
242
242
  }
243
243
 
244
- inline DBCondition operator==(const Field& field, const char* val) {
244
+ inline DBCondition operator==(const Field &field, const char *val) {
245
245
  return DBCondition(fmt::format(R"(({}="{}"))", field.name, val));
246
246
  }
247
247
 
@@ -17,4 +17,14 @@
17
17
  #include "TableMacro.h"
18
18
  #include "DBUpgrade.h"
19
19
 
20
+ #include "hikyuu/utilities/config.h"
21
+ #if HKU_ENABLE_MYSQL
22
+ #include "mysql/MySQLConnect.h"
23
+ #endif
24
+
25
+ #if HKU_ENABLE_SQLITE
26
+ #include "sqlite/SQLiteConnect.h"
27
+ #include "sqlite/SQLiteUtil.h"
28
+ #endif
29
+
20
30
  #endif /* HIKYUU_DB_CONNECT_H */
@@ -10,8 +10,8 @@
10
10
  #ifndef HIKYUU_DB_CONNECT_DBCONNECTBASE_H
11
11
  #define HIKYUU_DB_CONNECT_DBCONNECTBASE_H
12
12
 
13
- #include "../../DataType.h"
14
13
  #include "../../utilities/Parameter.h"
14
+ #include "../Null.h"
15
15
  #include "DBCondition.h"
16
16
  #include "SQLStatementBase.h"
17
17
  #include "SQLException.h"
@@ -25,7 +25,7 @@ class SQLResultSet;
25
25
  * 数据库连接基类
26
26
  * @ingroup DBConnect
27
27
  */
28
- class HKU_API DBConnectBase : public std::enable_shared_from_this<DBConnectBase> {
28
+ class HKU_UTILS_API DBConnectBase : public std::enable_shared_from_this<DBConnectBase> {
29
29
  PARAMETER_SUPPORT // NOSONAR
30
30
 
31
31
  public :
@@ -297,7 +297,7 @@ private:
297
297
  };
298
298
 
299
299
  /** @ingroup DBConnect */
300
- typedef shared_ptr<DBConnectBase> DBConnectPtr;
300
+ typedef std::shared_ptr<DBConnectBase> DBConnectPtr;
301
301
 
302
302
  //-------------------------------------------------------------------------
303
303
  // inline方法实现
@@ -366,19 +366,16 @@ void DBConnectBase::save(T &item, bool autotrans) {
366
366
  if (autotrans) {
367
367
  commit();
368
368
  }
369
-
370
369
  } catch (hku::SQLException &e) {
371
370
  if (autotrans) {
372
371
  rollback();
373
372
  }
374
373
  SQL_THROW(e.errcode(), "failed save! sql: {}! {}", st->getSqlString(), e.what());
375
-
376
374
  } catch (std::exception &e) {
377
375
  if (autotrans) {
378
376
  rollback();
379
377
  }
380
378
  HKU_THROW("failed save! sql: {}! {}", st->getSqlString(), e.what());
381
-
382
379
  } catch (...) {
383
380
  if (autotrans) {
384
381
  rollback();
@@ -409,19 +406,16 @@ void DBConnectBase::batchSave(InputIterator first, InputIterator last, bool auto
409
406
  if (autotrans) {
410
407
  commit();
411
408
  }
412
-
413
409
  } catch (hku::SQLException &e) {
414
410
  if (autotrans) {
415
411
  rollback();
416
412
  }
417
413
  SQL_THROW(e.errcode(), "failed batch save! sql: {}! {}", st->getSqlString(), e.what());
418
-
419
414
  } catch (std::exception &e) {
420
415
  if (autotrans) {
421
416
  rollback();
422
417
  }
423
418
  HKU_THROW("failed batch save! sql: {}! {}", st->getSqlString(), e.what());
424
-
425
419
  } catch (...) {
426
420
  if (autotrans) {
427
421
  rollback();
@@ -431,7 +425,7 @@ void DBConnectBase::batchSave(InputIterator first, InputIterator last, bool auto
431
425
  }
432
426
 
433
427
  template <typename T>
434
- void DBConnectBase::load(T &item, const string &where) {
428
+ void DBConnectBase::load(T &item, const std::string &where) {
435
429
  std::ostringstream sql;
436
430
  if (where != "") {
437
431
  sql << T::getSelectSQL() << " where " << where << " limit 1";
@@ -451,7 +445,7 @@ void DBConnectBase::load(T &item, const DBCondition &cond) {
451
445
  }
452
446
 
453
447
  template <typename Container>
454
- void DBConnectBase::batchLoad(Container &container, const string &where) {
448
+ void DBConnectBase::batchLoad(Container &container, const std::string &where) {
455
449
  std::ostringstream sql;
456
450
  if (where != "") {
457
451
  sql << Container::value_type::getSelectSQL() << " where " << where;
@@ -513,19 +507,16 @@ void DBConnectBase::batchUpdate(InputIterator first, InputIterator last, bool au
513
507
  if (autotrans) {
514
508
  commit();
515
509
  }
516
-
517
510
  } catch (hku::SQLException &e) {
518
511
  if (autotrans) {
519
512
  rollback();
520
513
  }
521
514
  SQL_THROW(e.errcode(), "failed batch save! sql: {}! {}", st->getSqlString(), e.what());
522
-
523
515
  } catch (std::exception &e) {
524
516
  if (autotrans) {
525
517
  rollback();
526
518
  }
527
519
  HKU_THROW("failed batch update! sql: {}! {}", st->getSqlString(), e.what());
528
-
529
520
  } catch (...) {
530
521
  if (autotrans) {
531
522
  rollback();
@@ -570,19 +561,16 @@ void DBConnectBase::remove(T &item, bool autotrans) {
570
561
  commit();
571
562
  }
572
563
  item.rowid(0);
573
-
574
564
  } catch (hku::SQLException &e) {
575
565
  if (autotrans) {
576
566
  rollback();
577
567
  }
578
568
  SQL_THROW(e.errcode(), "failed delete! sql: {}! {}", st->getSqlString(), e.what());
579
-
580
569
  } catch (std::exception &e) {
581
570
  if (autotrans) {
582
571
  rollback();
583
572
  }
584
573
  HKU_THROW("failed delete! sql: {}! {}", st->getSqlString(), e.what());
585
-
586
574
  } catch (...) {
587
575
  if (autotrans) {
588
576
  rollback();
@@ -610,19 +598,16 @@ void DBConnectBase::batchRemove(InputIterator first, InputIterator last, bool au
610
598
  if (autotrans) {
611
599
  commit();
612
600
  }
613
-
614
601
  } catch (hku::SQLException &e) {
615
602
  if (autotrans) {
616
603
  rollback();
617
604
  }
618
605
  SQL_THROW(e.errcode(), "failed batch delete! {}", e.what());
619
-
620
606
  } catch (std::exception &e) {
621
607
  if (autotrans) {
622
608
  rollback();
623
609
  }
624
610
  HKU_THROW("failed batch delete! {}", e.what());
625
-
626
611
  } catch (...) {
627
612
  if (autotrans) {
628
613
  rollback();
@@ -645,13 +630,11 @@ inline void DBConnectBase::remove(const std::string &tablename, const std::strin
645
630
  if (autotrans) {
646
631
  commit();
647
632
  }
648
-
649
633
  } catch (hku::SQLException &e) {
650
634
  if (autotrans) {
651
635
  rollback();
652
636
  }
653
637
  SQL_THROW(e.errcode(), "Failed exec sql: {}! {}", sql, e.what());
654
-
655
638
  } catch (std::exception &e) {
656
639
  if (autotrans) {
657
640
  rollback();
@@ -21,8 +21,8 @@ namespace hku {
21
21
  * @param create_script 数据库创建脚本,若对应的数据库不存在则使用该脚本创建数据库
22
22
  * @ingroup DataDriver
23
23
  */
24
- void HKU_API DBUpgrade(const DBConnectPtr &driver, const char *module_name,
25
- const std::vector<std::string> &upgrade_scripts, int start_version = 2,
26
- const char *create_script = nullptr);
24
+ void HKU_UTILS_API DBUpgrade(const DBConnectPtr &driver, const char *module_name,
25
+ const std::vector<std::string> &upgrade_scripts, int start_version = 2,
26
+ const char *create_script = nullptr);
27
27
 
28
28
  } // namespace hku
@@ -8,7 +8,7 @@
8
8
  #pragma once
9
9
 
10
10
  #include <fmt/format.h>
11
- #include "hikyuu/exception.h"
11
+ #include "hikyuu/utilities/exception.h"
12
12
 
13
13
  namespace hku {
14
14
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  #include <iterator>
11
11
  #include "hikyuu/utilities/arithmetic.h"
12
- #include "hikyuu/Log.h"
12
+ #include "hikyuu/utilities/Log.h"
13
13
  #include "hikyuu/utilities/osdef.h"
14
14
  #include "DBConnectBase.h"
15
15
 
@@ -21,7 +21,7 @@ namespace hku {
21
21
  class DBConnectBase;
22
22
 
23
23
  /** @ingroup DBConnect */
24
- typedef shared_ptr<DBConnectBase> DBConnectPtr;
24
+ typedef std::shared_ptr<DBConnectBase> DBConnectPtr;
25
25
 
26
26
  /** @ingroup DBConnect */
27
27
  class null_blob_exception : public exception {
@@ -34,19 +34,19 @@ public:
34
34
  * SQL Statement 基类
35
35
  * @ingroup DBConnect
36
36
  */
37
- class HKU_API SQLStatementBase {
37
+ class HKU_UTILS_API SQLStatementBase {
38
38
  public:
39
39
  /**
40
40
  * 构造函数
41
41
  * @param driver 数据库连接
42
42
  * @param sql_statement SQL语句
43
43
  */
44
- SQLStatementBase(DBConnectBase *driver, const string &sql_statement);
44
+ SQLStatementBase(DBConnectBase *driver, const std::string &sql_statement);
45
45
 
46
46
  virtual ~SQLStatementBase() = default;
47
47
 
48
48
  /** 获取构建时传入的表达式SQL语句 */
49
- const string &getSqlString() const;
49
+ const std::string &getSqlString() const;
50
50
 
51
51
  /** 获取数据驱动 */
52
52
  DBConnectBase *getConnect() const;
@@ -163,7 +163,7 @@ protected:
163
163
  };
164
164
 
165
165
  /** @ingroup DBConnect */
166
- typedef shared_ptr<SQLStatementBase> SQLStatementPtr;
166
+ typedef std::shared_ptr<SQLStatementBase> SQLStatementPtr;
167
167
 
168
168
  inline SQLStatementBase ::SQLStatementBase(DBConnectBase *driver, const std::string &sql_statement)
169
169
  : m_driver(driver), m_sql_string(sql_statement) {
@@ -183,7 +183,7 @@ inline void SQLStatementBase::bind(int idx, float item) {
183
183
  }
184
184
 
185
185
  inline void SQLStatementBase::exec() {
186
- #ifdef HKU_SQL_TRACE
186
+ #if HKU_SQL_TRACE
187
187
  HKU_DEBUG(m_sql_string);
188
188
  #endif
189
189
  sub_exec();
@@ -277,7 +277,7 @@ inline void SQLStatementBase::getColumn(int idx, std::vector<char> &item) {
277
277
  template <typename T>
278
278
  typename std::enable_if<!std::numeric_limits<T>::is_integer>::type SQLStatementBase::getColumn(
279
279
  int idx, T &item) {
280
- string tmp;
280
+ std::string tmp;
281
281
  try {
282
282
  sub_getColumnAsBlob(idx, tmp);
283
283
  } catch (null_blob_exception &) {
@@ -2168,8 +2168,7 @@ public:
2168
2168
  }
2169
2169
 
2170
2170
  #define TABLE_NO_AUTOID_BIND12(ROWID, table, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) \
2171
- pprivate: \
2172
- uint64_t m_rowid = 0; \
2171
+ pprivate : uint64_t m_rowid = 0; \
2173
2172
  \
2174
2173
  public: \
2175
2174
  bool valid() const { \