Skip to content

Commit

Permalink
Merge pull request fasiondog#137 from fasiondog/feature/tools
Browse files Browse the repository at this point in the history
Feature/tools fixed windows 下板块读取错误
  • Loading branch information
fasiondog authored Dec 9, 2023
2 parents d84f508 + 03a7530 commit 1cf8083
Show file tree
Hide file tree
Showing 12 changed files with 29,572 additions and 17,949 deletions.
1 change: 0 additions & 1 deletion hikyuu_cpp/hikyuu/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* Author: fasiondog
*/

#include <boost/algorithm/string.hpp>
#include "StockManager.h"

namespace hku {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include <fstream>
#include <boost/algorithm/string.hpp>
#include "hikyuu/utilities/arithmetic.h"
#include "QLBlockInfoDriver.h"

namespace hku {
Expand Down Expand Up @@ -36,9 +36,9 @@ Block QLBlockInfoDriver ::getBlock(const string& category, const string& name) {
string line_str;
string section, market, code;
bool is_find = false;
string gb_name = utf8_to_gb(name);
// string gb_name = utf8_to_gb(name);
while (std::getline(inifile, line_str)) {
boost::trim(line_str);
trim(line_str);

// 空行或注释行,跳过
if (line_str.empty() || line_str.at(0) == ';') {
Expand All @@ -49,7 +49,7 @@ Block QLBlockInfoDriver ::getBlock(const string& category, const string& name) {
size_t pos = line_str.find(';');
if (pos != std::string::npos) {
line_str.assign(line_str, 0, pos);
boost::trim(line_str);
trim(line_str);
}

// section行
Expand All @@ -63,12 +63,12 @@ Block QLBlockInfoDriver ::getBlock(const string& category, const string& name) {
}

section.assign(line_str, 1, len - 2);
boost::trim(section);
trim(section);
if (section.empty()) {
continue;
}

if (section == gb_name) {
if (section == name) {
is_find = true;
}
}
Expand All @@ -78,8 +78,8 @@ Block QLBlockInfoDriver ::getBlock(const string& category, const string& name) {
if (pos != std::string::npos) {
market.assign(line_str, 0, pos);
code.assign(line_str, pos + 1, line_str.size());
boost::trim(market);
boost::trim(code);
trim(market);
trim(code);
if (market == "0") {
result.add("SH" + code);
} else {
Expand Down Expand Up @@ -115,7 +115,7 @@ BlockList QLBlockInfoDriver::getBlockList(const string& category) {
std::string line_str;
Block block;
while (std::getline(inifile, line_str)) {
boost::trim(line_str);
trim(line_str);

// 空行或注释行,跳过
if (line_str.empty() || line_str.at(0) == ';')
Expand All @@ -125,7 +125,7 @@ BlockList QLBlockInfoDriver::getBlockList(const string& category) {
size_t pos = line_str.find(';');
if (pos != std::string::npos) {
line_str.assign(line_str, 0, pos);
boost::trim(line_str);
trim(line_str);
}

// section行
Expand All @@ -135,11 +135,11 @@ BlockList QLBlockInfoDriver::getBlockList(const string& category) {
continue;

section.assign(line_str, 1, len - 2);
boost::trim(section);
trim(section);
if (section.empty())
continue;

block = Block(category, gb_to_utf8(section));
block = Block(category, section);
result.push_back(block);

} else {
Expand All @@ -151,12 +151,12 @@ BlockList QLBlockInfoDriver::getBlockList(const string& category) {
continue;

key.assign(line_str, 0, pos);
boost::trim(key);
trim(key);
if (key.empty())
continue;

value.assign(line_str, pos + 1, std::string::npos);
boost::trim(value);
trim(value);
if (value.empty())
continue;

Expand Down
2 changes: 1 addition & 1 deletion hikyuu_cpp/hikyuu/utilities/arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ inline void trim(std::string& s) {

s.erase(0, s.find_first_not_of(" "));
s.erase(s.find_last_not_of(" ") + 1);
s.erase(s.find_last_not_of("\n") + 1);
s.erase(s.find_last_not_of("\r") + 1);
s.erase(s.find_last_not_of("\n") + 1);
}

/**
Expand Down
Loading

0 comments on commit 1cf8083

Please sign in to comment.