JAExUtil.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // Created by Ht on 2022/11/10.
  3. //
  4. #ifndef IOT_EDGE_VDALNEW_JAEXUTIL_H
  5. #define IOT_EDGE_VDALNEW_JAEXUTIL_H
  6. #include <qlibc/qlibc.h>
  7. namespace ja {
  8. class JE_API JAExUtil {
  9. public:
  10. static void clearTypePrefix (std::string& dest) {
  11. if(dest.empty() || dest == "$null") {
  12. dest.clear();
  13. return;
  14. }
  15. //查找
  16. auto next = dest.find("__$");
  17. auto size = dest.size();
  18. while(next!=std::string::npos && next < size-1) {
  19. auto t = dest[next+3];
  20. switch (t) {
  21. case 'n': //数字 __$n
  22. case 'b': //布尔
  23. case 'f': //浮点
  24. case 's': //字符串
  25. case 'o': //对象
  26. dest.erase(next, 4);
  27. size = dest.size();
  28. break;
  29. default: //不做改变
  30. break;
  31. }
  32. if(next>=size) break;
  33. next = dest.find("__$", next+1);
  34. }
  35. }
  36. };
  37. }
  38. #endif //IOT_EDGE_VDALNEW_JAEXUTIL_H