1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // stdafx.cpp : 只包括标准包含文件的源文件
- // CcosSMachine.pch 将作为预编译头
- // stdafx.obj 将包含预编译类型信息
- #include "stdafx.h"
- // TODO: 在 STDAFX.H 中
- // 引用任何所需的附加头文件,而不是在此文件中引用
- //字符串分割
- vector<string> stringSplit(const string& str, char delim)
- {
- size_t previous = 0;
- size_t current = str.find_first_of(delim);
- vector<string> elems;
- while (current != string::npos) {
- if (current > previous) {
- elems.push_back(str.substr(previous, current - previous));
- }
- previous = current + 1;
- current = str.find_first_of(delim, previous);
- }
- if (previous != str.size()) {
- elems.push_back(str.substr(previous));
- }
- return elems;
- }
- //判断是否是数字
- bool IsDigit(const string& str)
- {
- bool isFloat = false;
- for (int i = 0; i < str.length(); i++)
- {
- if (!isdigit(str[i]))
- {
- if (i == 0)
- {
- if (str[i] != '-' && str[i] != '+')
- return false;
- }
- else
- {
- if (!isFloat && str[i] == '.')
- isFloat = true;
- else
- return false;
- }
- }
- }
- return true;
- }
|