mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
clear cppcheck warns
This commit is contained in:
parent
95c968e70b
commit
8c431ba6da
@ -6,6 +6,7 @@
|
||||
<check-headers>true</check-headers>
|
||||
<check-unused-templates>false</check-unused-templates>
|
||||
<max-ctu-depth>10</max-ctu-depth>
|
||||
<max-template-recursion>100</max-template-recursion>
|
||||
<paths>
|
||||
<dir name="hikyuu_cpp/hikyuu"/>
|
||||
</paths>
|
||||
@ -13,7 +14,9 @@
|
||||
<library>boost</library>
|
||||
</libraries>
|
||||
<suppressions>
|
||||
<suppression>noExplicitConstructor</suppression>
|
||||
<suppression>unusedFunction</suppression>
|
||||
<suppression>ConfigurationNotChecked</suppression>
|
||||
<suppression>toomanyconfigs</suppression>
|
||||
<suppression>unknownMacro</suppression>
|
||||
</suppressions>
|
||||
</project>
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
namespace hku {
|
||||
|
||||
KDataImp::KDataImp() : m_start(0), m_end(0) {}
|
||||
KDataImp::KDataImp() : m_start(0), m_end(0), m_have_pos_in_stock(false) {}
|
||||
|
||||
KDataImp::KDataImp(const Stock& stock, const KQuery& query)
|
||||
: m_query(query), m_stock(stock), m_start(0), m_end(0), m_have_pos_in_stock(false) {
|
||||
@ -64,20 +64,6 @@ KDataImp::KDataImp(const Stock& stock, const KQuery& query)
|
||||
|
||||
KDataImp::~KDataImp() {}
|
||||
|
||||
/*bool KDataImp::empty() {
|
||||
if (!m_have_pos_in_stock) {
|
||||
_getPosInStock();
|
||||
}
|
||||
return m_start == m_end ? true : false;
|
||||
}
|
||||
|
||||
size_t KDataImp::size() {
|
||||
if (!m_have_pos_in_stock) {
|
||||
_getPosInStock();
|
||||
}
|
||||
return m_end - m_start;
|
||||
}*/
|
||||
|
||||
size_t KDataImp::startPos() {
|
||||
if (!m_have_pos_in_stock) {
|
||||
_getPosInStock();
|
||||
|
@ -236,6 +236,7 @@ bool operator==(const KQuery&, const KQuery&);
|
||||
bool operator!=(const KQuery&, const KQuery&);
|
||||
|
||||
inline bool operator!=(const KQuery& q1, const KQuery& q2) {
|
||||
// cppcheck-suppress [mismatchingContainerExpression]
|
||||
if (q1.start() != q2.start() || q1.end() != q2.end() || q1.queryType() != q2.queryType() ||
|
||||
q1.kType() != q2.kType() || q1.recoverType() != q2.recoverType()) {
|
||||
return true;
|
||||
|
@ -466,7 +466,7 @@ bool Stock::_getIndexRangeByDateFromBuffer(const KQuery& query, size_t& out_star
|
||||
}
|
||||
|
||||
const KRecordList& kdata = *(m_data->pKData[query.kType()]);
|
||||
size_t mid, low = 0, high = total - 1;
|
||||
size_t mid = total, low = 0, high = total - 1;
|
||||
size_t startpos, endpos;
|
||||
while (low <= high) {
|
||||
if (query.startDatetime() > kdata[high].datetime) {
|
||||
@ -560,10 +560,9 @@ KRecord Stock::getKRecord(const Datetime& datetime, KQuery::KType ktype) const {
|
||||
|
||||
// string ktype(inktype);
|
||||
// to_upper(ktype);
|
||||
|
||||
KQuery query = KQueryByDate(datetime, datetime + Minutes(1), ktype);
|
||||
size_t startix = 0, endix = 0;
|
||||
if (m_data->pKData.find(ktype) != m_data->pKData.end() || m_kdataDriver->isIndexFirst()) {
|
||||
size_t startix = 0, endix = 0;
|
||||
return getIndexRange(query, startix, endix) ? getKRecord(startix, ktype) : Null<KRecord>();
|
||||
}
|
||||
|
||||
|
@ -347,9 +347,9 @@ BlockList StockManager::getBlockList() {
|
||||
|
||||
DatetimeList StockManager::getTradingCalendar(const KQuery& query, const string& market) {
|
||||
Stock stock = getStock("SH000001");
|
||||
size_t start_ix = 0, end_ix = 0;
|
||||
DatetimeList result;
|
||||
if (query.queryType() == KQuery::INDEX) {
|
||||
size_t start_ix = 0, end_ix = 0;
|
||||
if (stock.getIndexRange(query, start_ix, end_ix)) {
|
||||
result = stock.getDatetimeList(KQuery(start_ix, end_ix, query.kType()));
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ bool BaseInfoDriver::init(const Parameter& params) {
|
||||
if (!checkType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HKU_INFO("Using {} BaseInfoDriver", name());
|
||||
return _init();
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
h5file->close();
|
||||
// HKU_INFO("Closed {}", filename);
|
||||
delete h5file;
|
||||
h5file = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -461,7 +460,7 @@ bool H5KDataDriver::_getOtherIndexRangeByDate(const string& market, const string
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t mid, low = 0, high = total - 1;
|
||||
size_t mid = total, low = 0, high = total - 1;
|
||||
uint64_t startDatetime = query.startDatetime().number();
|
||||
H5IndexRecord h5record;
|
||||
while (low <= high) {
|
||||
@ -976,10 +975,9 @@ TransList H5KDataDriver::_getTransList(const string& market, const string& code,
|
||||
|
||||
TransRecord record;
|
||||
result.reserve(total + 2);
|
||||
uint64_t number = 0, second = 0;
|
||||
for (hsize_t i = 0; i < total; i++) {
|
||||
number = pBuf[i].datetime / 100;
|
||||
second = pBuf[i].datetime - number * 100;
|
||||
uint64_t number = pBuf[i].datetime / 100;
|
||||
uint64_t second = pBuf[i].datetime - number * 100;
|
||||
Datetime d(number);
|
||||
record.datetime = Datetime(d.year(), d.month(), d.day(), d.hour(), d.minute(), second);
|
||||
record.price = price_t(pBuf[i].price) * 0.001;
|
||||
@ -1128,10 +1126,9 @@ TransList H5KDataDriver::_getTransList(const string& market, const string& code,
|
||||
|
||||
TransRecord record;
|
||||
result.reserve(total + 2);
|
||||
uint64_t number = 0, second = 0;
|
||||
for (hsize_t i = 0; i < total; i++) {
|
||||
number = pBuf[i].datetime / 100;
|
||||
second = pBuf[i].datetime - number * 100;
|
||||
uint64_t number = pBuf[i].datetime / 100;
|
||||
uint64_t second = pBuf[i].datetime - number * 100;
|
||||
Datetime d(number);
|
||||
record.datetime = Datetime(d.year(), d.month(), d.day(), d.hour(), d.minute(), second);
|
||||
record.price = price_t(pBuf[i].price) * 0.001;
|
||||
|
@ -19,7 +19,8 @@ public:
|
||||
: m_date(0), m_open(0.0), m_high(0.0), m_low(0.0), m_close(0.0), m_amount(0.0), m_count(0.0) {}
|
||||
|
||||
KRecordTable(const string& market, const string& code, const KQuery::KType& ktype)
|
||||
: m_code(code),
|
||||
: m_db_name(fmt::format("{}_{}", market, KQuery::getKTypeName(ktype))),
|
||||
m_code(code),
|
||||
m_date(0),
|
||||
m_open(0.0),
|
||||
m_high(0.0),
|
||||
@ -27,7 +28,7 @@ public:
|
||||
m_close(0.0),
|
||||
m_amount(0.0),
|
||||
m_count(0.0) {
|
||||
m_db_name = fmt::format("{}_{}", market, KQuery::getKTypeName(ktype));
|
||||
// m_db_name = fmt::format("{}_{}", market, KQuery::getKTypeName(ktype));
|
||||
to_lower(m_db_name);
|
||||
};
|
||||
|
||||
|
@ -224,7 +224,7 @@ bool TdxKDataDriver::_getDayIndexRangeByDate(const string& market, const string&
|
||||
struct TdxDayData tdx_data;
|
||||
|
||||
size_t len = sizeof(tdx_data);
|
||||
size_t mid, low = 0, high = total - 1;
|
||||
size_t mid = total, low = 0, high = total - 1;
|
||||
size_t startpos = 0, endpos = 0;
|
||||
while (low <= high) {
|
||||
file.seekg(high * len, file.beg);
|
||||
@ -329,7 +329,7 @@ bool TdxKDataDriver::_getMinIndexRangeByDate(const string& market, const string&
|
||||
struct TdxMinData tdx_data;
|
||||
|
||||
size_t len = sizeof(tdx_data);
|
||||
size_t mid, low = 0, high = total - 1;
|
||||
size_t mid = total, low = 0, high = total - 1;
|
||||
size_t startpos = 0, endpos = 0;
|
||||
while (low <= high) {
|
||||
file.seekg(high * len, file.beg);
|
||||
|
@ -99,7 +99,6 @@ std::string Datetime::str() const {
|
||||
return "+infinity";
|
||||
}
|
||||
|
||||
std::string result;
|
||||
double microseconds = millisecond() * 1000 + microsecond();
|
||||
|
||||
// 和 python datetime 打印方式保持一致
|
||||
|
@ -89,7 +89,6 @@ private:
|
||||
m_connectList.push(p);
|
||||
} else {
|
||||
delete p;
|
||||
p = nullptr;
|
||||
m_count--;
|
||||
}
|
||||
} else {
|
||||
|
@ -259,7 +259,7 @@ int IniParser::getInt(const std::string& section, const std::string& option,
|
||||
|
||||
std::string value_str = get(section, option, default_str);
|
||||
remain = 0;
|
||||
result = std::stoi(value_str, &remain);
|
||||
result = std::stoi(value_str, &remain); // cppcheck-suppress redundantAssignment
|
||||
if (remain != value_str.size()) {
|
||||
throw(std::invalid_argument("This option cannot be converted to an integer! " + value_str));
|
||||
}
|
||||
@ -292,7 +292,7 @@ float IniParser::getFloat(const std::string& section, const std::string& option,
|
||||
|
||||
std::string value_str = get(section, option, default_str);
|
||||
remain = 0;
|
||||
result = std::stof(value_str, &remain);
|
||||
result = std::stof(value_str, &remain); // cppcheck-suppress redundantAssignment
|
||||
if (remain != value_str.size()) {
|
||||
throw(std::invalid_argument("This option cannot be converted to an float! " + value_str));
|
||||
}
|
||||
@ -325,7 +325,7 @@ double IniParser::getDouble(const std::string& section, const std::string& optio
|
||||
|
||||
std::string value_str = get(section, option, default_str);
|
||||
remain = 0;
|
||||
result = std::stod(value_str, &remain);
|
||||
result = std::stod(value_str, &remain); // cppcheck-suppress redundantAssignment
|
||||
if (remain != value_str.size()) {
|
||||
throw(std::invalid_argument("This option cannot be converted to an double! " + value_str));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
* 构造函数
|
||||
* @param param 数据库连接参数
|
||||
*/
|
||||
explicit DBConnectBase(const Parameter& param) noexcept;
|
||||
explicit DBConnectBase(const Parameter& param);
|
||||
virtual ~DBConnectBase() = default;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -176,7 +176,7 @@ typedef shared_ptr<DBConnectBase> DBConnectPtr;
|
||||
// inline方法实现
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
inline DBConnectBase::DBConnectBase(const Parameter& param) noexcept : m_params(param) {}
|
||||
inline DBConnectBase::DBConnectBase(const Parameter& param) : m_params(param) {}
|
||||
|
||||
inline int DBConnectBase::queryInt(const string& query) {
|
||||
SQLStatementPtr st = getStatement(query);
|
||||
|
@ -11,8 +11,7 @@
|
||||
|
||||
namespace hku {
|
||||
|
||||
MySQLConnect::MySQLConnect(const Parameter& param) noexcept
|
||||
: DBConnectBase(param), m_mysql(nullptr) {
|
||||
MySQLConnect::MySQLConnect(const Parameter& param) : DBConnectBase(param), m_mysql(nullptr) {
|
||||
m_mysql = new MYSQL;
|
||||
try {
|
||||
HKU_CHECK(m_mysql, "Failed new MYSQL instance!");
|
||||
|
@ -24,7 +24,7 @@ namespace hku {
|
||||
|
||||
class HKU_API MySQLConnect : public DBConnectBase {
|
||||
public:
|
||||
MySQLConnect(const Parameter& param) noexcept;
|
||||
MySQLConnect(const Parameter& param);
|
||||
virtual ~MySQLConnect();
|
||||
|
||||
virtual bool ping() override;
|
||||
|
@ -21,8 +21,7 @@ static int sqlite_busy_call_back(void* ptr, int count) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
SQLiteConnect::SQLiteConnect(const Parameter& param) noexcept
|
||||
: DBConnectBase(param), m_db(nullptr) {
|
||||
SQLiteConnect::SQLiteConnect(const Parameter& param) : DBConnectBase(param), m_db(nullptr) {
|
||||
try {
|
||||
m_dbname = getParam<string>("db");
|
||||
int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
* (具体可参考 SQLite 帮助)
|
||||
* </pre>
|
||||
*/
|
||||
explicit SQLiteConnect(const Parameter& param) noexcept;
|
||||
explicit SQLiteConnect(const Parameter& param);
|
||||
|
||||
/** 析构函数 */
|
||||
virtual ~SQLiteConnect();
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace hku {
|
||||
|
||||
StealTaskBase::StealTaskBase() : m_done(false) {}
|
||||
StealTaskBase::StealTaskBase() : m_done(false), m_group(nullptr) {}
|
||||
|
||||
StealTaskBase::~StealTaskBase() {}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
StopTask() {}
|
||||
virtual ~StopTask() {}
|
||||
|
||||
void run(){};
|
||||
void run() override{};
|
||||
};
|
||||
|
||||
} // namespace hku
|
||||
|
@ -61,17 +61,11 @@ void StealTaskGroup::join() {
|
||||
}
|
||||
|
||||
// 向主任务队列插入“停止”任务
|
||||
std::vector<StealTaskPtr> stopTaskList;
|
||||
for (auto i = 0; i < m_runnerNum; i++) {
|
||||
auto stopTask = std::make_shared<StopTask>();
|
||||
m_master_queue->push(stopTask);
|
||||
}
|
||||
|
||||
// 等待“停止”任务被执行
|
||||
for (auto& task : stopTaskList) {
|
||||
task->join();
|
||||
}
|
||||
|
||||
m_done = true;
|
||||
|
||||
RunnerList::iterator runnerIter;
|
||||
|
Loading…
Reference in New Issue
Block a user