Advertisement
arsovski

haloAMor

Jun 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. double parsedX;
  2. double parsedY;
  3. double parsedCR;
  4. double parsedStrokeWidth;
  5. std::string parsedFill;
  6. std::string parsedStroke;
  7. std::regex regX("<circle[^>]*cx\s*=\s*\"?(\d+)\"?[^>]*>");
  8. std::regex regY("<circle[^>]*cy\s*=\s*\"?(\d+)\"?[^>]*>");
  9. std::regex regCR("<circle[^>]*[(r)(cr)]\s*=\s*\"?(\d+)\"?[^>]*>");
  10. std::regex regStrokeWidth("<circle[^>]*stroke-width\s*=\s*\"?(\d+)\"?[^>]*>");
  11. std::regex regFill("<circle[^>]*fill\s*=\s*\"?(\w+)\"?[^>]*>");
  12. std::regex regStroke("<circle[^>]*stroke\s*=\s*\"?(\w+)\"?[^>]*>");
  13. std::smatch matches1;
  14. std::smatch matches2;
  15. std::smatch matches3;
  16. std::smatch matches4;
  17. std::smatch matches5;
  18. std::smatch matches6;
  19. if(std::regex_search(fileLine,matches1,regX))
  20. {
  21. std::stringstream extractor(matches1[0]);
  22. extractor >> parsedX;
  23. if (!(parsedX >= 0))
  24. throw std::runtime_error("Invalid x (must be positive )");
  25. //x exists
  26. //extract x from string
  27. }
  28. //!Idea to set values - int and strings to "no" and to do if statements later to check for them
  29. if (std::regex_search(fileLine, matches2, regY))
  30. {
  31. std::stringstream extractor(matches2[0]);
  32. extractor >> parsedY;
  33. if (!(parsedY >= 0))
  34. throw std::runtime_error("Invalid y (must be positive )");
  35. //y exists
  36. }
  37. if (std::regex_search(fileLine, matches3, regCR))
  38. {
  39. std::stringstream extractor(matches3[0]);
  40. extractor >> parsedCR;
  41. if (!(parsedCR >= 0))
  42. throw std::runtime_error("Invalid r (must be positive )");
  43. //cr exists
  44. }
  45. if (std::regex_search(fileLine, matches4, regStrokeWidth))
  46. {
  47. //stroke width exists
  48. }
  49. if (std::regex_search(fileLine, matches5, regFill))
  50. {
  51. //fill exists
  52. }
  53. if (std::regex_search(fileLine, matches6, regStroke))
  54. {
  55. //stroke exists
  56. }
  57. //match all regex
  58. //check the vector basic make it work
  59. //create at least a circle object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement