Пример #1
0
bool NFCRecord::SetString(const int nRow, const int nCol, const std::string& value)
{
    if (!ValidPos(nRow, nCol))
    {
        return false;
    }

    if (TDATA_STRING != GetColType(nCol))
    {
        return false;
    }

    if (!IsUsed(nRow))
    {
        return false;
    }

    NFData var;
    var.SetString(value);

    NF_SHARE_PTR<NFData>& pVar = mtRecordVec.at(GetPos(nRow, nCol));

	//must have memory
	if (nullptr == pVar)
	{
		return false;
	}

	if (var == *pVar)
	{
		return false;
	}

	if (mtRecordCallback.size() == 0)
	{
		pVar->SetString(value);
	}
	else
	{
		NFData oldValue;
		oldValue.SetString(pVar->GetString());

		pVar->SetString(value);

		RECORD_EVENT_DATA xEventData;
		xEventData.nOpType = RECORD_EVENT_DATA::Update;
		xEventData.nRow = nRow;
		xEventData.nCol = nCol;
		xEventData.strRecordName = mstrRecordName;

		OnEventHandler(mSelf, xEventData, oldValue, *pVar);
	}

    return true;
}
Пример #2
0
NFDATA_TYPE NFCClassModule::ComputerType(const char* pstrTypeName, NFData& var)
{
    if (0 == strcmp(pstrTypeName, "int"))
    {
        var.SetInt(NULL_INT);
        return var.GetType();
    }
    else if (0 == strcmp(pstrTypeName, "string"))
    {
        var.SetString(NULL_STR);
        return var.GetType();
    }
    else if (0 == strcmp(pstrTypeName, "float"))
    {
        var.SetFloat(NULL_FLOAT);
        return var.GetType();
    }
    else if (0 == strcmp(pstrTypeName, "object"))
    {
        var.SetObject(NULL_OBJECT);
        return var.GetType();
    }
	else if (0 == strcmp(pstrTypeName, "vector2"))
	{
		var.SetVector2(NULL_VECTOR2);
		return var.GetType();
	}
	else if (0 == strcmp(pstrTypeName, "vector3"))
	{
		var.SetVector3(NULL_VECTOR3);
		return var.GetType();
	}

    return TDATA_UNKNOWN;
}