\brief Get the code of an identifier of an object. * * The lifetime of the returned string is the same as the input obj parameter. * * @param obj Object (must not be NULL) * @param index Index of the identifier. 0 = first identifier * @return a string, or NULL in case of error or missing name. */
| 1589 | * @return a string, or NULL in case of error or missing name. |
| 1590 | */ |
| 1591 | const char *proj_get_id_code(const PJ *obj, int index) { |
| 1592 | if (!obj) { |
| 1593 | return nullptr; |
| 1594 | } |
| 1595 | auto identifiedObj = dynamic_cast<IdentifiedObject *>(obj->iso_obj.get()); |
| 1596 | if (!identifiedObj) { |
| 1597 | return nullptr; |
| 1598 | } |
| 1599 | const auto &ids = identifiedObj->identifiers(); |
| 1600 | if (static_cast<size_t>(index) >= ids.size()) { |
| 1601 | return nullptr; |
| 1602 | } |
| 1603 | return ids[index]->code().c_str(); |
| 1604 | } |
| 1605 | |
| 1606 | // --------------------------------------------------------------------------- |
| 1607 |