Merge branch 'dev' of https://github.com/vnpy/vnpy into dev

This commit is contained in:
vn.py 2018-08-05 23:06:43 +08:00
commit 5001d6ef9d
3 changed files with 23 additions and 8 deletions

9
.gitignore vendored
View File

@ -43,6 +43,15 @@ Release/
*.log
*.bak
# 编译临时文件夹
build/
# CMake临时文件
CMakeCache.txt
CMakeFiles/
build/cmake_install.cmake
build/Makefile
# 目录
.idea
.vscode

View File

@ -4,6 +4,10 @@ cache: pip
python:
- 2.7
- 3.6
branches:
only:
- master
- dev
install:
- pip install -r requirements.txt
- pip install flake8 # pytest # add another testing frameworks later

View File

@ -7,7 +7,7 @@
///从Python对象到C++类型转换用的函数
///-------------------------------------------------------------------------------------
void getInt(dict d, string key, int *value)
void getInt(dict d, const string &key, int *value)
{
if (d.has_key(key)) //检查字典中是否存在该键值
{
@ -20,7 +20,7 @@ void getInt(dict d, string key, int *value)
}
};
void getDouble(dict d, string key, double *value)
void getDouble(dict d, const string &key, double *value)
{
if (d.has_key(key))
{
@ -33,7 +33,9 @@ void getDouble(dict d, string key, double *value)
}
};
void getStr(dict d, string key, char *value)
// 使用特化的strcpy_s能提升性能
template <class CharType, size_t size>
void getStr(dict d, const string &key, const CharType(&value)[size])
{
if (d.has_key(key))
{
@ -43,18 +45,18 @@ void getStr(dict d, string key, char *value)
{
string s = x();
const char *buffer = s.c_str();
//对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过
//+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错
#ifdef _MSC_VER //WIN32
strcpy_s(value, strlen(buffer) + 1, buffer);
strcpy_s(value, buffer);
#elif __GNUC__
strncpy(value, buffer, strlen(buffer) + 1);
#else
#pragma error("unsupported compiler")
#endif
}
}
};
}
void getChar(dict d, string key, char *value)
void getChar(dict d, const string &key, char *value)
{
if (d.has_key(key))
{