| 1485 | } |
| 1486 | |
| 1487 | const ConfigValue * ConfigInstance::getValue(int n, const char *_name, int arrIdx) const |
| 1488 | { |
| 1489 | if (n >= 0) { // prefer N |
| 1490 | if (n<N) { |
| 1491 | return getVal(n,arrIdx); |
| 1492 | } |
| 1493 | } else if (_name != NULL) { |
| 1494 | // split name |
| 1495 | SMILE_DBG(7,"called ConfigInstance::getValue (_name = '%s')",_name); |
| 1496 | const char *rem; |
| 1497 | char *base=NULL; |
| 1498 | int h = instNameSplit(_name, &base, &rem); |
| 1499 | arrIdx = -1; |
| 1500 | char *arrStr = NULL; |
| 1501 | int idx = type->findField(base,&arrIdx,&arrStr); |
| 1502 | SMILE_DBG(7,"findField returned idx=%i and arrIdx=%i arrStr='%s' (h=%i)",idx,arrIdx,arrStr,h); |
| 1503 | if (base!=NULL) { free(base); base=NULL; } |
| 1504 | if (h==1) { |
| 1505 | if ((idx >= 0)&&(idx < N)) { // check for valid index |
| 1506 | if (field[idx] == NULL) CONF_MANAGER_ERR("ConfigInstance::getValue: attempting to access object field '%s', which has not been initialized!",base); |
| 1507 | if ((field[idx]->getType() == CFTP_OBJ)||(field[idx]->getType() == CFTP_OBJ_ARR)) { |
| 1508 | // TODO:: check if field[idx] is initialized!! |
| 1509 | if (arrStr != NULL) { |
| 1510 | arrIdx = field[idx]->findField(arrStr); |
| 1511 | free(arrStr); |
| 1512 | } |
| 1513 | ConfigInstance *cur = field[idx]->getObj(arrIdx); |
| 1514 | if (cur!=NULL) return cur->getValue(-1,rem); |
| 1515 | else |
| 1516 | CONF_MANAGER_ERR("getValue: cannot dereference NULL subobject pointer while getting value for'%s' (rem:'%s')",name,rem); |
| 1517 | } else CONF_MANAGER_ERR("getValue: hierarchical field referenced is not of type object! ('%s')",rem); |
| 1518 | } else CONF_MANAGER_ERR("getValue: hierarchical field referenced ('%s') does not exist! ",rem); |
| 1519 | } else { |
| 1520 | if (idx < 0) SMILE_WRN(2,"ConfigInstance::getValue : non-existant field '%s' (%i)",_name,n); |
| 1521 | if (arrStr != NULL) { |
| 1522 | arrIdx = field[idx]->findField(arrStr); |
| 1523 | free(arrStr); |
| 1524 | } |
| 1525 | return getValue(idx,NULL,arrIdx); |
| 1526 | } |
| 1527 | } |
| 1528 | SMILE_WRN(2,"ConfigInstance::getValue : index %i out of bounds (0-%i)",n,N-1); |
| 1529 | return NULL; |
| 1530 | } |
| 1531 | |
| 1532 | |
| 1533 |
no test coverage detected