* Gets the value stored in the current pgbson_element_writer * based on the field pointed to by the writer. * Returns BSON_TYPE_EOD if not found. */
| 1672 | * Returns BSON_TYPE_EOD if not found. |
| 1673 | */ |
| 1674 | bson_value_t |
| 1675 | PgbsonElementWriterGetValue(pgbson_element_writer *elementWriter) |
| 1676 | { |
| 1677 | char pathPointer[UINT32_MAX_STR_LEN]; |
| 1678 | const char *pathString = NULL; |
| 1679 | uint32_t pathStringLength = 0; |
| 1680 | bson_t *innerBson = NULL; |
| 1681 | |
| 1682 | if (elementWriter->isArray) |
| 1683 | { |
| 1684 | pathStringLength = bson_uint32_to_string( |
| 1685 | elementWriter->arrayWriter->index, |
| 1686 | &pathString, &pathPointer[0], UINT32_MAX_STR_LEN); |
| 1687 | innerBson = &elementWriter->arrayWriter->innerBson; |
| 1688 | } |
| 1689 | else |
| 1690 | { |
| 1691 | pathString = elementWriter->objectWriterState.path; |
| 1692 | pathStringLength = elementWriter->objectWriterState.pathLength; |
| 1693 | innerBson = &elementWriter->objectWriterState.objectWriter->innerBson; |
| 1694 | } |
| 1695 | |
| 1696 | bson_iter_t iterator; |
| 1697 | if (bson_iter_init_find_w_len(&iterator, innerBson, pathString, pathStringLength)) |
| 1698 | { |
| 1699 | return *bson_iter_value(&iterator); |
| 1700 | } |
| 1701 | |
| 1702 | bson_value_t returnValue = { 0 }; |
| 1703 | return returnValue; |
| 1704 | } |
| 1705 | |
| 1706 | |
| 1707 | /* |
no outgoing calls
no test coverage detected