int NFCRecord::FindFloat(const int nCol, const double value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_FLOAT != mVarRecordType->Type(nCol)) { return -1; } for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetFloat(i, nCol) == value) { varResult << i; } } return varResult.GetCount(); }
int NFCRecord::FindString(const int nCol, const std::string& value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_STRING != mVarRecordType->Type(nCol)) { return -1; } { for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } const std::string& strData = GetString(i, nCol); if (0 == strcmp(strData.c_str(), value.c_str())) { varResult << (int64_t)i; } } return varResult.GetCount(); } return -1; }
int NFCRecord::FindVector3(const int nCol, const NFVector3& value, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_VECTOR3 != mVarRecordType->Type(nCol)) { return -1; } { for (int i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetVector3(i, nCol) == value) { varResult << (int64_t)i; } } return varResult.GetCount(); } return -1; }
int NFCRecord::FindObject(const int nCol, const NFGUID& value, NFIDataList& varResult) { if (!ValidCol(nCol)) { return -1; } if (TDATA_OBJECT != mVarRecordType->Type(nCol)) { return -1; } { for (int64_t i = 0; i < mnMaxRow; ++i) { if (!IsUsed(i)) { continue; } if (GetObject(i, nCol) == value) { varResult << i; } } return varResult.GetCount(); } return -1; }
bool NFCRecord::ValidPos(int nRow, int nCol) const { if (ValidCol(nCol) && ValidRow(nRow)) { return true; } return false; }
int NFCRecord::FindRowByColValue(const int nCol, const NFData& var, NFDataList& varResult) { if (!ValidCol(nCol)) { return -1; } NFDATA_TYPE eType = var.GetType(); if (eType != mVarRecordType->Type(nCol)) { return -1; } switch (eType) { case TDATA_INT: return FindInt(nCol, var.GetInt(), varResult); break; case TDATA_FLOAT: return FindFloat(nCol, var.GetFloat(), varResult); break; case TDATA_STRING: return FindString(nCol, var.GetString(), varResult); break; case TDATA_OBJECT: return FindObject(nCol, var.GetObject(), varResult); break; case TDATA_VECTOR2: return FindVector2(nCol, var.GetVector2(), varResult); break; case TDATA_VECTOR3: return FindVector3(nCol, var.GetVector3(), varResult); break; default: break; } return -1; }
int NFCRecord::FindRowByColValue(const int nCol, const NFIDataList& var, NFIDataList& varResult) { if (!ValidCol(nCol)) { return -1; } TDATA_TYPE eType = var.Type(0); if (eType != mVarRecordType->Type(nCol)) { return -1; } switch (eType) { case TDATA_INT: return FindInt(nCol, var.Int(nCol), varResult); break; case TDATA_FLOAT: return FindFloat(nCol, var.Float(nCol), varResult); break; case TDATA_STRING: return FindString(nCol, var.String(nCol).c_str(), varResult); break; case TDATA_OBJECT: return FindObject(nCol, var.Object(nCol), varResult); break; default: break; } return -1; }