| 866 | |
| 867 | namespace v1 { |
| 868 | int32_t GetStrField(const int8_t* row, uint32_t field_offset, |
| 869 | uint32_t next_str_field_offset, uint32_t str_start_offset, |
| 870 | uint32_t addr_space, int8_t** data, uint32_t* size) { |
| 871 | if (row == NULL || data == NULL || size == NULL) return -1; |
| 872 | const int8_t* row_with_offset = row + str_start_offset; |
| 873 | uint32_t str_offset = 0; |
| 874 | uint32_t next_str_offset = 0; |
| 875 | switch (addr_space) { |
| 876 | case 1: { |
| 877 | str_offset = |
| 878 | (uint8_t)(*(row_with_offset + field_offset * addr_space)); |
| 879 | if (next_str_field_offset > 0) { |
| 880 | next_str_offset = (uint8_t)( |
| 881 | *(row_with_offset + next_str_field_offset * addr_space)); |
| 882 | } |
| 883 | break; |
| 884 | } |
| 885 | case 2: { |
| 886 | str_offset = *(reinterpret_cast<const uint16_t*>( |
| 887 | row_with_offset + field_offset * addr_space)); |
| 888 | if (next_str_field_offset > 0) { |
| 889 | next_str_offset = *(reinterpret_cast<const uint16_t*>( |
| 890 | row_with_offset + next_str_field_offset * addr_space)); |
| 891 | } |
| 892 | break; |
| 893 | } |
| 894 | case 3: { |
| 895 | const int8_t* cur_row_with_offset = |
| 896 | row_with_offset + field_offset * addr_space; |
| 897 | str_offset = (uint8_t)(*cur_row_with_offset); |
| 898 | str_offset = |
| 899 | (str_offset << 8) + (uint8_t)(*(cur_row_with_offset + 1)); |
| 900 | str_offset = |
| 901 | (str_offset << 8) + (uint8_t)(*(cur_row_with_offset + 2)); |
| 902 | if (next_str_field_offset > 0) { |
| 903 | const int8_t* next_row_with_offset = |
| 904 | row_with_offset + next_str_field_offset * addr_space; |
| 905 | next_str_offset = (uint8_t)(*(next_row_with_offset)); |
| 906 | next_str_offset = (next_str_offset << 8) + |
| 907 | (uint8_t)(*(next_row_with_offset + 1)); |
| 908 | next_str_offset = (next_str_offset << 8) + |
| 909 | (uint8_t)(*(next_row_with_offset + 2)); |
| 910 | } |
| 911 | break; |
| 912 | } |
| 913 | case 4: { |
| 914 | str_offset = *(reinterpret_cast<const uint32_t*>( |
| 915 | row_with_offset + field_offset * addr_space)); |
| 916 | if (next_str_field_offset > 0) { |
| 917 | next_str_offset = *(reinterpret_cast<const uint32_t*>( |
| 918 | row_with_offset + next_str_field_offset * addr_space)); |
| 919 | } |
| 920 | break; |
| 921 | } |
| 922 | default: { |
| 923 | return -2; |
| 924 | } |
| 925 | } |