It is uses by MarkMask to ask Field under shape.
Definition at line 14 of file Shape.h.
Public Types | |
typedef std::vector< V2 > | t_marks |
typedef t_marks::const_iterator | const_iterator |
Public Member Functions | |
Shape (const std::string &shape) | |
Read shape in format: "XXX. | |
const_iterator | marksBegin () const |
const_iterator | marksEnd () const |
int | getW () const |
int | getH () const |
std::string | toString () const |
|
|
|
|
|
Read shape in format: "XXX.
.. NOTE: rows does not need to have the same length
Definition at line 25 of file Shape.cpp. 00026 { 00027 int x = 0; 00028 int y = 0; 00029 int max_x = -1; 00030 int max_y = -1; 00031 00032 for (unsigned int i = 0; i < shape.size(); ++i) { 00033 switch (shape[i]) { 00034 case '\n': 00035 ++y; 00036 x = 0; 00037 break; 00038 case 'X': 00039 m_marks.push_back(V2(x, y)); 00040 max_x = max(max_x, x); 00041 max_y = max(max_y, y); 00042 ++x; 00043 break; 00044 case '.': 00045 ++x; 00046 break; 00047 default: 00048 throw LayoutException(ExInfo("bad shape char") 00049 .addInfo("char", shape[i]) 00050 .addInfo("shape", shape)); 00051 } 00052 } 00053 00054 m_w = max_x + 1; 00055 m_h = max_y + 1; 00056 }
|
|
Definition at line 28 of file Shape.h. 00028 { return m_h; }
|
|
Definition at line 27 of file Shape.h. 00027 { return m_w; }
|
|
Definition at line 25 of file Shape.h. 00025 { return m_marks.begin(); }
|
|
Definition at line 26 of file Shape.h. 00026 { return m_marks.end(); }
|
|
Definition at line 60 of file Shape.cpp. 00061 { 00062 std::string result; 00063 00064 t_marks::const_iterator end = m_marks.end(); 00065 for (t_marks::const_iterator i = m_marks.begin(); i != end; ++i) { 00066 result.append(i->toString()); 00067 } 00068 return result; 00069 }
|