Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ippResponseParser.h

Go to the documentation of this file.
00001 // 
00002 // DISCLAIMER: 
00003 //  This software was produced by the National Institute of Standards 
00004 //  and Technology (NIST), an agency of the U.S. government, and by statute is 
00005 //  not subject to copyright in the United States.  Recipients of this 
00006 //  software assume all responsibility associated with its operation,
00007 //  modification,maintenance, and subsequent redistribution. 
00008 //
00009 //  See NIST Administration Manual 4.09.07 b and Appendix I. 
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 /* error codes
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 /* parserRes
00094 
00095 To use the parser, the setInput() method must first be called to copy an
00096 input string into the parser's inputArray. An alternative would be to
00097 have a string as an argument to the parseXXX methods. Copying to
00098 inputArray takes time, but it prevents the parser from messing up the
00099 original string.
00100 
00101 The caller should then call parseResponse(), which makes an instance of
00102 the Response from the input string (if there is no error in the string).
00103 If there is an error in the string, parseResponse returns NULL.
00104 
00105 After calling parseResponse, the caller should call getParserErr()
00106 to see if there was an error. If the returned error code is not OK,
00107 the caller can call getErrorMessageString(buffer) to get an error message
00108 that describes the error. The buffer should be at least 100 chars long.
00109 If no error occurs until after the responseNameType is identified, the
00110 responseNameType is given at the beginning of the error message.
00111 
00112 If the error code is OK, the caller can start processing the Response
00113 instance.
00114 
00115 The caller may call parseTag() before calling parseResponse(), but that
00116 is not required.
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   // tag number of command being parsed
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 /* #ifndef PARSERRES_HH */
00236 
00237 
00238 
00239 
00240 

Generated on Wed Nov 8 00:19:59 2006 for IPPDME by  doxygen 1.4.1