Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double parsedX;
- double parsedY;
- double parsedCR;
- double parsedStrokeWidth;
- std::string parsedFill;
- std::string parsedStroke;
- std::regex regX("<circle[^>]*cx\s*=\s*\"?(\d+)\"?[^>]*>");
- std::regex regY("<circle[^>]*cy\s*=\s*\"?(\d+)\"?[^>]*>");
- std::regex regCR("<circle[^>]*[(r)(cr)]\s*=\s*\"?(\d+)\"?[^>]*>");
- std::regex regStrokeWidth("<circle[^>]*stroke-width\s*=\s*\"?(\d+)\"?[^>]*>");
- std::regex regFill("<circle[^>]*fill\s*=\s*\"?(\w+)\"?[^>]*>");
- std::regex regStroke("<circle[^>]*stroke\s*=\s*\"?(\w+)\"?[^>]*>");
- std::smatch matches1;
- std::smatch matches2;
- std::smatch matches3;
- std::smatch matches4;
- std::smatch matches5;
- std::smatch matches6;
- if(std::regex_search(fileLine,matches1,regX))
- {
- std::stringstream extractor(matches1[0]);
- extractor >> parsedX;
- if (!(parsedX >= 0))
- throw std::runtime_error("Invalid x (must be positive )");
- //x exists
- //extract x from string
- }
- //!Idea to set values - int and strings to "no" and to do if statements later to check for them
- if (std::regex_search(fileLine, matches2, regY))
- {
- std::stringstream extractor(matches2[0]);
- extractor >> parsedY;
- if (!(parsedY >= 0))
- throw std::runtime_error("Invalid y (must be positive )");
- //y exists
- }
- if (std::regex_search(fileLine, matches3, regCR))
- {
- std::stringstream extractor(matches3[0]);
- extractor >> parsedCR;
- if (!(parsedCR >= 0))
- throw std::runtime_error("Invalid r (must be positive )");
- //cr exists
- }
- if (std::regex_search(fileLine, matches4, regStrokeWidth))
- {
- //stroke width exists
- }
- if (std::regex_search(fileLine, matches5, regFill))
- {
- //fill exists
- }
- if (std::regex_search(fileLine, matches6, regStroke))
- {
- //stroke exists
- }
- //match all regex
- //check the vector basic make it work
- //create at least a circle object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement