| 810 | |
| 811 | |
| 812 | int convertExtendedToString(QString& query, QString &result) |
| 813 | { //query may equal to result, since it always gets smaller |
| 814 | int i = 0, j = 0; |
| 815 | |
| 816 | int length = query.length(); |
| 817 | int charLeft = length; |
| 818 | QChar current; |
| 819 | while (i < length) |
| 820 | { //because the backslash escape quences always reduce the size of the generic_string, no overflow checks have to be made for target, assuming parameters are correct |
| 821 | current = query.at(i); |
| 822 | --charLeft; |
| 823 | if (current == '\\' && charLeft) |
| 824 | { //possible escape sequence |
| 825 | ++i; |
| 826 | --charLeft; |
| 827 | current = query.at(i); |
| 828 | switch (current.toLatin1()) |
| 829 | { |
| 830 | case 'r': |
| 831 | result[j] = '\r'; |
| 832 | break; |
| 833 | case 'n': |
| 834 | result[j] = '\n'; |
| 835 | break; |
| 836 | case '0': |
| 837 | result[j] = '\0'; |
| 838 | break; |
| 839 | case 't': |
| 840 | result[j] = '\t'; |
| 841 | break; |
| 842 | case '\\': |
| 843 | result[j] = '\\'; |
| 844 | break; |
| 845 | case 'b': |
| 846 | case 'd': |
| 847 | case 'o': |
| 848 | case 'x': |
| 849 | case 'u': |
| 850 | { |
| 851 | int size = 0, base = 0; |
| 852 | if (current == 'b') |
| 853 | { //11111111 |
| 854 | size = 8, base = 2; |
| 855 | } |
| 856 | else if (current == 'o') |
| 857 | { //377 |
| 858 | size = 3, base = 8; |
| 859 | } |
| 860 | else if (current == 'd') |
| 861 | { //255 |
| 862 | size = 3, base = 10; |
| 863 | } |
| 864 | else if (current == 'x') |
| 865 | { //0xFF |
| 866 | size = 2, base = 16; |
| 867 | } |
| 868 | else if (current == 'u') |
| 869 | { //0xCDCD |
no test coverage detected