/************************************************************************************ 函数名称: bool CField::LoadDataFromBuffer(LPBYTE& lpIndicate, LPBYTE& lpData) 功能说明:虚函數,读取一条记录某一字段的数据,可以用来读取值标签. 详细解释:1.子类实现. 出入参数: [in]: 1.lpIndicate:指示字节地址. 2.lpData :数据地址. [out]:1.lpIndicate:下一数据块的指示字节地址. 2.lpData :下一数据块的数据地址. 返回类型:bool 制作:YTLI 2002/07/12 修改: ************************************************************************************/ void CField::LoadDataFromBuffer( LPBYTE& lpData) { if(m_pValue==NULL) {//旧版本 if(m_nNextModifyField == -1) { NewData(); LoadDataFromBuffer(lpData); DeleteData(); } else { if(m_pFields->IsConvertToLastVersion(this)) { NewData(); LoadDataFromBuffer(lpData); CField* pNewField = m_pFields->m_FieldVersion.GetFieldByAbsolutePos(m_nNextModifyField); pNewField->ConvertToCurField(this); DeleteData(); } } } else {//当前最新 if (GetFieldType() == fString) { FieldString* pStr = (FieldString*)m_pValue; char *pBuf = new char[m_nWidth+2]; memset(pBuf,0,m_nWidth+2); memcpy(pBuf,lpData,m_nWidth); *pStr= pBuf; /* char* lpstr = pStr->GetBuffer(m_nWidth+2); memcpy(lpstr,lpData,m_nWidth); *(lpstr+m_nWidth)= 0; *(lpstr+m_nWidth+1)= 0; pStr->ReleaseBuffer(); */ //pStr->TrimLeft();//,左边空格保留 pStr->TrimRight(); lpData = lpData + Align4(m_nWidth); } else { memcpy( &*((FieldNUM *)m_pValue), lpData, sizeof(FieldNUM) ); //ytli Modify 2002/09/04 lpData = lpData + sizeof(FieldNUM); } } }
//将原来版本的字段数据转换到当前字段的数据。 //1。如果本字段空间为空,生成空间 //2。要进行原来字段空值判断! //2。1如果为空则本字段为空 //2。2如果不为空则将原来的数据以原来的数据类型读 出,然后调用本字段的SetAs***设置。 //然后,如果有新的next字段,则调用该字段的ConvertToCurField函数,并且负责释放本空间,并且清0 void CField::ConvertToCurField(CField* pOldField) { /* if(this->GetFieldType() == fString) { ConvertToCurField(pOldField); return ; } */ if(!m_pValue) {//本字段也为中间字段 NewData(); if(pOldField->IsNull()) SetNull(); else { CFieldType ftType = pOldField->GetFieldType(); if( ftType == fBoolean ) SetAsBool( pOldField->GetAsBool()); else if( ftType == fCurrency ) SetAsCurrency( pOldField->GetAsCurrency()); else if( ftType == fDate ) //SetAsBool( pOldField->GetAsDateTime()); SetAsBool( true);//#_修改 2002-12-2 $ 10:01:35 zlq else if( ftType == fDouble ) SetAsDouble( pOldField->GetAsDouble()); else if( ftType == fInt ) SetAsInteger( pOldField->GetAsInteger()); else if( ftType == fString ) SetAsString( pOldField->GetAsString()); //assert(m_nNextModifyField != -1); CField* pNewField = m_pFields->m_FieldVersion.GetFieldByAbsolutePos(m_nNextModifyField); pNewField->ConvertToCurField(this); } DeleteData(); } else //最后一层转换. { if(pOldField->IsNull()) SetNull(); else { if( pOldField->GetFieldType() == fBoolean ) SetAsBool( pOldField->GetAsBool()); else if( pOldField->GetFieldType() == fCurrency ) SetAsCurrency( pOldField->GetAsCurrency()); else if( pOldField->GetFieldType() == fDate ) //SetAsBool( pOldField->GetAsDateTime()); SetAsBool( true); else if( pOldField->GetFieldType() == fDouble ) SetAsDouble( pOldField->GetAsDouble()); else if( pOldField->GetFieldType() == fInt ) SetAsInteger( pOldField->GetAsInteger()); else if( pOldField->GetFieldType() == fString ) SetAsString( pOldField->GetAsString()); //assert(m_nNextModifyField == -1); } } }