static pwr_tStatus replaceAttr( wb_session *sp, wb_attribute& a, pwr_sAttrRef *target) { printf( "%s\n", a.attrName()); switch( a.type()) { case pwr_eType_AttrRef: { pwr_sAttrRef *value = (pwr_sAttrRef *)a.value(); pwr_sAttrRef aref = *value; if ( aref.Objid.vid == ldh_cIoConnectVolume) { aref.Objid = target->Objid; wb_attribute va = sp->attribute( &aref); printf( "Replacing %s\n", va.attrName()); sp->writeAttribute( a, &aref, sizeof(aref)); } break; } default: ; } return LDH__SUCCESS; }
// // printParameter // void wb_print_wbl::printParameter(wb_volume& v, wb_attribute& attr, wb_attribute& tattr, ///< template wb_adef& adef) { int nElement = adef.nElement(); int varSize = adef.size() / nElement; char* valueb = (char *)attr.value(); char* val; char* tvalueb; char* tval; char* svalp; int varOffset; bool parValOk; bool print_all = false; const char* name = adef.subName(); if (valueb == NULL) { m_os << "! %WBDUMP-E-Error Failed to get attribute address for " << adef.name() << endl; m_errCnt++; return; } if (adef.type() == pwr_eType_Text) { printText(v, adef, valueb, adef.size()); return; } if ( tattr.evenSts()) { // Template attribute not found, should not happen tvalueb = (char *)calloc( 1, attr.size()); print_all = true; } else if ( attr == tattr || m_isTemplateObject) // This is the template object itself, print all nonzero tvalueb = (char *)calloc( 1, tattr.size()); else tvalueb = (char *)tattr.value(); for (int i = 0; i < nElement; i++) { switch (adef.type()) { case pwr_eType_Boolean: case pwr_eType_Float32: case pwr_eType_Float64: case pwr_eType_Char: case pwr_eType_String: case pwr_eType_ProString: case pwr_eType_Int8: case pwr_eType_Int16: case pwr_eType_Int32: case pwr_eType_Int64: case pwr_eType_UInt8: case pwr_eType_UInt16: case pwr_eType_UInt32: case pwr_eType_UInt64: case pwr_eType_Objid: case pwr_eType_TypeId: case pwr_eType_CastId: case pwr_eType_DisableAttr: case pwr_eType_ClassId: case pwr_eType_AttrRef: case pwr_eType_Time: case pwr_eType_VolumeId: case pwr_eType_ObjectIx: case pwr_eType_RefId: case pwr_eType_DeltaTime: case pwr_eType_Mask: case pwr_eType_Enum: case pwr_eType_Status: case pwr_eType_NetStatus: case pwr_eType_DataRef: varOffset = varSize * i; val = valueb + varOffset; tval = tvalueb + varOffset; if (memcmp(val, tval, varSize) == 0 && !(adef.flags() & PWR_MASK_ALWAYSWBL) && !print_all) continue; parValOk = printValue(v, adef, val, varSize, &svalp); if (parValOk) indent(); else m_os << "! %WBDUMP-E-Error "; if (adef.flags() & PWR_MASK_ARRAY) { m_os << "Attr " << name << "[" << i << "] = " << svalp << endl; } else { m_os << "Attr " << name << " = " << svalp << endl; } break; case pwr_eType_Array: m_os << "! %WBDUMP-E-Error Type pwr_eType_Array is not yet implemented" << endl; m_errCnt++; break; case pwr_eType_Buffer: m_os << "! %WBDUMP-E-Error Type pwr_eType_Buffer is not yet implemented" << endl; m_errCnt++; break; case pwr_eType_Struct: m_os << "! %WBDUMP-E-Error Type pwr_eType_Struct is not yet implemented" << endl; m_errCnt++; break; default: m_os << "! %WBDUMP-E-Error Attribute " << adef.name() << " is of unknown type: " << adef.type() << endl; m_errCnt++; break; } } if ( tattr.evenSts() || attr == tattr) free( tvalueb); }