OSDN Git Service

Initial Commit
[qcad/qcad.git] / compiler / QParseInfo.cpp
1 //----------------------------------------------------------------------------\r
2 //  Parse information\r
3 //----------------------------------------------------------------------------\r
4 #ifdef __BORLANDC__\r
5 #include <vcl.h>\r
6 #pragma hdrstop\r
7 #endif //__BORLANDC__\r
8 \r
9 #include <iostream>\r
10 #include <string>\r
11 #include <vector>\r
12 #include "QParseInfo.h"\r
13 \r
14 //----------------------------------------------------------------------------\r
15 #ifdef __BORLANDC__\r
16 #pragma package(smart_init)\r
17 #endif //__BORLANDC__\r
18 \r
19 \r
20 std::vector<int> dummy_vec;\r
21 \r
22 /**\r
23  *  Constructor\r
24  */\r
25 QParseInfo::QParseInfo(const int _operator, const std::vector<int> &_targets,\r
26                        const double _rotation, const bool _result,\r
27                        const int _error) {\r
28   mOperator       = _operator;\r
29   mTargetIndices  = _targets;\r
30   mRotation       = _rotation;\r
31   mParseResult    = _result;\r
32   mErrorNo        = _error;\r
33 }\r
34 \r
35 /**\r
36  *  Constructor for error notification\r
37  */\r
38 QParseInfo::QParseInfo(const int _error) {\r
39   mOperator       = -1;\r
40   mTargetIndices  = dummy_vec;\r
41   mRotation       = 0;\r
42   mParseResult    = false;\r
43   mErrorNo        = _error;\r
44 }\r
45 \r
46 /**\r
47  *  Copy constructor\r
48  */\r
49 QParseInfo::QParseInfo(const QParseInfo &pinfo) {\r
50   mOperator       = pinfo.mOperator;\r
51   mTargetIndices  = pinfo.mTargetIndices;\r
52   mRotation       = pinfo.mRotation;\r
53   mParseResult    = pinfo.mParseResult;\r
54   mErrorNo        = pinfo.mErrorNo;\r
55 }\r
56 \r
57 /**\r
58  *  Operator<<\r
59  */\r
60 std::ostream &operator<<(std::ostream &os, const QParseInfo &pinfo) {\r
61   os <<   "operator    : " << pinfo.mOperator;\r
62   if (pinfo.mParseResult)\r
63     os << "\nparse result: true";\r
64   else\r
65     os << "\nparse result: false";\r
66   os << "\nerror no.   : " << pinfo.mErrorNo;\r
67   return os;\r
68 }\r