示例#1
0
ECode CVariableOfStruct::GetStructFieldGetter(
    /* [in] */ const String& name,
    /* [out] */ IStructGetter** getter)
{
    if (name.IsNull() || !getter) {
        return E_INVALID_ARGUMENT;
    }

    Int32 index = 0;
    ECode ec = GetIndexByName(name, &index);
    if (FAILED(ec)) return ec;

    if (mStructFieldDesc[index].mType != CarDataType_Struct) {
        return E_INVALID_ARGUMENT;
    }

    AutoPtr<IFieldInfo> fieldInfo;
    AutoPtr<IStructInfo> structInfo;
    ec = mStructInfo->GetFieldInfo(name, (IFieldInfo **)&fieldInfo);
    if (FAILED(ec)) return ec;

    ec = fieldInfo->GetTypeInfo((IDataTypeInfo **)&structInfo);
    if (FAILED(ec)) return ec;

    AutoPtr<IVariableOfStruct> variable;
    ec = structInfo->CreateVariableBox(
            mVarBuf + mStructFieldDesc[index].mPos, (IVariableOfStruct **)&variable);
    if (FAILED(ec)) return ec;

    return variable->GetGetter(getter);
}
示例#2
0
ECode CVariableOfStruct::GetFieldValueByName(
    /* [in] */ const String& name,
    /* [in] */ void* param,
    /* [in] */ CarDataType type)
{
    if(name.IsNull() || !param) {
        return E_INVALID_ARGUMENT;
    }

    if (!mVarBuf) {
        return E_INVALID_OPERATION;
    }

    Int32 index = 0;
    ECode ec = GetIndexByName(name, &index);
    if (FAILED(ec)) return ec;

    if (type != mStructFieldDesc[index].mType) {
        return E_INVALID_ARGUMENT;
    }

    memcpy(param, mVarBuf + mStructFieldDesc[index].mPos,
            mStructFieldDesc[index].mSize);

    return NOERROR;
}
//---------------------------------------------------------------------------
void Table::DropIndexByName(char *desc)
{
	IndexField *indx = GetIndexByName(desc);
	if (!stricmp(desc, "None")) return;

	if (indx)
		DropIndex(indx);
}
示例#4
0
//
// Sets the key for the given name
//
bool
KeyView::SetKeyByName(const wxString & name, const wxString & key)
{
   int index = GetIndexByName(name);

   // Bail is the name wasn't found
   if (index == wxNOT_FOUND)
   {
      return false;
   }

   // Go set the key
   return SetKey(index, key);
}
示例#5
0
ECode CVariableOfStruct::AcquireCppVectorFieldSGetter(
    /* [in] */ const String& name,
    /* [in] */ Boolean isSetter,
    /* [out] */ IInterface** sGetter)
{
    if (name.IsNull() || !sGetter) {
        return E_INVALID_ARGUMENT;
    }

    Int32 index = 0;
    ECode ec = GetIndexByName(name, &index);
    if (FAILED(ec)) return ec;

    if (mStructFieldDesc[index].mType != CarDataType_CppVector) {
        return E_INVALID_ARGUMENT;
    }

    assert(mCppVectorSGetters);

    g_objInfoList.LockHashTable(EntryType_Struct);

    CVariableOfCppVector* sGetterObj = (CVariableOfCppVector *)
            (IVariableOfCarArray *)mCppVectorSGetters[index];
    if (!sGetterObj) {
        AutoPtr<IFieldInfo> fieldInfo;
        ec = mStructInfo->GetFieldInfo(name, (IFieldInfo**)&fieldInfo);
        if (FAILED(ec)) {
            g_objInfoList.UnlockHashTable(EntryType_Struct);
            return ec;
        }

        AutoPtr<ICppVectorInfo> typeInfo;
        fieldInfo->GetTypeInfo((IDataTypeInfo**)&typeInfo);
        if (FAILED(ec)) {
            g_objInfoList.UnlockHashTable(EntryType_Struct);
            return ec;
        }

        Int32 length = 0;
        ec = typeInfo->GetLength(&length);
        if (FAILED(ec)) {
            g_objInfoList.UnlockHashTable(EntryType_Struct);
            return ec;
        }

        AutoPtr<IDataTypeInfo> elementTypeInfo;
        ec = typeInfo->GetElementTypeInfo((IDataTypeInfo**)&elementTypeInfo);
        if (FAILED(ec)) {
            g_objInfoList.UnlockHashTable(EntryType_Struct);
            return ec;
        }

        sGetterObj = new CVariableOfCppVector(
                elementTypeInfo, length,
                mVarBuf + mStructFieldDesc[index].mPos);
        if (sGetterObj == NULL) {
            g_objInfoList.UnlockHashTable(EntryType_Struct);
            return E_OUT_OF_MEMORY;
        }

        ec = sGetterObj->Init();
        if (FAILED(ec)) {
            delete sGetterObj;
            g_objInfoList.UnlockHashTable(EntryType_Struct);
            return ec;
        }

        sGetterObj->AddRef();
        mCppVectorSGetters[index] = (IVariableOfCarArray *)sGetterObj;
    }

    if (isSetter) {
        sGetterObj->GetSetter((ICppVectorSetter**)sGetter);
    }
    else {
        sGetterObj->GetGetter((ICppVectorGetter**)sGetter);
    }

    g_objInfoList.UnlockHashTable(EntryType_Struct);

    return NOERROR;
}