void FieldSelectionPanel::AddField(CItemData::FieldType ft, bool selected, bool mandatory) { wxCHECK_RET(!mandatory || selected, wxT("A mandatory field must also be pre-selected")); const wxString fieldName(towxstring(CItemData::FieldName(ft))); if (FindField(ft, selected? m_lbSelected: m_lbAvailable) != wxNOT_FOUND) { wxLogDebug(wxT("%ls already in %ls list, not adding it again"), fieldName, selected? wxT("selected"): wxT("available")); return; } //if the field is already in another listbox, just move it const int index = FindField(ft, selected? m_lbAvailable: m_lbSelected); if (index != wxNOT_FOUND) { wxLogDebug(wxT("%ls already in %ls list, moving it to %ls"), fieldName, selected? wxT("available"): wxT("selected"), selected? wxT("selected"): wxT("available")); MoveItem(index, selected? m_lbAvailable: m_lbSelected, selected? m_lbSelected: m_lbAvailable); return; } //else, add it wxString title(fieldName); if (mandatory) title += _(" [Mandatory Field]"); FieldData *data = new FieldData(mandatory, ft); wxListBox* lb = selected? m_lbSelected: m_lbAvailable; lb->Append(title, data); }
IFieldPtr CFields::GetField(const CommonLib::CString& name) const { int nIndex = FindField(name); if(nIndex == -1) return IFieldPtr(); return GetField(nIndex); }
GField* GFieldsImpl::GetField(const char* szName) { int nIndex = FindField(szName); if(nIndex<0) return NULL; return m_fields[nIndex]; }
int GetFieldOrdering(FieldList list, int *order) { FieldSpec *field; long ord; field = FindField(list, "fieldOrder"); if (field == NULL) ord = TYPE_ORDER; else if (field->occurrence != GLOBAL || field->rank != 0 || field->data == NULL || !LongVal(field->data, field->type, &ord) || ord != FIELD_ORDER && ord != TYPE_ORDER) { DebugMsg(1, "Bad field \"fieldOrder\"."); return FALSE; } if (order != NULL) *order = ord; return TRUE; }
RESULTCODE GFieldsImpl::Remove(const char* szName) { int nIndex = FindField(szName); if(nIndex<0) return AG_FAILURE; m_fields.erase(m_fields.begin()+nIndex); return AG_SUCCESS; }
bool CRuleStruct::AddField(CRuleVariable* pField) { if(FindField(pField->m_oName.GetStr())) return false; m_oFields.Insert((uint32)(-1), pField); m_bImplemented = false; return true; }
/** * If any changes have been made to this component, * they are now applied to the schematic component */ void BOM_TABLE_COMPONENT::ApplyFieldChanges() { for( auto& unit : Units ) { auto cmp = unit.GetComp(); if( !cmp ) continue; // Iterate over each column SCH_FIELD* field; for( auto& column : m_columnList->Columns ) { if( column && HasValueChanged( column ) ) { wxString value = GetFieldValue( column->Id() ); switch( column->Id() ) { // Ignore read-only fields case BOM_COL_ID_REFERENCE: case BOM_COL_ID_QUANTITY: continue; // Special field considerations case BOM_COL_ID_FOOTPRINT: field = cmp->GetField( FOOTPRINT ); break; case BOM_COL_ID_VALUE: field = cmp->GetField( VALUE ); break; case BOM_COL_ID_DATASHEET: field = cmp->GetField( DATASHEET ); break; default: // Find the field by name (but ignore default fields) field = cmp->FindField( column->Title(), false ); break; } // New field needs to be added? if( !field && !value.IsEmpty() ) { SCH_FIELD newField( wxPoint( 0, 0 ), -1, cmp, column->Title() ); field = cmp->AddField( newField ); } if( field ) { field->SetText( value ); } } } } }
static FieldSpec * AddCommandLine(FieldList *list, char *line) { FieldSpec *field; if (line == NULL) return NULL; field = FindField(*list, "commandLine"); if (field == NULL) { field = NewFieldSpec(ECHAR, 1); if (field == NULL) { DebugMsg(1, "AddCommandLine: Couldn't create field spec."); return NULL; } field->dim[0] = strlen(line); field->name = savestring("commandLine"); field->occurrence = GLOBAL; if (!AddField(list, field)) { DebugMsg(1, "AddCommandLine: Couldn't add field spec."); return NULL; } } else /* field != NULL */ { if (field->occurrence != GLOBAL) { DebugMsg(1, "AddCommandLine: non-GLOBAL field \'commandLine\"."); return NULL; } field->type = ECHAR; field->rank = 1; field->dim = (long *) ((field->dim == NULL) ? malloc(sizeof(long)) : realloc(field->dim, sizeof(long))); if (field->dim == NULL) { DebugMsg(1, "AddCommandLine: couldn't (re)allocate dimension."); return NULL; } field->dim[0] = 1 + strlen(line); } field->data = line; return field; }
bool MimeHeader::FieldExists(const char *pszFieldName) const { vector<MimeField>::iterator iter = FindField(pszFieldName); if (iter == m_listFields.end()) return false; return true; }
int SetFieldOrdering(FieldList *list, int order) { FieldSpec *field; if (*list == NULL) { DebugMsg(1, "SetFieldOrdering: NULL field list."); return FALSE; } field = FindField(*list, "fieldOrder"); if (field == NULL) { if (order == TYPE_ORDER) return TRUE; field = NewFieldSpec(SHORT, 0); if (field == NULL) { DebugMsg(1, "SetFieldOrdering: Couldn't create field spec."); return FALSE; } field->name = StrDup("fieldOrder"); field->occurrence = GLOBAL; if (!AddField(list, field)) { DebugMsg(1, "SetFieldOrdering: Couldn't add field spec."); return FALSE; } } else /* field != NULL */ { if (field->occurrence != GLOBAL) { DebugMsg(1, "SetFieldOrdering: non-GLOBAL field \"fieldOrder\"."); return FALSE; } field->type = SHORT; field->rank = 0; } field->data = ((field->data == NULL) ? malloc(sizeof(short)) : realloc(field->data, sizeof(short))); if (field->data == NULL) { DebugMsg(1, "SetFieldOrdering: couldn't (re)allocate data."); return FALSE; } *(short *) field->data = order; return TRUE; }
BinaryObjectImpl BinaryObjectImpl::GetField(const char* name) const { CheckIdResolver(); int32_t fieldId = idRslvr->GetFieldId(GetTypeId(), name); int32_t pos = FindField(fieldId); return FromMemory(*mem, pos, metaMgr); }
bool BinaryObjectImpl::HasField(const char* name) const { CheckIdResolver(); int32_t fieldId = idRslvr->GetFieldId(GetTypeId(), name); int32_t fieldPos = FindField(fieldId); return fieldPos >= 0; }
TDC_ATTRIBUTE CTDLImportOutlookObjectsDlg::GetFieldMapping(const CTDCCsvColumnMapping& aMapping, OUTLOOK_FIELDTYPE nFieldType) { int nField = FindField(aMapping, nFieldType); if (nField != -1) return aMapping[nField].nTDCAttrib; // else return TDCA_NONE; }
//------------------------------------------------------------------------------------------------------------ void CPerfTestContact::SetTextFieldL(TFieldType aFieldType,const TDesC& aText) { CContactItemFieldSet& fields = iContactItem->CardFields(); TInt fieldIndex = 0; fieldIndex = FindField( aFieldType ); if ( fieldIndex > KErrNotFound ) { CContactItemField& field = fields[ fieldIndex ]; ASSERT(field.StorageType()==KStorageTypeText); STATIC_CAST(CContactTextField*,field.Storage())->SetText(aText.AllocL()); }
RESULTCODE GFieldsImpl::AddRef(GField* pField) { if(pField==NULL) { return AG_FAILURE; } int nIndex = FindField(pField->GetName()); if(nIndex>0) { return AG_FAILURE; } m_fields.push_back(pField); return AG_SUCCESS; }
/* Parse rule comment with dynamic fields */ char* ParseRuleComment(Eventinfo *lf) { static char final[OS_COMMENT_MAX + 1] = { '\0' }; char orig[OS_COMMENT_MAX + 1] = { '\0' }; const char *field; char *str; char *var; char *end; char *tok; size_t n = 0; size_t z; strncpy(orig, lf->generated_rule->comment, OS_COMMENT_MAX); for (str = orig; (tok = strstr(str, "$(")); str = end) { *tok = '\0'; var = tok + 2; if (n + (z = strlen(str)) >= OS_COMMENT_MAX) return strdup(lf->generated_rule->comment); strncpy(&final[n], str, z); n += z; if (!(end = strchr(var, ')'))) { *tok = '$'; str = tok; break; } *(end++) = '\0'; if ((field = FindField(lf, var))) { if (n + (z = strlen(field)) >= OS_COMMENT_MAX) return strdup(lf->generated_rule->comment); strncpy(&final[n], field, z); n += z; } else { *tok = '$'; if (n + (z = strlen(tok)) + 1 >= OS_COMMENT_MAX) return strdup(lf->generated_rule->comment); strncpy(&final[n], tok, z); n += z; final[n++] = ')'; } }
void CTDLImportOutlookObjectsDlg::UpdateMasterMapping() { CTDCCsvColumnMapping aMapping; m_lcFieldMapping.GetColumnMapping(aMapping); for (int nField = 0; nField < aMapping.GetSize(); nField++) { const CSVCOLUMNMAPPING& col = aMapping[nField]; // find this field in the master mapping int nMaster = FindField(m_aMasterMapping, (OUTLOOK_FIELDTYPE)col.dwItemData); ASSERT(nMaster != -1); if (nMaster != -1) m_aMasterMapping[nMaster].nTDCAttrib = col.nTDCAttrib; } }
bool iDBF::GetStrDataArray(const wxString& fieldname, charPtr* dt) { int rows = NumOfRecords; int fld = FindField(fieldname); if (fld < 0 || fld > NumOfFields-1 || Field[fld]->Type != 'C') return false; for ( int xIndex = 0; xIndex < rows; ++xIndex) { while (Pos() != fld) Read(); int len = Field[fld]->Width; char* result = new char[len+1]; Read(result, len); dt[xIndex] = result; } return true; }
bool iDBF::GetDblDataArray(const wxString& fieldname, double* dt) { LOG_MSG("Entering iDBF::GetDblDataArray"); int rows = NumOfRecords; int fld = FindField(fieldname); if (fld < 0 || fld > NumOfFields-1) return 0; pos =0; record=0; //ReOpen(); //MMM this must be a hack, temporarily disable and eventually remove it! if (Field[fld]->Type == 'F') { for ( int xIndex = 0; xIndex < rows; ++xIndex) { while (Pos() != fld) Read(); int len = Field[fld]->Width; char* result = new char[len+1]; Read(result, len); //dt[xIndex] = atof(result); wxString::Format("%s", result).ToCDouble(&dt[xIndex]); delete [] result; result = NULL; } } else { for ( int xIndex = 0; xIndex < rows; ++xIndex) { while (Pos() != fld) Read(); double result; Read(result); dt[xIndex] = result; } } LOG_MSG("Exiting iDBF::GetDblDataArray"); return 1; }
FieldSpec * FindField(FieldList list, /* field list */ char *name) /* full name of field */ { char *prefix; /* first component of name */ char *tail; /* rest of name after prefix */ FieldSpec *ancestor; /* parent of named field spec (or parent of parent ...). */ FieldSpec *field; /* named field spec */ /* Check for bad or empty arguments. */ if (list == NULL || *list == NULL || name == NULL) return NULL; /* Parse name. */ tail = strchr(name, DOT); /* Handle simple case immediately or complex case by recursion. */ if (tail == NULL) /* Just one component. */ return GetField(list, name); else /* Multi-component name. */ { tail++; /* Skip over dot. */ prefix = FirstComponent(name); if (prefix == NULL) return NULL; ancestor = GetField(list, prefix); if (ancestor == NULL) /* Search failed. */ field = NULL; else /* Descend into subfields. */ field = FindField(ancestor->subfields, tail); free(prefix); return field; } }
// ---------------------------------------------------------------------------- // GetFieldData, for EVPbkFieldStorageTypeBinary // ---------------------------------------------------------------------------- EXPORT_C TPtrC8 CContactMatcher::GetFieldDataBinaryL( const MVPbkStoreContact& aContact, const MVPbkFieldType& aFType ) const { TPtrC8 ret(KNullDesC8); const MVPbkStoreContactField* field = FindField( aContact, aFType); if (field) { const MVPbkContactFieldData& fdata = field->FieldData(); if (fdata.DataType() == EVPbkFieldStorageTypeBinary) { const MVPbkContactFieldBinaryData& fdata2 = MVPbkContactFieldBinaryData::Cast( fdata ); ret.Set( fdata2.BinaryData() ); } else { User::Leave( KErrArgument ); } } return ret; }
bool FindField(bson_iterator *itIn, bson_iterator *itOut, const String &fieldname, bool recursive) { bool found = false; while(!found && bson_iterator_next(itIn)) { String itKey = String(bson_iterator_key(itIn)); if(fieldname == itKey) { *itOut = *itIn; found = true; } else if( (recursive && (BSON_OBJECT == bson_iterator_type(itIn))) || (recursive && (BSON_ARRAY == bson_iterator_type(itIn)))) { bson_iterator subIt; bson_iterator_subiterator(itIn, &subIt); found = FindField(&subIt, itOut, fieldname, recursive); } } return found; }
// ---------------------------------------------------------------------------- // GetFieldData, for EVPbkFieldStorageTypeDateTime // ---------------------------------------------------------------------------- EXPORT_C TTime CContactMatcher::GetFieldDataDateTimeL( const MVPbkStoreContact& aContact, const MVPbkFieldType& aFType ) const { // YYYYMMDD:HHMMSS.MMMMMM _LIT(KNullTime, "11110000:010101.00000"); TTime ret(KNullTime); const MVPbkStoreContactField* field = FindField( aContact, aFType); if (field) { const MVPbkContactFieldData& fdata = field->FieldData(); if (fdata.DataType() == EVPbkFieldStorageTypeDateTime) { const MVPbkContactFieldDateTimeData& fdata2 = MVPbkContactFieldDateTimeData::Cast( fdata ); ret = fdata2.DateTime(); } else { User::Leave( KErrArgument ); } } return ret; }
DwFieldBody& DwHeaders::FieldBody(const DwString& aFieldName) { assert(aFieldName != ""); // First, search for field DwField* field = FindField(aFieldName); // If the field is not found, create the field and its field body if (field == 0) { field = DwField::NewField("", this); field->SetFieldNameStr(aFieldName); DwFieldBody* fieldBody = DwField::CreateFieldBody(aFieldName, "", field); field->SetFieldBody(fieldBody); AddField(field); } // Get the field body DwFieldBody* fieldBody = field->FieldBody(); // If it does not exist, create it if (fieldBody == 0) { fieldBody = DwField::CreateFieldBody(aFieldName, "", field); field->SetFieldBody(fieldBody); SetModified(); } return *fieldBody; }
EXPORT_C TBool CHTTPResponse::FindRealm(TPtrC8& aRealm) const { __LOG_ENTER(_L("CHTTPResponse::FindRealm")); // Search for the WWWAuthenticate field TPtrC8 realmPtr(aRealm); TBool retVal = FindField(EHttpWWWAuthenticate, realmPtr, 0); if (retVal) { // realmPtr now points to the WWWAuthentication field value. This contains the Authentication scheme, realm // value and optional parameters. Check authentication is Basic (encoded as 0x80). This is stored in the // second byte of the header value (i.e. index [1]). if (realmPtr[1] == 0x80) { // Set the realm descriptor passed in aRealm.Set(realmPtr.Mid(2)); #ifdef _DEBUG // In debug builds, convert the 8-bit realm to 16-bit UNICODE in order to log it. HBufC16* aRealm16 = HBufC16::New(aRealm.Length()); if(aRealm16!=NULL) { TPtr16 aRealm16_Ptr = aRealm16->Des(); aRealm16_Ptr.Copy(aRealm); __LOG1(_L("CHTTPResponse::FindRealm : found realm string: %S"), &aRealm16_Ptr); delete aRealm16; } #endif } else { __LOG(_L("CHTTPResponse::FindRealm : nothing found")); retVal = EFalse; } } __LOG_RETURN; return retVal; }
DwBool DwHeaders::HasField(const DwString& aFieldName) const { return FindField(aFieldName) ? 1 : 0; }
DwBool DwHeaders::HasField(const char* aFieldName) const { return FindField(aFieldName) ? 1 : 0; }
DwBool DwHeaders::HasMimeVersion() const { return FindField("mime-version") ? 1 : 0; }
DwBool DwHeaders::HasContentDisposition() const { return FindField("content-disposition") ? 1 : 0; }
DwBool DwHeaders::HasContentType() const { return FindField("content-type") ? 1 : 0; }