00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef PARSERRES_HH
00013 #define PARSERRES_HH
00014 #include "ippdme/ippdme.h"
00015
00016 #include "ippdme/ippResponseNameType.h"
00017 #include "ippdme/Response/ippResponse.h"
00018 #include "ippdme/ippTag.h"
00019 #include "ippdme/Property/ippOnePropertyAlignment.h"
00020 #include "ippdme/Property/ippOnePropertyAlignmentVolume.h"
00021 #include "ippdme/Property/ippOnePropertyName.h"
00022 #include "ippdme/Property/ippOnePropertyNumber.h"
00023 #include "ippdme/Property/ippOnePropertyId.h"
00024 #include "ippdme/Property/ippOnePropertyCollisionVolume.h"
00025
00026 #include <string>
00027 #include <vector>
00028
00029
00030
00031 namespace ipp
00032 {
00033 typedef enum parserResErrorId {
00034 OK = 0,
00035 BAD_CHARACTER_AFTER_KEYWORD,
00036 BAD_CHARACTER_AFTER_RESPONSE_END,
00037 BAD_COORDINATE_SYSTEM,
00038 BAD_E_NUMBER_EXPONENT_MUST_HAVE_ONE_TWO_OR_THREE_DIGITS,
00039 BAD_ERROR_CODE,
00040 BAD_GOTOPAR_PROPERTY,
00041 BAD_KEYWORD,
00042 BAD_MACHINE_CLASS,
00043 BAD_NUMBER_MORE_THAN_16_DIGITS,
00044 BAD_NUMBER_NO_DIGITS,
00045 BAD_NUMBER_TWO_DECIMAL_POINTS,
00046 BAD_PTMEASPAR_PROPERTY,
00047 BAD_RESPONSE_ITEMS,
00048 BAD_SECOND_KEYWORD,
00049 BAD_SEVENTH_CHARACTER_IN_RESPONSE,
00050 BAD_SEVERITY,
00051 BAD_STRING,
00052 BAD_TAG_CHARACTER,
00053 BAD_TEXT,
00054 BAD_THIRD_KEYWORD,
00055 BUG,
00056 ER_USED_TWICE,
00057 ERROR_CODE_MUST_HAVE_FOUR_DIGITS,
00058 FIRST_ARGUMENT_MUST_BE_SWITCH_ROTATE_MOVEAUTO_OR_MOVEMAN,
00059 IJK_USED_TWICE,
00060 IJKACT_USED_TWICE,
00061 Q_USED_TWICE,
00062 IJK_VALUES_MUST_BE_ZERO,
00063 ILLEGAL_SPACE,
00064 R_USED_TWICE,
00065 RESPONSE_NAME_MUST_BE_ERROR,
00066 SEVERITY_MUST_HAVE_ONE_DIGIT,
00067 SPACE_MISSING_AFTER_TAG,
00068 SPACE_MISSING_AT_EIGHTH_CHARACTER_OF_RESPONSE,
00069 TAG_NUMBER_OUT_OF_RANGE_FOR_COMMAND_TAG,
00070 TOOL_A_USED_TWICE,
00071 TOOL_B_USED_TWICE,
00072 TOOL_C_USED_TWICE,
00073 VALUE_MUST_BE_0_OR_1,
00074 X_USED_TWICE,
00075 Y_USED_TWICE,
00076 Z_USED_TWICE,
00077 ZERO_TAG_MUST_BE_SERVER_INITIATED_RESPONSE,
00078 BAD_PROPERTY,
00079 };
00080 }
00081
00082 typedef enum resItemType {
00083 RESCOMMA = ',',
00084 RESDOT = '.',
00085 RESDOUBLE = '#',
00086 RESKEYWORD = 'k',
00087 RESPARENLEFT = '(',
00088 RESPARENRIGHT= ')',
00089 RESSTRING = 's'
00090 };
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 class IPPDME_EXT_CLASS ippResponseParser
00125 {
00126 public:
00127 ippResponseParser();
00128 virtual ~ippResponseParser();
00129
00130 std::string getErrorMessageString() const;
00131
00132 ipp::parserResErrorId getParserErr() const { return _errorCode;}
00133 tagIdType getTagType() const {return _tagType;}
00134 int getTag() const {return _tag;}
00135
00136 ippResponsePtr parseResponse();
00137
00138 void parseTag();
00139
00140 void setInput(const char * input);
00141
00142 private:
00143
00144 int _arrayIndex;
00145 ipp::parserResErrorId _errorCode;
00146 char _inputArray[IPPSIZE];
00147
00148 int _itemCount;
00149
00150 std::vector<double> _resDoubles;
00151 std::vector<ippOtherKeyType> _resKeywords;
00152
00153 int _resSize;
00154 std::vector<std::string> _resStrings;
00155 std::vector<resItemType> _resTypes;
00156
00157 ippResponseNameType _responseName;
00158 tagIdType _tagType;
00159
00160 int _tag;
00161
00162
00163
00164 void makeArraysBigger();
00165 ippOnePropertyAlignmentPtr makeOnePropertyAlignment(int * n);
00166 ippOnePropertyAlignmentVolumePtr makeOnePropertyAlignmentVolume(int* n);
00167 ippOnePropertyCollisionVolumePtr makeOnePropertyCollisionVolume(int * n);
00168
00169 ippOnePropertyIdPtr makeOnePropertyId(int * n);
00170 ippOnePropertyNamePtr makeOnePropertyName(int * n);
00171 ippResponsePtr makeAlignResponse();
00172 ippResponsePtr makeCenterPartResponse();
00173 ippResponsePtr makeChangeToolEResponse();
00174 ippResponsePtr makeDataResponse();
00175 ippResponsePtr makeEnumPropResponse();
00176 ippResponsePtr makeErrorResponse();
00177 ippResponsePtr makeGetChangeToolActionResponse();
00178 ippResponsePtr makeGetCoordSystemResponse();
00179 ippResponsePtr makeGetCsyTransformationResponse();
00180 ippResponsePtr makeGetDMEVersionResponse();
00181 ippResponsePtr makeGetErrStatusEResponse();
00182 ippResponsePtr makeGetMachineClassResponse();
00183 ippResponsePtr makeGetPropResponse();
00184 ippResponsePtr makeGoToEResponse();
00185 ippResponsePtr makeIsHomedResponse();
00186 ippResponsePtr makeIsUserEnabledResponse();
00187 ippResponsePtr makeKeyPressEResponse();
00188 ippResponsePtr makePtMeasEResponse();
00189 ippResponsePtr makePtMeasOrGetResponse();
00190 ippResponsePtr makeScanResponse();
00191 ippResponsePtr makeServerInitiatedResponse();
00192 ippResponsePtr makeSetPropEResponse();
00193 ippResponsePtr makeStringResponse();
00194 ippResponsePtr makeTiltCenterPartResponse();
00195 ippResponsePtr makeTiltPartResponse();
00196
00197 void parseResItems();
00198 void parseKeyword();
00199 void parseNumber();
00200 void parseString();
00201 void unSpaceInputArray();
00202 private:
00203 ippResponseParser(const ippResponseParser&);
00204 void operator=(const ippResponseParser&);
00205
00206 void dump_token(int k);
00207
00208 bool CheckOptionalArgument(
00209 int& n,
00210 bool& hasArgurment,
00211 ippOtherKeyType type,
00212 double& value,
00213 parserResErrorId errorIfDuplicated
00214 );
00215
00216 bool CheckOptionalArgument(
00217 int& n,
00218 bool& hasArgurment,
00219 ippOtherKeyType type1,
00220 ippOtherKeyType type2,
00221 double& value,
00222 parserResErrorId errorIfDuplicated
00223 );
00224 bool CheckOptionalArgument(
00225 int& n,
00226 bool& hasArgurment,
00227 ippOtherKeyType type,
00228 double& value1,
00229 double& value2,
00230 double& value3,
00231 parserResErrorId errorIfDuplicated
00232 );
00233 };
00234
00235 #endif
00236
00237
00238
00239
00240