MCPcopy Create free account
hub / github.com/alandefreitas/matplotplusplus / parse_string

Method parse_string

source/matplot/core/line_spec.cpp:20–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 }
19
20 void line_spec::parse_string(std::string_view expr) {
21 for (size_t expr_pos = 0; expr_pos != expr.size(); ++expr_pos) {
22 size_t chars_left = expr.size() - expr_pos;
23 switch (expr[expr_pos]) {
24 case '-':
25 if (chars_left != 1 && expr[expr_pos + 1] == '-') {
26 // "--"
27 line_style_ = line_style::dashed_line;
28 ++expr_pos;
29 } else if (chars_left != 1 && expr[expr_pos + 1] == '.') {
30 // "-."
31 line_style_ = line_style::dash_dot_line;
32 ++expr_pos;
33 } else {
34 line_style_ = line_style::solid_line;
35 }
36 break;
37 case ':':
38 line_style_ = line_style::dotted_line;
39 break;
40 case '+':
41 marker_style_ = marker_style::plus_sign;
42 break;
43 case 'o':
44 marker_style_ = marker_style::circle;
45 break;
46 case '*':
47 marker_style_ = marker_style::asterisk;
48 break;
49 case '.':
50 marker_style_ = marker_style::point;
51 break;
52 case 'x':
53 marker_style_ = marker_style::cross;
54 break;
55 case 's':
56 marker_style_ = marker_style::square;
57 if (expr.substr(expr_pos, 6) == "square") {
58 expr_pos += 5;
59 }
60 break;
61 case 'd':
62 marker_style_ = marker_style::diamond;
63 if (expr.substr(expr_pos, 7) == "diamond") {
64 expr_pos += 6;
65 }
66 break;
67 case '^':
68 marker_style_ = marker_style::upward_pointing_triangle;
69 break;
70 case 'V':
71 case 'v':
72 marker_style_ = marker_style::downward_pointing_triangle;
73 break;
74 case '>':
75 marker_style_ = marker_style::custom;
76 custom_marker_ = "▶";
77 break;

Callers 5

line.cppFile · 0.80
network.cppFile · 0.80
surface.cppFile · 0.80
contours.cppFile · 0.80
vectors.cppFile · 0.80

Calls 3

char_to_colorFunction · 0.85
to_arrayFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected