📄 util.cpp
字号:
#include "config.h"#include <iostream>#include <fstream>#include <string>#include <sstream>#include <loki/Factory.h>#include <boost/scoped_ptr.hpp>#include "response.h"#include "stock.h"using namespace std;namespace StockMarket{bool is_file_exist(const string& filename){ bool isOpen; ifstream ifs; ifs.open(filename.c_str()); isOpen = ifs.is_open(); ifs.close(); return isOpen;}bool stockcode_is_valid(const uchar * s){ bool valid = true; for(int i = 0; i < MarketInfo::StocksCodeLen; ++i) { if(s[i] < '0' || s[i] > '9') { valid = false; break; } } return valid;}const uchar * stock_code_search (const uchar * str, unsigned int len){ const uchar *cp = str; while (len -- > 0) { if(stockcode_is_valid(cp)) return cp; cp++; } return 0;}void log_packet(const char* data, size_t len){ const string path = "F:\\Develop\\stock\\data\\exc_log\\exc"; string filename; for(int i = 0; i < 1000; i++) { stringstream ss; ss << i << ".dat"; filename = path + ss.str(); if(!is_file_exist(filename)) { ofstream ofs(filename.c_str(), ios::out | ios::binary); ofs.write(data, len); break; } }}void test_packet_from_file(const string& filename ){ uchar temp[10 * 1024]; uchar *pData = &temp[0]; const string path = "F:\\Develop\\stock\\data\\exc_log\\"; const string fullname = path + filename; fstream fs(fullname.c_str(), ios::in | ios::binary); if(!fs) return; fs.read((char*)pData, 10*1024); uint len = fs.gcount(); ProcessResponsePacket(pData, len, true);}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -