Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
table field.cpp 2.21 KB
Copy Edit Raw Blame History
hybtalented authored 2018-03-31 18:26 . Add files via upload
/*
* table field.cpp
*
* Created on: 20171129
* Author: Administrator
*/
#include"table field.h"
#include<sstream>
using namespace std;
VOID Table_field::initFields(){
fields.clear();
for(UINT i=0,size=field.size() ; i < size; ++i ){
while( i <size && field[i] == ifs && field[ i ] !='\0' ) ++i ;
fields.push_back(i);
while(i <size && field[i]!=ifs && field[ i ] !='\0') ++i ;
if( i< size)
field[ i ] ='\0';
}
}
VOID Table_field::initFieldsStandard(){
fields.clear();
for(UINT i=0,size=field.size() ; i < size; ++i ){
fields.push_back(i);
while(i< size && field[ i ] !='\0'&& field[i]!=ifs ) ++i ;
if( i< size )
field[ i ] = '\0';
}
}
Table_field::Table_field(istream& in , BYTE fs , BOOL st ):ifs(fs),stand(st){
getline(in, field);
if(stand){
initFieldsStandard();
}else{
initFields();
}
}
Table_field::Table_field(string&& s,BYTE fs, BOOL st ):field(s),ifs(fs),stand(st){
if(stand){
initFieldsStandard();
}else{
initFields();
}
}
Table_field::Table_field(string& s,BYTE fs, BOOL st):field(s),ifs(fs),stand(st){
if(stand){
initFieldsStandard();
}else{
initFields();
}
}
WORD Table_field::getWordHex(UINT i){
DWORD ret;
if(i >= fields.size())return 0;
istringstream ssin( field.c_str() + fields[i] );
ssin >> hex >> ret;
return ret;
}
DWORD Table_field::getDWordHex(UINT i){
DWORD ret;
if(i >= fields.size())return 0;
istringstream ssin(field.c_str() + fields[i] );
ssin >> hex >> ret;
return ret;
}
WORD Table_field::getWord(UINT i){
DWORD ret;
if(i >= fields.size())return 0;
const string s=field.c_str() + fields[i] ;
istringstream ssin(field.c_str() + fields[i]);
ssin >> ret;
return ret;
}
DWORD Table_field::getDWord(UINT i){
DWORD ret;
if(i >= fields.size())return 0;
istringstream ssin(field.c_str() + fields[i] );
ssin >> ret;
return ret;
}
BYTE Table_field::getByteHex(UINT i){
DWORD ret;
if(i >= fields.size())return 0;
istringstream ssin(field.c_str() + fields[i] );
ssin >> hex >> ret;
return ret;
}
BYTE Table_field::getByte(UINT i){
DWORD ret;
if(i >= fields.size())return 0;
istringstream ssin(field.c_str() + i );
ssin >> ret;
return ret;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化