bool NFCRecord::SwapRowInfo(const int nOriginRow, const int nTargetRow) { if (!IsUsed(nOriginRow)) { return false; } if (ValidRow(nOriginRow) && ValidRow(nTargetRow)) { for (int i = 0; i < GetCols(); ++i) { NF_SHARE_PTR<NFData> pOrigin = mtRecordVec.at(GetPos(nOriginRow, i)); mtRecordVec[GetPos(nOriginRow, i)] = mtRecordVec.at(GetPos(nTargetRow, i)); mtRecordVec[GetPos(nTargetRow, i)] = pOrigin; } int nOriginUse = mVecUsedState[nOriginRow]; mVecUsedState[nOriginRow] = mVecUsedState[nTargetRow]; mVecUsedState[nTargetRow] = nOriginUse; RECORD_EVENT_DATA xEventData; xEventData.nOpType = RECORD_EVENT_DATA::Swap; xEventData.nRow = nOriginRow; xEventData.nCol = nTargetRow; xEventData.strRecordName = mstrRecordName; NFData xData; OnEventHandler(mSelf, xEventData, xData, xData); return true; } return false; }
int CheckLegalPos(tBoard * structboard, tPos * pos) { int res; TranslateCoords(pos); res = ValidRow(pos); res = res && LegalPos(structboard, pos); return res; }
bool NFCRecord::IsUsed(const int nRow) const { if (ValidRow(nRow)) { return (mVecUsedState[nRow] > 0); } return false; }
bool NFCRecord::ValidPos(int nRow, int nCol) const { if (ValidCol(nCol) && ValidRow(nRow)) { return true; } return false; }
bool NFCRecord::SetUsed(const int nRow, const int bUse) { if (ValidRow(nRow)) { mVecUsedState[nRow] = bUse; return true; } return false; }
// 获得数据 bool NFCRecord::QueryRow(const int nRow, NFIDataList& varList) { if (!ValidRow(nRow)) { return false; } if (!IsUsed(nRow)) { return false; } varList.Clear(); for (int i = 0; i < GetCols(); ++i) { NF_SHARE_PTR<NFIDataList::TData> pVar = mtRecordVec.at(GetPos(nRow, i)); if (pVar.get()) { varList.Append(*pVar); } else { switch (GetColType(i)) { case TDATA_INT: varList.Add(NFINT64(0)); break; case TDATA_FLOAT: varList.Add(0.0f); break; case TDATA_STRING: varList.Add(NULL_STR.c_str()); break; case TDATA_OBJECT: varList.Add(NFGUID()); break; default: return false; break; } } } if (varList.GetCount() != GetCols()) { return false; } return true; }
bool NFCRecord::Remove(const int nRow) { if (ValidRow(nRow)) { if (IsUsed(nRow)) { RECORD_EVENT_DATA xEventData; xEventData.nOpType = Del; xEventData.nRow = nRow; xEventData.nCol = 0; xEventData.strRecordName = mstrRecordName; OnEventHandler(mSelf, xEventData, NFCDataList::TData(), NFCDataList::TData()); mVecUsedState[nRow] = 0; return true; } } return false; }