Advertisement
arsovski

create

Jun 19th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //create
  2. void CommandParser::create(const std::vector<std::string>& shapeInput)
  3. {
  4. if (!shapeInput.empty())
  5. { //can a sstream be treated as a string
  6. //TODO create a sstream with xml shape syntax and send it to create shape tag or better yet create cirle /rect etc..
  7. if (createInputShape(shapeInput))
  8. std::cout << "Successfully created shape at (" << shapes.size() - 1 << ") position.\n";
  9. else
  10. std::cerr << "Enter the correct shape format \n";
  11. }
  12. }
  13.  
  14. bool CommandParser::createInputShape(const std::vector<std::string>& shapeInput)
  15. {
  16. if(shapeInput[0]=="rectangle")
  17. {
  18. int rectMin = 8; //no of elements a rectangle needs to have
  19. if (shapeInput.size() != rectMin) return false;
  20.  
  21. std::string rectShape = "<rect x=\"" + shapeInput[1] + "\"y=\" " + shapeInput[2] + "\"width=\"" +
  22. shapeInput[3] + "\" height=\" " + shapeInput[4] + "\" fill=\" " + shapeInput[5] +
  23. +"\" stroke=\" " + shapeInput[6] + "\" stroke-width=\" " + shapeInput[7] = "\" >";
  24. createShape(rectShape);
  25. return true;
  26. }
  27.  
  28. if(shapeInput[0]=="circle")
  29. {
  30.  
  31. }
  32.  
  33. if(shapeInput[0]=="ellipse")
  34. {
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement