----------------------------------------------------- //
| 815 | |
| 816 | // ----------------------------------------------------- // |
| 817 | static void getElement(int arrayLen, const char *cur, const char *old, char *oldPtr, char *curData) |
| 818 | { |
| 819 | #define getEle(value, current, type, cast, size, ptr) \ |
| 820 | if (strcmp(current, type) == 0) \ |
| 821 | { \ |
| 822 | value = (*(cast *)ptr); \ |
| 823 | ptr += size; \ |
| 824 | } |
| 825 | |
| 826 | #define setEle(value, current, type, cast, size, ptr) \ |
| 827 | if (strcmp(current, type) == 0) \ |
| 828 | { \ |
| 829 | (*(cast *)ptr) = (cast)value; \ |
| 830 | ptr += size; \ |
| 831 | } |
| 832 | double value = 0.0; |
| 833 | |
| 834 | for (int i = 0; i < arrayLen; i++) |
| 835 | { |
| 836 | getEle(value, old, "char", char, sizeof(char), oldPtr); |
| 837 | setEle(value, cur, "char", char, sizeof(char), curData); |
| 838 | getEle(value, old, "short", short, sizeof(short), oldPtr); |
| 839 | setEle(value, cur, "short", short, sizeof(short), curData); |
| 840 | getEle(value, old, "ushort", unsigned short, sizeof(unsigned short), oldPtr); |
| 841 | setEle(value, cur, "ushort", unsigned short, sizeof(unsigned short), curData); |
| 842 | getEle(value, old, "int", int, sizeof(int), oldPtr); |
| 843 | setEle(value, cur, "int", int, sizeof(int), curData); |
| 844 | getEle(value, old, "long", int, sizeof(int), oldPtr); |
| 845 | setEle(value, cur, "long", int, sizeof(int), curData); |
| 846 | getEle(value, old, "float", float, sizeof(float), oldPtr); |
| 847 | setEle(value, cur, "float", float, sizeof(float), curData); |
| 848 | getEle(value, old, "double", double, sizeof(double), oldPtr); |
| 849 | setEle(value, cur, "double", double, sizeof(double), curData); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | // ----------------------------------------------------- // |
| 854 | void bFile::swapData(char *data, short type, int arraySize, bool ignoreEndianFlag) |
no outgoing calls
no test coverage detected