00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "stdafx.h"
00012
00013 #include "ippdme/Parser/ippCommandParser.h"
00014 #include "ippdme/Command/commands.h"
00015
00016 #include "ippdme/ippOtherKeyType.h"
00017 #include "ippdme/ippErrorNameType.h"
00018 #include "ippPatternChecker.h"
00019 #include "ippdme/misc/ippPropDefinition.h"
00020 #include "ippdme/assert.h"
00021
00022 #include <map>
00023 class ippCommandHashTable
00024 {
00025 typedef std::map<std::string,ippCommandNameType> Map;
00026 typedef std::map<std::string,ippCommandNameType>::const_iterator _Iter;
00027 typedef std::pair <std::string, ippCommandNameType> _Pair;
00028 Map _map;
00029 public:
00030 ippCommandHashTable();
00031 ippCommandNameType find(const std::string& string);
00032 } g_command_hash;
00033
00034
00035
00036 #ifdef _DEBUG
00037 #define new DEBUG_NEW
00038 #undef THIS_FILE
00039 static char THIS_FILE[] = __FILE__;
00040 #endif
00041
00042 bool IsInteger(double value)
00043 {
00044 return (value -(int)value) ==0;
00045 }
00046 bool IsBoolean(double value)
00047 {
00048 return ( value == 0 || value == 1);
00049 }
00050 bool AsBoolean(double value)
00051 {
00052 IPP_ASSERT(IsBoolean(value));
00053 return value != 0.0 ;
00054 }
00055 int AsInteger(double value)
00056 {
00057 IPP_ASSERT(IsInteger(value));
00058 return (int)value;
00059 }
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 ippCommandParser::ippCommandParser()
00095 {
00096 _argCount = 0;
00097 _argSize = INITARGS;
00098 _argDoubles.resize(_argSize);
00099 _argKeywords.resize(_argSize);
00100 _argStrings.resize(_argSize);
00101 _argTypes.resize(_argSize);
00102 _arrayIndex = 0;
00103 }
00104
00105 ippCommandParser::~ippCommandParser()
00106 {
00107 }
00108
00109
00110
00111 void ippCommandParser::setInput(const char * input)
00112 {
00113 strcpy(_inputArray, input);
00114
00115
00116 int length = strlen(_inputArray);
00117 if (length>2 && _inputArray[length-1]!='\n' && _inputArray[length-2]!='\r') {
00118 _inputArray[length+0]='\r';
00119 _inputArray[length+1]='\n';
00120 _inputArray[length+2]=0;
00121
00122 }
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 #define PARSER_ERROR_ENUMERATION\
00155 ENUM(OK ,"OK")\
00156 ENUM(ARGUMENT_FIRST_PART_MUST_BE_TOOL_OR_FOUNDTOOL, "ARGUMENT FIRST PART MUST BE TOOL OR FOUNDTOOL")\
00157 ENUM(ARGUMENT_FOURTH_PART_MUST_BE_ACT, "ARGUMENT FOURTH PART MUST BE ACT")\
00158 ENUM(ARGUMENT_FOURTH_PART_BAD, "ARGUMENT FOURTH PART BAD")\
00159 ENUM(ARGUMENT_MUST_BE_A_NUMBER, "ARGUMENT MUST BE A NUMBER")\
00160 ENUM(ARGUMENT_MUST_BE_EVENT_TAG, "ARGUMENT MUST BE EVENT TAG")\
00161 ENUM(ARGUMENT_MUST_BE_INTEGER, "ARGUMENT MUST BE INTEGER")\
00162 ENUM(ARGUMENT_MUST_BE_POSITIVE, "ARGUMENT MUST BE POSITIVE")\
00163 ENUM(ARGUMENT_MUST_BE_STRING, "ARGUMENT MUST BE STRING")\
00164 ENUM(ARGUMENT_MUST_END_WITH_EMPTY_PARENTHESES, "ARGUMENT MUST END WITH EMPTY PARENTHESES")\
00165 ENUM(ARGUMENT_MUST_END_WITH_NUMBER_IN_PARENTHESES, "ARGUMENT MUST END WITH NUMBER IN PARENTHESES")\
00166 ENUM(ARGUMENT_SECOND_PART_BAD, "ARGUMENT SECOND PART BAD")\
00167 ENUM(ARGUMENT_SECOND_PART_MUST_BE_GOTOPAR_OR_PTMEASPAR, "ARGUMENT SECOND PART MUST BE GOTOPAR OR PTMEASPAR")\
00168 ENUM(ARGUMENT_THIRD_PART_BAD, "ARGUMENT THIRD PART BAD")\
00169 ENUM(BAD_ARGUMENTS, "BAD ARGUMENTS")\
00170 ENUM(BAD_CHARACTER_AFTER_COMMAND_END, "BAD CHARACTER AFTER COMMAND END")\
00171 ENUM(BAD_CHARACTER_AFTER_KEYWORD, "BAD CHARACTER AFTER KEYWORD")\
00172 ENUM(BAD_COMMAND_ARGUMENTS, "BAD COMMAND ARGUMENTS")\
00173 ENUM(BAD_COMMAND_NAME, "BAD COMMAND NAME")\
00174 ENUM(BAD_DOTS, "BAD DOTS")\
00175 ENUM(BAD_E_NUMBER_EXPONENT_MUST_HAVE_ONE_TWO_OR_THREE_DIGITS,"BAD E NUMBER EXPONENT MUST HAVE ONE TWO OR THREE DIGITS")\
00176 ENUM(BAD_FIRST_ARGUMENT, "BAD FIRST ARGUMENT")\
00177 ENUM(BAD_IJK_NUMBERS, "BAD IJK NUMBERS")\
00178 ENUM(BAD_KEYWORD, "BAD KEYWORD")\
00179 ENUM(BAD_NUMBER_MORE_THAN_16_DIGITS, "BAD NUMBER MORE THAN 16 DIGITS")\
00180 ENUM(BAD_NUMBER_NO_DIGITS, "BAD NUMBER NO DIGITS")\
00181 ENUM(BAD_NUMBER_OF_THROUGHS, "BAD NUMBER OF THROUGHS")\
00182 ENUM(BAD_NUMBER_TWO_DECIMAL_POINTS, "BAD NUMBER TWO DECIMAL POINTS")\
00183 ENUM(BAD_STRING, "BAD STRING")\
00184 ENUM(BAD_TAG_CHARACTER, "BAD TAG CHARACTER")\
00185 ENUM(C_ARGUMENT_USED_TWICE, "C ARGUMENT USED TWICE")\
00186 ENUM(DIAMETER_MUST_BE_POSITIVE, "DIAMETER MUST BE POSITIVE")\
00187 ENUM(DIS_ARGUMENT_USED_TWICE, "DIS ARGUMENT USED TWICE")\
00188 ENUM(DIS_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS, "DIS MUST BE FOLLOWED BY NUMBER IN PARENS")\
00189 ENUM(ER_ARGUMENT_USED_TWICE, "ER ARGUMENT USED TWICE")\
00190 ENUM(EVENT_COMMAND_MUST_HAVE_EVENT_TAG, "EVENT COMMAND MUST HAVE EVENT TAG")\
00191 ENUM(IJK_ARGUMENT_USED_TWICE, "IJK ARGUMENT USED TWICE")\
00192 ENUM(IJK_NOT_FOLLOWED_BY_ARGIJK, "IJK NOT FOLLOWED BY ARGIJK")\
00193 ENUM(LMN_ARGUMENT_USED_TWICE, "LMN ARGUMENT USED TWICE")\
00194 ENUM(LMN_NOT_FOLLOWED_BY_ARGIJK, "LMN NOT FOLLOWED BY ARGIJK")\
00195 ENUM(ILLEGAL_SPACE, "ILLEGAL SPACE")\
00196 ENUM(MUST_HAVE_NO_ARGUMENTS, "MUST HAVE NO ARGUMENTS")\
00197 ENUM(MUST_HAVE_ONE_ARGUMENT, "MUST HAVE ONE ARGUMENT")\
00198 ENUM(MUST_HAVE_4_ARGUMENTS, "MUST HAVE 4 ARGUMENTS")\
00199 ENUM(MUST_HAVE_4_OR_8_ARGUMENTS, "MUST HAVE 4 OR 8 ARGUMENTS")\
00200 ENUM(MUST_HAVE_7_ARGUMENTS, "MUST HAVE 7 ARGUMENTS")\
00201 ENUM(MUST_HAVE_7_OR_14_ARGUMENTS, "MUST HAVE 7 OR 14 ARGUMENTS")\
00202 ENUM(NON_EVENT_COMMAND_MUST_NOT_HAVE_EVENT_TAG, "NON EVENT COMMAND MUST NOT HAVE EVENT TAG")\
00203 ENUM(NUMBER_THROUGH_MUST_BE_INTEGER, "NUMBER THROUGH MUST BE INTEGER")\
00204 ENUM(NUMBER_THROUGH_MUST_BE_POSITIVE, "NUMBER THROUGH MUST BE POSITIVE")\
00205 ENUM(PHI_ARGUMENT_USED_TWICE, "PHI ARGUMENT USED TWICE")\
00206 ENUM(Q_ARGUMENT_USED_TWICE, "Q ARGUMENT USED TWICE")\
00207 ENUM(R_ARGUMENT_USED_TWICE, "R ARGUMENT USED TWICE")\
00208 ENUM(SPACE_MISSING_AFTER_TAG, "SPACE MISSING AFTER TAG")\
00209 ENUM(STEPW_MUST_BE_POSITIVE, "STEPW MUST BE POSITIVE")\
00210 ENUM(TAG_NUMBER_OUT_OF_RANGE_FOR_EVENT_TAG, "TAG NUMBER OUT OF RANGE FOR EVENT TAG")\
00211 ENUM(TAG_NUMBER_OUT_OF_RANGE_FOR_COMMAND_TAG, "TAG NUMBER OUT OF RANGE FOR COMMAND TAG")\
00212 ENUM(THETA_OUT_OF_RANGE, "THETA OUT OF RANGE")\
00213 ENUM(TIME_ARGUMENT_USED_TWICE, "TIME ARGUMENT USED TWICE")\
00214 ENUM(TIME_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS, "TIME MUST BE FOLLOWED BY NUMBER IN PARENS")\
00215 ENUM(TOOL_A_ARGUMENT_USED_TWICE, "TOOL A ARGUMENT USED TWICE")\
00216 ENUM(TOOL_B_ARGUMENT_USED_TWICE, "TOOL B ARGUMENT USED TWICE")\
00217 ENUM(TOOL_C_ARGUMENT_USED_TWICE, "TOOL C ARGUMENT USED TWICE")\
00218 ENUM(X_ARGUMENT_USED_TWICE, "X ARGUMENT USED TWICE")\
00219 ENUM(X_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, "X NOT FOLLOWED BY NUMBER IN PARENS")\
00220 ENUM(X_Y_Z_ALL_MISSING, "X Y Z ALL MISSING")\
00221 ENUM(Y_ARGUMENT_USED_TWICE, "Y ARGUMENT USED TWICE")\
00222 ENUM(Y_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, "Y NOT FOLLOWED BY NUMBER IN PARENS")\
00223 ENUM(Z_ARGUMENT_USED_TWICE, "Z ARGUMENT USED TWICE")\
00224 ENUM(Z_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, "Z NOT FOLLOWED BY NUMBER IN PARENS")\
00225 ENUM(TOOL_A_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, "TOOL.A NOT FOLLOWED BY NUMBER IN_PARENS")\
00226 ENUM(TOOL_B_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, "TOOL.B NOT FOLLOWED BY NUMBER IN_PARENS")\
00227 ENUM(TOOL_C_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, "TOOL.C NOT FOLLOWED BY NUMBER IN_PARENS")\
00228 ENUM(IJKACT_ARGUMENT_USED_TWICE, "IJKACT ARGUMENT USED TWICE")\
00229 ENUM(DENSITY_MUST_BE_POSITIVE, "DENSITY MUST BE POSITIVE")\
00230 ENUM(MINIMUM_RADIUS_OF_CURVATURE_MUST_BE_POSITIVE, "MINIMUM RADIUS OF CURVATURE MUST BE POSITIVE")\
00231 ENUM(ANGLE_ARGUMENT_USED_TWICE, "ANGLE ARGUMENT USED TWICE")\
00232 ENUM(ATNOMINALS_ARGUMENT_USED_TWICE, "ATNOMINALS ARGUMENT USED TWICE")\
00233 ENUM(ANGLE_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS, "ANGLE MUST BE FOLLOWED BY NUMBER IN PARENS")\
00234 ENUM(ATNOMINALS_NOT_FOLLOWED_BY_BOOLEAN_IN_PARENS, "ATNOMINALS NOT FOLLOWED BY BOOLEAN IN PARENS")\
00235 ENUM(BAD_SYNTAX_FOR_FORMAT_IN_SCANONCURVE, "BAD SYNTAX FOR FORMAT IN SCANONCURVE")\
00236 ENUM(BAD_NUMBER_OF_ARGUMENT_FOR_DATA_IN_SCANONCURVE, "BAD NUMBER OF ARGUMENT FOR DATA IN SCANONCURVE")\
00237 ENUM(NOT_IMPLEMENTED_YET, "NOT_IMPLEMENTED_YET")
00238
00239
00240
00241 std::string ippCommandParser::getErrorMessageString() const
00242 {
00243 std::string errorString ;
00244 switch(_errorCode) {
00245 #define ENUM(a,b) case a: errorString=b; break;
00246 PARSER_ERROR_ENUMERATION
00247 #undef ENUM
00248 }
00249
00250 std::string retval;
00251
00252 if ((_commandName > -1) && (_commandName < ippCOMMANDNAMETYPE_MAXIMUM)) {
00253 retval.append(getCommandNameString(_commandName));
00254 retval.append(" : ");
00255 }
00256
00257 retval.append(errorString);
00258 return retval;
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 void ippCommandParser::makeArraysBigger()
00280 {
00281 _argSize = (2 * _argSize);
00282 _argDoubles.resize(_argSize);
00283 _argKeywords.resize(_argSize);
00284 _argStrings.resize(_argSize);
00285 _argTypes.resize(_argSize);
00286 }
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 ippCommandPtr ippCommandParser::makeAbortE()
00307 {
00308 if (_argCount != 0) {
00309 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00310 }
00311 return ((_errorCode != OK) ? 0 : new ippCommand(_tag, AbortE));
00312 }
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 ippCommandPtr ippCommandParser::makeAlignPart()
00335 {
00336 if (_argCount == 13 ) {
00337 if (!match(_argTypes,"#,#,#,#,#,#,#")) {
00338 _errorCode = BAD_ARGUMENTS;
00339 }
00340 } else if ( _argCount == 27 ) {
00341 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#,#")) {
00342 _errorCode = BAD_ARGUMENTS;
00343 }
00344 } else {
00345 _errorCode = MUST_HAVE_7_OR_14_ARGUMENTS;
00346 }
00347
00348 return ((_errorCode != OK) ? NULL:
00349 (_argCount == 13) ?
00350 new ippAlignPartCommand(_tag,
00351 getValue(0), getValue(2), getValue(4),
00352 getValue(6), getValue(8), getValue(10),
00353 getValue(12)) :
00354 new ippAlignPartCommand(_tag,
00355 getValue(0), getValue(2), getValue(4),
00356 getValue(6), getValue(8), getValue(10),
00357 getValue(12), getValue(14), getValue(16),
00358 getValue(18), getValue(20), getValue(22),
00359 getValue(24), getValue(26)));
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 ippCommandPtr ippCommandParser::makeAlignTool()
00383 {
00384
00385 if (_argCount == 7 ) {
00386 if (!match(_argTypes,"#,#,#,#")) {
00387 _errorCode = BAD_ARGUMENTS;
00388 }
00389 } else if ( _argCount == 15 ) {
00390 if (!match(_argTypes,"#,#,#,#,#,#,#,#")) {
00391 _errorCode = BAD_ARGUMENTS;
00392 }
00393 } else {
00394 _errorCode = MUST_HAVE_4_OR_8_ARGUMENTS;
00395 }
00396 return ((_errorCode != OK) ? NULL:
00397 (_argCount == 7) ?
00398 new ippAlignToolCommand(_tag, getValue(0), getValue(2),
00399 getValue(4), getValue(6)) :
00400 new ippAlignToolCommand(_tag, getValue(0), getValue(2),
00401 getValue(4), getValue(6),
00402 getValue(8), getValue(10),
00403 getValue(12), getValue(14)));
00404 }
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 ippCommandPtr ippCommandParser::makeCenterPart()
00427 {
00428 if (_argCount != 7) {
00429 _errorCode = MUST_HAVE_4_ARGUMENTS;
00430 }
00431 if (!match(_argTypes,"#,#,#,#")) {
00432 _errorCode = BAD_ARGUMENTS;
00433 }
00434 return ((_errorCode != OK) ? NULL:
00435 new ippCenterPartCommand(_tag, getValue(0), getValue(2),
00436 getValue(4), getValue(6)));
00437 }
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457 ippCommandPtr ippCommandParser::makeChangeTool()
00458 {
00459 if (_argCount != 1)
00460 _errorCode = MUST_HAVE_ONE_ARGUMENT;
00461 else if (_argTypes[0] != ARGSTRING)
00462 _errorCode = ARGUMENT_MUST_BE_STRING;
00463 return ((_errorCode != OK) ? NULL :
00464 (new ippChangeToolCommand(_tag, _argStrings[0].c_str())));
00465 }
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484 ippCommandPtr ippCommandParser::makeClearAllErrors()
00485 {
00486 if (_argCount != 0)
00487 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00488 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, ClearAllErrors)));
00489 }
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 ippCommandPtr ippCommandParser::makeDisableUser()
00509 {
00510 if (_argCount != 0)
00511 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00512 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, DisableUser)));
00513 }
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532 ippCommandPtr ippCommandParser::makeEnableUser()
00533 {
00534 if (_argCount != 0)
00535 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00536 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, EnableUser)));
00537 }
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556 ippCommandPtr ippCommandParser::makeEndSession()
00557 {
00558 if (_argCount != 0)
00559 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00560 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, EndSession)));
00561 }
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 ippCommandPtr ippCommandParser::makeEnumAllProp()
00605 {
00606
00607 ippOtherKeyType key1 = EmptyKey;
00608 ippOtherKeyType key2 = EmptyKey;
00609 ippOtherKeyType key3 = EmptyKey;
00610 ippOtherKeyType key4 = EmptyKey;
00611
00612 if (_argCount == 2 && match(_argTypes,"kE")) {
00613 key1 = _argKeywords[0];
00614 } else if (_argCount == 4 && match(_argTypes,"k.kE")) {
00615 key1 = _argKeywords[0];
00616 key2 = _argKeywords[2];
00617 } else if (_argCount == 6 && match(_argTypes,"k.k.kE")) {
00618 key1 = _argKeywords[0];
00619 key2 = _argKeywords[2];
00620 key3 = _argKeywords[4];
00621 } else if (_argCount == 8 && match(_argTypes,"k.k.k.kE")) {
00622 key1 = _argKeywords[0];
00623 key2 = _argKeywords[2];
00624 key3 = _argKeywords[4];
00625 key4 = _argKeywords[6];
00626 } else {
00627 _errorCode = BAD_ARGUMENTS;
00628 return 0;
00629
00630 }
00631 ippProp prop(key1,key2,key3,key4);
00632 if (!IsObjectOrProperty(prop)) {
00633 _errorCode = BAD_ARGUMENTS;
00634 return 0;
00635 }
00636
00637 ippEnumAllPropCommandPtr command = new ippEnumAllPropCommand(_tag,prop);
00638
00639 return command;
00640 }
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683 ippCommandPtr ippCommandParser::makeEnumProp()
00684 {
00685
00686 ippOtherKeyType key1 = EmptyKey;
00687 ippOtherKeyType key2 = EmptyKey;
00688 ippOtherKeyType key3 = EmptyKey;
00689 ippOtherKeyType key4 = EmptyKey;
00690
00691 if (_argCount == 2 && match(_argTypes,"kE")) {
00692 key1 = _argKeywords[0];
00693 } else if (_argCount == 4 && match(_argTypes,"k.kE")) {
00694 key1 = _argKeywords[0];
00695 key2 = _argKeywords[2];
00696 } else if (_argCount == 6 && match(_argTypes,"k.k.kE")) {
00697 key1 = _argKeywords[0];
00698 key2 = _argKeywords[2];
00699 key3 = _argKeywords[4];
00700 } else if (_argCount == 8 && match(_argTypes,"k.k.k.kE")) {
00701 key1 = _argKeywords[0];
00702 key2 = _argKeywords[2];
00703 key3 = _argKeywords[4];
00704 key4 = _argKeywords[6];
00705 } else {
00706 _errorCode = BAD_ARGUMENTS;
00707 return 0;
00708
00709 }
00710 ippProp prop(key1,key2,key3,key4);
00711 if (!IsObjectOrProperty(prop)) {
00712 _errorCode = BAD_ARGUMENTS;
00713 return 0;
00714 }
00715 ippEnumPropCommandPtr command = new ippEnumPropCommand(_tag,prop);
00716 return command;
00717
00718 }
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737 ippCommandPtr ippCommandParser::makeEnumTools()
00738 {
00739 if (_argCount != 0)
00740 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00741 return ((_errorCode != OK) ? NULL : (new ippEnumToolsCommand(_tag)));
00742 }
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763 ippCommandPtr ippCommandParser::makeFindTool()
00764 {
00765 if (_argCount != 1)
00766 _errorCode = MUST_HAVE_ONE_ARGUMENT;
00767 else if (_argTypes[0] != ARGSTRING)
00768 _errorCode = ARGUMENT_MUST_BE_STRING;
00769 return((_errorCode != OK) ? NULL: (new ippFindToolCommand(_tag, _argStrings[0].c_str())));
00770 }
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815 ippCommandPtr ippCommandParser::makeGet()
00816 {
00817 bool hasR = false;
00818 bool hasX = false;
00819 bool hasY = false;
00820 bool hasZ = false;
00821 bool hasToolA = false;
00822 bool hasToolB = false;
00823 bool hasToolC = false;
00824
00825 if (_argCount < 2) {
00826 _errorCode = BAD_ARGUMENTS;
00827 }
00828 int n =0;
00829
00830 while (n < _argCount && _errorCode == OK) {
00831 int old_n=n;
00832 CheckOptionalArgument(n,hasR ,_R , R_ARGUMENT_USED_TWICE);
00833 CheckOptionalArgument(n,hasX ,_X , X_ARGUMENT_USED_TWICE);
00834 CheckOptionalArgument(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE);
00835 CheckOptionalArgument(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE);
00836 CheckOptionalArgument(n,hasToolA,Tool,_A,TOOL_A_ARGUMENT_USED_TWICE);
00837 CheckOptionalArgument(n,hasToolB,Tool,_B,TOOL_B_ARGUMENT_USED_TWICE);
00838 CheckOptionalArgument(n,hasToolC,Tool,_C,TOOL_C_ARGUMENT_USED_TWICE);
00839 if (old_n == n) {
00840
00841 _errorCode = BAD_ARGUMENTS;
00842 }
00843 }
00844 return ((_errorCode != OK) ? NULL:
00845 (new ippGetCommand(_tag, hasR, hasX, hasY, hasZ,
00846 hasToolA, hasToolB, hasToolC)));
00847 }
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868 ippCommandPtr ippCommandParser::makeGetChangeToolAction()
00869 {
00870 if (_argCount != 1) {
00871 _errorCode = MUST_HAVE_ONE_ARGUMENT;
00872 } else if (_argTypes[0] != ARGSTRING) {
00873 _errorCode = ARGUMENT_MUST_BE_STRING;
00874 }
00875 return ((_errorCode != OK) ? NULL :
00876 (new ippGetChangeToolActionCommand(_tag, _argStrings[0].c_str())));
00877 }
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 ippCommandPtr ippCommandParser::makeGetCoordSystem()
00897 {
00898 if (_argCount != 0) {
00899 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00900 }
00901 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, GetCoordSystem)));
00902 }
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 ippCommandPtr ippCommandParser::makeGetCsyTransformation()
00925 {
00926 if (_argCount != 1)
00927 _errorCode = MUST_HAVE_ONE_ARGUMENT;
00928 else if ((_argTypes[0] != ARGKEYWORD) ||
00929 ((_argKeywords[0] != JogDisplayCsy) &&
00930 (_argKeywords[0] != JogMoveCsy) &&
00931 (_argKeywords[0] != MoveableMachineCsy) &&
00932 (_argKeywords[0] != MultipleArmCsy) &&
00933 (_argKeywords[0] != PartCsy) &&
00934 (_argKeywords[0] != SensorCsy)))
00935 _errorCode = BAD_ARGUMENTS;
00936 return ((_errorCode != OK) ? NULL :
00937 (new ippGetCsyTransformationCommand(_tag, (ippCoordSysType)_argKeywords[0])));
00938 }
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957 ippCommandPtr ippCommandParser::makeGetDMEVersion()
00958 {
00959 if (_argCount != 0)
00960 _errorCode = MUST_HAVE_NO_ARGUMENTS;
00961 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, GetDMEVersion)));
00962 }
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989 ippCommandPtr ippCommandParser::makeGetErrorInfo()
00990 {
00991 if (_argCount != 1){
00992 _errorCode = MUST_HAVE_ONE_ARGUMENT;
00993 } else if ((_argTypes[0] != ARGDOUBLE) || !IsInteger(getValue(0))){
00994 _errorCode = ARGUMENT_MUST_BE_INTEGER;
00995 }
00996 return ((_errorCode != OK) ? NULL :
00997 (new ippGetErrorInfoCommand(_tag, Convert2ippErrorNameType(getValue(0)))));
00998 }
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 ippCommandPtr ippCommandParser::makeGetErrStatusE()
01018 {
01019 if (_argCount != 0)
01020 _errorCode = MUST_HAVE_NO_ARGUMENTS;
01021 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, GetErrStatusE)));
01022 }
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041 ippCommandPtr ippCommandParser::makeGetMachineClass()
01042 {
01043 if (_argCount != 0)
01044 _errorCode = MUST_HAVE_NO_ARGUMENTS;
01045 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, GetMachineClass)));
01046 }
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129 ippCommandPtr ippCommandParser::makeGetProp()
01130 {
01131
01132 ippGetPropCommandPtr command;
01133 if ( _commandName == GetProp ) {
01134 command = new ippGetPropCommand(_tag);
01135 } else if(_commandName == GetPropE ) {
01136 command = new ippGetPropECommand(_tag);
01137 }
01138
01139
01140 for (int n = 0; ((n < _argCount) && (_errorCode == OK));n++) {
01141
01142 ippOtherKeyType key1 = ippOtherKeyType_INVALID;
01143 ippOtherKeyType key2 = EmptyKey;
01144 ippOtherKeyType key3 = EmptyKey;
01145 ippOtherKeyType key4 = EmptyKey;
01146
01147 if (match(_argTypes,"k.k.k.kE",n)) {
01148 key1 = _argKeywords[n];
01149 key2 = _argKeywords[n+2];
01150 key3 = _argKeywords[n+4];
01151 key4 = _argKeywords[n+6];
01152 n += 8;
01153
01154 } else if (match(_argTypes,"k.k.kE",n)) {
01155 key1 = _argKeywords[n];
01156 key2 = _argKeywords[n+2];
01157 key3 = _argKeywords[n+4];
01158 n += 6;
01159 } else if (match(_argTypes,"k.kE",n)) {
01160 key1 = _argKeywords[n];
01161 key2 = _argKeywords[n+2];
01162 n += 4;
01163 } else if (match(_argTypes,"kE",n)) {
01164 key1 = _argKeywords[n];
01165 n += 2;
01166 } else {
01167 _errorCode = BAD_ARGUMENTS;
01168 }
01169 if (n < _argCount && _argTypes[n] != ARGCOMMA) {
01170 _errorCode = BAD_ARGUMENTS;
01171 }
01172 if(_errorCode == OK ) {
01173 ippProp prop(key1,key2,key3,key4);
01174 if (PropertyIsAllowed(prop)) {
01175 command->addProp(prop);
01176 } else {
01177 _errorCode = BAD_ARGUMENTS;
01178 }
01179 }
01180 }
01181 if (_errorCode != OK) {
01182 return 0;
01183 }
01184 return command;
01185 }
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199 ippCommandPtr ippCommandParser::makeGetPropE()
01200 {
01201
01202 return makeGetProp();
01203 }
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224 ippCommandPtr ippCommandParser::makeGetXtdErrStatus()
01225 {
01226 if (_argCount != 0)
01227 _errorCode = MUST_HAVE_NO_ARGUMENTS;
01228 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, GetXtdErrStatus)));
01229 }
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262 ippCommandPtr ippCommandParser::makeGoTo()
01263 {
01264
01265 bool hasX = false;
01266 bool hasY = false;
01267 bool hasZ = false;
01268 double x = 0;
01269 double y = 0;
01270 double z = 0;
01271 bool hasToolA = false;
01272 bool hasToolB = false;
01273 bool hasToolC = false;
01274 double toolA = 0;
01275 double toolB = 0;
01276 double toolC = 0;
01277
01278 if (_argCount < 2) {
01279 _errorCode = BAD_ARGUMENTS;
01280 }
01281 int n =0;
01282
01283 while (n < _argCount && _errorCode == OK) {
01284 int old_n=n;
01285 CheckOptionalArgumentValue(n,hasX ,_X , X_ARGUMENT_USED_TWICE, X_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, x);
01286 CheckOptionalArgumentValue(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE, Y_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, y);
01287 CheckOptionalArgumentValue(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE, Z_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, z);
01288 CheckOptionalArgumentValue(n,hasToolA,Tool,_A,TOOL_A_ARGUMENT_USED_TWICE, TOOL_A_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, toolA);
01289 CheckOptionalArgumentValue(n,hasToolB,Tool,_B,TOOL_B_ARGUMENT_USED_TWICE, TOOL_B_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, toolB);
01290 CheckOptionalArgumentValue(n,hasToolC,Tool,_C,TOOL_C_ARGUMENT_USED_TWICE, TOOL_C_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, toolC);
01291 if (old_n == n) {
01292
01293 _errorCode = BAD_ARGUMENTS;
01294 }
01295 }
01296
01297 return ((_errorCode != OK) ? NULL:
01298 (new ippGoToCommand(_tag, hasX, hasY, hasZ, x, y, z, hasToolA,
01299 hasToolB, hasToolC, toolA, toolB, toolC)));
01300 }
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 ippCommandPtr ippCommandParser::makeHome()
01320 {
01321 if (_argCount != 0)
01322 _errorCode = MUST_HAVE_NO_ARGUMENTS;
01323 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, Home)));
01324 }
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343 ippCommandPtr ippCommandParser::makeIsHomed()
01344 {
01345 if (_argCount != 0)
01346 _errorCode = MUST_HAVE_NO_ARGUMENTS;
01347 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, IsHomed)));
01348 }
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367 ippCommandPtr ippCommandParser::makeIsUserEnabled()
01368 {
01369 if (_argCount != 0)
01370 _errorCode = MUST_HAVE_NO_ARGUMENTS;
01371 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, IsUserEnabled)));
01372 }
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410 ippCommandPtr ippCommandParser::makeLockAxis()
01411 {
01412 bool hasC = false;
01413 bool hasPhi = false;
01414 bool hasR = false;
01415 bool hasX = false;
01416 bool hasY = false;
01417 bool hasZ = false;
01418
01419 if (_argCount < 2) {
01420 _errorCode = BAD_ARGUMENTS;
01421 }
01422 int n =0;
01423 while (n < _argCount && _errorCode == OK) {
01424 int old_n=n;
01425 CheckOptionalArgument(n,hasC ,_C , C_ARGUMENT_USED_TWICE);
01426 CheckOptionalArgument(n,hasPhi ,Phi ,PHI_ARGUMENT_USED_TWICE);
01427 CheckOptionalArgument(n,hasR ,_R , R_ARGUMENT_USED_TWICE);
01428 CheckOptionalArgument(n,hasX ,_X , X_ARGUMENT_USED_TWICE);
01429 CheckOptionalArgument(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE);
01430 CheckOptionalArgument(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE);
01431 if (old_n == n) {
01432
01433 _errorCode = BAD_ARGUMENTS;
01434 }
01435 }
01436 return ((_errorCode != OK) ? NULL :
01437 (new ippLockAxisCommand(_tag, hasC, hasPhi, hasR, hasX, hasY, hasZ)));
01438 }
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482 ippCommandPtr ippCommandParser::makeOnMoveReportE()
01483 {
01484 int n;
01485 bool hasR = false;
01486 bool hasX = false;
01487 bool hasY = false;
01488 bool hasZ = false;
01489 bool hasToolA = false;
01490 bool hasToolB = false;
01491 bool hasToolC = false;
01492 bool hasDis = false;
01493 bool hasTime = false;
01494 double theDis = 100.0;
01495 double theTime = 100.0;
01496
01497 n = 0;
01498 while (n < _argCount && _errorCode == OK) {
01499 int old_n=n;
01500 CheckOptionalArgument(n,hasR ,_R , R_ARGUMENT_USED_TWICE);
01501 CheckOptionalArgument(n,hasX ,_X , X_ARGUMENT_USED_TWICE);
01502 CheckOptionalArgument(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE);
01503 CheckOptionalArgument(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE);
01504
01505 CheckOptionalArgument(n,hasToolA,Tool,_A,TOOL_A_ARGUMENT_USED_TWICE);
01506 CheckOptionalArgument(n,hasToolB,Tool,_B,TOOL_B_ARGUMENT_USED_TWICE);
01507 CheckOptionalArgument(n,hasToolC,Tool,_C,TOOL_C_ARGUMENT_USED_TWICE);
01508
01509 CheckOptionalArgumentValue(n,hasTime,Time,TIME_ARGUMENT_USED_TWICE,TIME_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS,theTime);
01510 CheckOptionalArgumentValue(n,hasDis ,Dis , DIS_ARGUMENT_USED_TWICE, DIS_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS,theDis);
01511 if (old_n == n) {
01512
01513 _errorCode = BAD_ARGUMENTS;
01514 }
01515 }
01516
01517 return ((_errorCode != OK) ? NULL:
01518 (new ippOnMoveReportECommand(_tag, hasR, hasX, hasY, hasZ, hasToolA,
01519 hasToolB, hasToolC, hasDis, hasTime, theDis, theTime)));
01520 }
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570 bool ippCommandParser::CheckOptionalArgument(
01571 int& n,
01572 bool& hasArgument,
01573 ippOtherKeyType type,
01574 ippParserCmdErrorId errorIfDuplicated
01575 )
01576 {
01577 if (_errorCode != OK) return false;
01578 if (_argCount < n+2) return false;
01579
01580 if (_argTypes[n] != ARGKEYWORD ) {
01581 return false;
01582 }
01583
01584 if (_argKeywords[n] != type) {
01585 return false;
01586 } else {
01587 if (hasArgument ) {
01588 _errorCode = errorIfDuplicated;
01589 } else {
01590 hasArgument = true;
01591 if (_argTypes[n+1] != ARGPARENEMPTY) {
01592 _errorCode = BAD_ARGUMENTS;
01593 return false;
01594 }
01595 if ( n+2 < _argCount && _argTypes[n+2] != ARGCOMMA ) {
01596 _errorCode = BAD_ARGUMENTS;
01597 return false;
01598 }
01599 }
01600 n +=3;
01601 }
01602 if (_errorCode == OK ) {
01603 return true;
01604 }
01605 return false;
01606 }
01607 bool ippCommandParser::CheckOptionalArgument(
01608 int& n,
01609 bool& hasArgument,
01610 ippOtherKeyType type1,
01611 ippOtherKeyType type2,
01612 ippParserCmdErrorId errorIfDuplicated
01613 )
01614 {
01615 if (_errorCode != OK) { return false; }
01616 if (_argCount < n+3) { return false;}
01617
01618 if (_argTypes[n] != ARGKEYWORD ||_argTypes[n+1]!=ARGDOT ||_argTypes[n+2] != ARGKEYWORD) {
01619 return false;
01620 }
01621
01622 if (_argKeywords[n] != type1 || _argKeywords[n+2] != type2) {
01623 return false;
01624 } else {
01625 if (hasArgument ) {
01626 _errorCode = errorIfDuplicated;
01627 } else {
01628 hasArgument = true;
01629 }
01630 if (_argTypes[n+3] != ARGPARENEMPTY ) {
01631 _errorCode = BAD_ARGUMENTS;
01632 return false;
01633 }
01634 if ( n+4 < _argCount && _argTypes[n+4] != ARGCOMMA ) {
01635 _errorCode = BAD_ARGUMENTS;
01636 return false;
01637 }
01638 n +=5;
01639 }
01640 if (_errorCode == OK ) {
01641 return true;
01642 }
01643 return false;
01644 }
01645
01646
01647
01648
01649 ippCommandPtr ippCommandParser::makeOnPtMeasReport()
01650 {
01651 int n;
01652 bool hasER = false;
01653 bool hasIJK = false;
01654 bool hasIJKAct = false;
01655 bool hasQ = false;
01656 bool hasR = false;
01657 bool hasX = false;
01658 bool hasY = false;
01659 bool hasZ = false;
01660 bool hasToolA = false;
01661 bool hasToolB = false;
01662 bool hasToolC = false;
01663
01664 if (_argCount <2 ) {
01665 _errorCode = BAD_ARGUMENTS;
01666 }
01667 n = 0;
01668 while (n < _argCount && _errorCode == OK) {
01669 int old_n=n;
01670 CheckOptionalArgument(n,hasER ,ER , ER_ARGUMENT_USED_TWICE);
01671 CheckOptionalArgument(n,hasIJK ,_IJK , IJK_ARGUMENT_USED_TWICE);
01672 CheckOptionalArgument(n,hasIJKAct,_IJKAct, IJKACT_ARGUMENT_USED_TWICE);
01673 CheckOptionalArgument(n,hasQ ,Q , Q_ARGUMENT_USED_TWICE);
01674 CheckOptionalArgument(n,hasR ,_R , R_ARGUMENT_USED_TWICE);
01675 CheckOptionalArgument(n,hasX ,_X , X_ARGUMENT_USED_TWICE);
01676 CheckOptionalArgument(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE);
01677 CheckOptionalArgument(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE);
01678 CheckOptionalArgument(n,hasToolA,Tool,_A,TOOL_A_ARGUMENT_USED_TWICE);
01679 CheckOptionalArgument(n,hasToolB,Tool,_B,TOOL_B_ARGUMENT_USED_TWICE);
01680 CheckOptionalArgument(n,hasToolC,Tool,_C,TOOL_C_ARGUMENT_USED_TWICE);
01681
01682 if (old_n == n) {
01683
01684 _errorCode = BAD_ARGUMENTS;
01685 }
01686 }
01687 return ((_errorCode != OK) ? NULL :
01688 (new ippOnPtMeasReportCommand(_tag, hasER, hasIJK,hasQ, hasR, hasX, hasY,
01689 hasZ,hasToolA, hasToolB, hasToolC,hasIJKAct)));
01690 }
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737 ippCommandPtr ippCommandParser::makeOnScanReport()
01738 {
01739 int n;
01740 bool hasER = false;
01741 bool hasIJK = false;
01742 bool hasIJKAct = false;
01743 bool hasQ = false;
01744 bool hasR = false;
01745 bool hasX = false;
01746 bool hasY = false;
01747 bool hasZ = false;
01748 bool hasToolA = false;
01749 bool hasToolB = false;
01750 bool hasToolC = false;
01751
01752
01753
01754
01755
01756 if (_argCount <2 ) {
01757 _errorCode = BAD_ARGUMENTS;
01758 }
01759 n = 0;
01760
01761 ippOnScanReportCommandPtr cmd = new ippOnScanReportCommand(_tag);
01762
01763 while (n < _argCount && _errorCode == OK) {
01764 int old_n=n;
01765
01766 if (CheckOptionalArgument(n,hasER ,ER , ER_ARGUMENT_USED_TWICE)) {
01767 cmd->append(ippOnScanReportCommand::ER);
01768 }
01769
01770 if(CheckOptionalArgument(n,hasIJK ,_IJK , IJK_ARGUMENT_USED_TWICE)) {
01771 cmd->append(ippOnScanReportCommand::IJK);
01772 }
01773
01774 if (CheckOptionalArgument(n,hasQ ,Q , Q_ARGUMENT_USED_TWICE)) {
01775 cmd->append(ippOnScanReportCommand::Q);
01776 }
01777
01778 if (CheckOptionalArgument(n,hasR ,_R , R_ARGUMENT_USED_TWICE)) {
01779 cmd->append(ippOnScanReportCommand::R);
01780 }
01781
01782 if (CheckOptionalArgument(n,hasX ,_X , X_ARGUMENT_USED_TWICE)) {
01783 cmd->append(ippOnScanReportCommand::X);
01784 }
01785
01786 if (CheckOptionalArgument(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE)) {
01787 cmd->append(ippOnScanReportCommand::Y);
01788 }
01789
01790 if (CheckOptionalArgument(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE)) {
01791 cmd->append(ippOnScanReportCommand::Z);
01792 }
01793
01794 if (CheckOptionalArgument(n,hasToolA,Tool,_A,TOOL_A_ARGUMENT_USED_TWICE)) {
01795 cmd->append(ippOnScanReportCommand::ToolA);
01796 }
01797
01798 if (CheckOptionalArgument(n,hasToolB,Tool,_B,TOOL_B_ARGUMENT_USED_TWICE)) {
01799 cmd->append(ippOnScanReportCommand::ToolB);
01800 }
01801
01802 if (CheckOptionalArgument(n,hasToolC,Tool,_C,TOOL_C_ARGUMENT_USED_TWICE)) {
01803 cmd->append(ippOnScanReportCommand::ToolC);
01804 }
01805
01806 if(CheckOptionalArgument(n,hasIJKAct,_IJKAct, IJKACT_ARGUMENT_USED_TWICE)) {
01807 cmd->append(ippOnScanReportCommand::IJKAct);
01808 }
01809
01810 if (old_n == n) {
01811
01812 _errorCode = BAD_ARGUMENTS;
01813 }
01814 }
01815 return (_errorCode != OK) ? NULL :cmd;
01816 }
01817
01818
01819
01820 bool ippCommandParser::CheckOptionalArgumentValue(
01821 int& n,
01822 bool& hasArgument,
01823 ippOtherKeyType type,
01824 ippParserCmdErrorId errorIfDuplicated,
01825 ippParserCmdErrorId errorIfNotFollowedByNumberInParens,
01826 double& value
01827 )
01828 {
01829 if (_errorCode != OK) return false;
01830 if (_argCount < n+2) return false;
01831
01832 if (_argTypes[n] != ARGKEYWORD ) {
01833 return false;
01834 }
01835
01836 if (_argKeywords[n] != type) {
01837 return false;
01838 } else {
01839 if (hasArgument ) {
01840 _errorCode = errorIfDuplicated;
01841 } else {
01842 hasArgument = true;
01843 if (_argTypes[n+1] != ARGPARENDOUBLE) {
01844 _errorCode = errorIfNotFollowedByNumberInParens;
01845 return false;
01846 }
01847 if ( n+2 < _argCount && _argTypes[n+2] != ARGCOMMA ) {
01848 _errorCode = BAD_ARGUMENTS;
01849 return false;
01850 }
01851 value = getValue(n+1);
01852 }
01853 n +=3;
01854 }
01855 if (_errorCode == OK ) {
01856 return true;
01857 }
01858 return false;
01859 }
01860
01861 bool ippCommandParser::CheckOptionalArgumentValue(
01862 int& n,
01863 bool& hasArgument,
01864 ippOtherKeyType type1,
01865 ippOtherKeyType type2,
01866 ippParserCmdErrorId errorIfDuplicated,
01867 ippParserCmdErrorId errorIfNotFollowedByNumberInParens,
01868 double& value
01869 )
01870 {
01871 if (_errorCode != OK) return false;
01872 if (_argCount < n+4) return false;
01873
01874 if (_argTypes[n] != ARGKEYWORD ) {
01875 return false;
01876 }
01877 if (_argTypes[n+1] != ARGDOT ) {
01878 return false;
01879 }
01880 if (_argTypes[n+2] != ARGKEYWORD ) {
01881 return false;
01882 }
01883
01884 if (_argKeywords[n] != type1 ||_argKeywords[n+2] != type2) {
01885 return false;
01886 } else {
01887 if (hasArgument ) {
01888 _errorCode = errorIfDuplicated;
01889 } else {
01890 hasArgument = true;
01891 if (_argTypes[n+3] != ARGPARENDOUBLE) {
01892 _errorCode = errorIfNotFollowedByNumberInParens;
01893 return false;
01894 }
01895 if ( n+4 < _argCount && _argTypes[n+4] != ARGCOMMA ) {
01896 _errorCode = BAD_ARGUMENTS;
01897 return false;
01898 }
01899 value = getValue(n+3);
01900 }
01901 n +=5;
01902 }
01903 if (_errorCode == OK ) {
01904 return true;
01905 }
01906 return false;
01907 }
01908 bool ippCommandParser::CheckOptionalArgumentValue(
01909 int& n,
01910 bool& hasArgument,
01911 ippOtherKeyType type,
01912 ippParserCmdErrorId errorIfDuplicated,
01913 ippParserCmdErrorId errorIfNotFollowedByBooleanInParens,
01914 bool& value
01915 )
01916 {
01917 if (_errorCode != OK) return false;
01918 if (_argCount < n+2) return false;
01919
01920 if (_argTypes[n] != ARGKEYWORD ) {
01921 return false;
01922 }
01923 if (_argKeywords[n] != type ) {
01924 return false;
01925 } else {
01926 if (hasArgument ) {
01927 _errorCode = errorIfDuplicated;
01928 } else {
01929 hasArgument = true;
01930 if (_argTypes[n+1] != ARGPARENDOUBLE) {
01931 _errorCode = errorIfNotFollowedByBooleanInParens;
01932 return false;
01933 }
01934 if ( n+2 < _argCount && _argTypes[n+2] != ARGCOMMA ) {
01935 _errorCode = BAD_ARGUMENTS;
01936 return false;
01937 }
01938 if (getValue(n+1) != 0 && getValue(n+1) !=1 ){
01939 _errorCode =errorIfNotFollowedByBooleanInParens;
01940 return false;
01941 }
01942 value = (getValue(n+1) == 1.0)?true:false ;
01943 }
01944 n +=3;
01945 }
01946 if (_errorCode == OK ) {
01947 return true;
01948 }
01949 return false;
01950 }
01951
01952 bool ippCommandParser::CheckOptionalArgumentValue(
01953 int& n,
01954 bool& hasArgument,
01955 ippOtherKeyType type,
01956 ippParserCmdErrorId errorIfDuplicated,
01957 ippParserCmdErrorId errorIfNotFollowedByNumberInParens,
01958 double& valueI,
01959 double& valueJ,
01960 double& valueK
01961 )
01962 {
01963 if (_errorCode != OK) return false;
01964 if (_argCount < n+3) {
01965 return false;
01966 }
01967
01968 if (_argTypes[n] != ARGKEYWORD ) {
01969 return false;
01970 }
01971
01972 if (_argKeywords[n] != type) {
01973 return false;
01974 } else {
01975 if (hasArgument ) {
01976 _errorCode = errorIfDuplicated;
01977 } else {
01978 hasArgument = true;
01979 if (_argTypes[n+1] != ARGIJK || _argTypes[n+2] != ARGIJK|| _argTypes[n+3] != ARGIJK) {
01980 _errorCode = errorIfNotFollowedByNumberInParens;
01981 return false;
01982 }
01983 if ( n+4 < _argCount && _argTypes[n+4] != ARGCOMMA ) {
01984 _errorCode = BAD_ARGUMENTS;
01985 return false;
01986 }
01987 valueI = getValue(n+1);
01988 valueJ = getValue(n+2);
01989 valueK = getValue(n+3);
01990 }
01991 n +=5;
01992 }
01993 if (_errorCode == OK ) {
01994 return true;
01995 }
01996 return false;
01997 }
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031 ippCommandPtr ippCommandParser::makePtMeas()
02032 {
02033 int n;
02034 bool hasX = false;
02035 bool hasY = false;
02036 bool hasZ = false;
02037 bool hasIJK = false;
02038 double x = 0.0;
02039 double y = 0.0;
02040 double z = 0.0;
02041 double i = 0.0;
02042 double j = 0.0;
02043 double k = 0.0;
02044
02045 n = 0;
02046 while (n < _argCount && _errorCode == OK) {
02047 int old_n=n;
02048 CheckOptionalArgumentValue(n,hasX,_X,X_ARGUMENT_USED_TWICE,X_NOT_FOLLOWED_BY_NUMBER_IN_PARENS,x);
02049 CheckOptionalArgumentValue(n,hasY,_Y,Y_ARGUMENT_USED_TWICE,Y_NOT_FOLLOWED_BY_NUMBER_IN_PARENS,y);
02050 CheckOptionalArgumentValue(n,hasZ,_Z,Z_ARGUMENT_USED_TWICE,Z_NOT_FOLLOWED_BY_NUMBER_IN_PARENS,z);
02051 CheckOptionalArgumentValue(n,hasIJK,_IJK,IJK_ARGUMENT_USED_TWICE,IJK_NOT_FOLLOWED_BY_ARGIJK,i,j,k);
02052 if (old_n == n) {
02053
02054 _errorCode = BAD_ARGUMENTS;
02055 }
02056 }
02057 if ((_errorCode == OK)&&(hasX == false) && (hasY == false) && (hasZ == false)) {
02058 _errorCode = X_Y_Z_ALL_MISSING;
02059 }
02060 return ((_errorCode != OK) ? NULL:
02061 (new ippPtMeasCommand(_tag, hasX, hasY, hasZ, hasIJK, x, y, z,i,j,k)));
02062 }
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082 ippCommandPtr ippCommandParser::makeReQualify()
02083 {
02084 if (_argCount != 0)
02085 _errorCode = MUST_HAVE_NO_ARGUMENTS;
02086 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, ReQualify)));
02087 }
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115 ippCommandPtr ippCommandParser::makeScanInCylEndIsPlane()
02116 {
02117 int n;
02118
02119 if (_argCount != 51) {
02120 _errorCode = BAD_ARGUMENTS;
02121 return 0;
02122 }
02123
02124
02125 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#")) {
02126 _errorCode = BAD_ARGUMENTS;
02127 return 0;
02128 }
02129
02130 if (getValue(30) <= 0) {
02131 _errorCode = STEPW_MUST_BE_POSITIVE;
02132 return 0;
02133 }
02134 if (getValue(44) <= 0) {
02135 _errorCode = NUMBER_THROUGH_MUST_BE_POSITIVE;
02136 return 0;
02137 }
02138
02139 if (!IsInteger(getValue(44))) {
02140 _errorCode = NUMBER_THROUGH_MUST_BE_INTEGER;
02141 return 0;
02142 }
02143
02144 for (n = 0; ((n < 25) && (_errorCode == OK)); n++) {
02145 if ((_argTypes[2*n] != ARGDOUBLE) || (_argTypes[(2*n)+1] != ARGCOMMA)) {
02146 _errorCode = BAD_ARGUMENTS;
02147 return 0;
02148 }
02149 }
02150 return ((_errorCode != OK) ? NULL:
02151 (new ippScanInCylEndIsPlaneCommand
02152 (_tag,
02153 getValue(0), getValue(2), getValue(4), getValue(6),
02154 getValue(8), getValue(10), getValue(12), getValue(14),
02155 getValue(16), getValue(18), getValue(20), getValue(22),
02156 getValue(24), getValue(26), getValue(28), getValue(30),
02157 getValue(32), getValue(34), getValue(36), getValue(38),
02158 getValue(40), getValue(42), AsInteger(getValue(44)),
02159 getValue(46), getValue(48), getValue(50))));
02160 }
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187 ippCommandPtr ippCommandParser::makeScanInCylEndIsSphere()
02188 {
02189 if (_argCount != 47) {
02190 _errorCode = BAD_ARGUMENTS;
02191 }
02192
02193
02194 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#")) {
02195 _errorCode = BAD_ARGUMENTS;
02196 return 0;
02197 }
02198
02199 if (getValue(30) <= 0) {
02200 _errorCode = STEPW_MUST_BE_POSITIVE;
02201 return 0;
02202 }
02203 if (getValue(38) <= 0) {
02204 _errorCode = DIAMETER_MUST_BE_POSITIVE;
02205 return 0;
02206 }
02207 if (getValue(40) <= 0)
02208 _errorCode = NUMBER_THROUGH_MUST_BE_POSITIVE;
02209 else if ( !IsInteger(getValue(40)))
02210 _errorCode = NUMBER_THROUGH_MUST_BE_INTEGER;
02211
02212 return ((_errorCode != OK) ? NULL:
02213 (new ippScanInCylEndIsSphereCommand
02214 (_tag,
02215 getValue(0), getValue(2), getValue(4),
02216 getValue(6), getValue(8), getValue(10),
02217 getValue(12), getValue(14), getValue(16),
02218 getValue(18), getValue(20), getValue(22),
02219 getValue(24), getValue(26), getValue(28),
02220 getValue(30),
02221 getValue(32), getValue(34), getValue(36),
02222 getValue(38),
02223 int(getValue(40)),
02224 getValue(42), getValue(44), getValue(46))));
02225 }
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255 ippCommandPtr ippCommandParser::makeScanInPlaneEndIsCyl()
02256 {
02257
02258 if (_argCount != 47) {
02259 _errorCode = BAD_ARGUMENTS;
02260 return 0;
02261 }
02262
02263
02264 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#")) {
02265 _errorCode = BAD_ARGUMENTS;
02266 return 0;
02267 }
02268
02269 if (getValue(24) <= 0)
02270 _errorCode = STEPW_MUST_BE_POSITIVE;
02271 else if (getValue(38) <= 0)
02272 _errorCode = DIAMETER_MUST_BE_POSITIVE;
02273 else if (getValue(40) <= 0)
02274 _errorCode = NUMBER_THROUGH_MUST_BE_POSITIVE;
02275 else if ( !IsInteger(getValue(40)))
02276 _errorCode = NUMBER_THROUGH_MUST_BE_INTEGER;
02277
02278
02279 return ((_errorCode != OK) ? NULL:
02280 (new ippScanInPlaneEndIsCylCommand
02281 (_tag,
02282 getValue(0), getValue(2), getValue(4),
02283 getValue(6), getValue(8), getValue(10),
02284 getValue(12), getValue(14), getValue(16),
02285 getValue(18), getValue(20), getValue(22),
02286 getValue(24),
02287 getValue(26), getValue(28), getValue(30),
02288 getValue(32), getValue(34), getValue(36),
02289 getValue(38),
02290 int(getValue(40)),
02291 getValue(42), getValue(44), getValue(46)
02292 )));
02293 }
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321 ippCommandPtr ippCommandParser::makeScanInPlaneEndIsPlane()
02322 {
02323 if (_argCount != 45) {
02324 _errorCode = BAD_ARGUMENTS;
02325 return 0;
02326 }
02327
02328
02329 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#")) {
02330 _errorCode = BAD_ARGUMENTS;
02331 return 0;
02332 }
02333
02334 if (getValue(24) <= 0)
02335 _errorCode = STEPW_MUST_BE_POSITIVE;
02336 else if (getValue(38) <= 0)
02337 _errorCode = NUMBER_THROUGH_MUST_BE_POSITIVE;
02338 else if (!IsInteger(getValue(38)) != 0)
02339 _errorCode = NUMBER_THROUGH_MUST_BE_INTEGER;
02340
02341 return ((_errorCode != OK) ? NULL:
02342 (new ippScanInPlaneEndIsPlaneCommand
02343 (_tag,
02344 getValue(0), getValue(2), getValue(4),
02345 getValue(6), getValue(8), getValue(10),
02346 getValue(12), getValue(14), getValue(16),
02347 getValue(18), getValue(20), getValue(22),
02348 getValue(24),
02349 getValue(26), getValue(28), getValue(30),
02350 getValue(32), getValue(34), getValue(36),
02351 int(getValue(38)),
02352 getValue(40), getValue(42), getValue(44)
02353 )));
02354 }
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381 ippCommandPtr ippCommandParser::makeScanInPlaneEndIsSphere()
02382 {
02383
02384 if (_argCount != 41) {
02385 _errorCode = BAD_ARGUMENTS;
02386 }
02387
02388
02389 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#")) {
02390 _errorCode = BAD_ARGUMENTS;
02391 return 0;
02392 }
02393
02394 if (getValue(24) <= 0)
02395 _errorCode = STEPW_MUST_BE_POSITIVE;
02396 else if (getValue(32) <= 0)
02397 _errorCode = DIAMETER_MUST_BE_POSITIVE;
02398 else if (!IsInteger(getValue(34)) != 0)
02399 _errorCode = NUMBER_THROUGH_MUST_BE_INTEGER;
02400
02401 return ((_errorCode != OK) ? NULL:
02402 (new ippScanInPlaneEndIsSphereCommand
02403 (_tag,
02404 getValue(0), getValue(2), getValue(4),
02405 getValue(6), getValue(8), getValue(10),
02406 getValue(12), getValue(14), getValue(16),
02407 getValue(18), getValue(20), getValue(22),
02408 getValue(24),
02409 getValue(26), getValue(28), getValue(30),
02410 getValue(32),
02411 int(getValue(34)),
02412 getValue(36),getValue(38),getValue(40)
02413 )));
02414 }
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440 ippCommandPtr ippCommandParser::makeScanOnCircle()
02441 {
02442
02443 if (_argCount != 23) {
02444 _errorCode = BAD_ARGUMENTS;
02445 }
02446
02447
02448 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#")) {
02449 _errorCode = BAD_ARGUMENTS;
02450 return 0;
02451 }
02452
02453 return ((_errorCode != OK) ? NULL:
02454 (new ippScanOnCircleCommand
02455 (_tag,
02456 getValue(0), getValue(2), getValue(4), getValue(6),
02457 getValue(8), getValue(10), getValue(12), getValue(14),
02458 getValue(16), getValue(18), getValue(20), getValue(22))));
02459 }
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482 ippCommandPtr ippCommandParser::makeScanOnCircleHint()
02483 {
02484
02485 if ((_argCount != 3) || !match(_argTypes,"#,#")) {
02486 _errorCode = BAD_ARGUMENTS;
02487 return 0;
02488 }
02489
02490 if (getValue(0) < 0 || getValue(2) < 0) {
02491 _errorCode = BAD_ARGUMENTS;
02492 return 0;
02493 }
02494
02495 return ((_errorCode != OK) ? NULL:
02496 (new ippScanOnCircleHintCommand(_tag, getValue(0), getValue(2))));
02497 }
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521 ippCommandPtr ippCommandParser::makeScanOnLine()
02522 {
02523
02524 if (_argCount != 19) {
02525 _errorCode = BAD_ARGUMENTS;
02526 return 0;
02527 }
02528
02529
02530
02531 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#")) {
02532 _errorCode = BAD_ARGUMENTS;
02533 return 0;
02534 }
02535
02536 if (getValue(18) <= 0) {
02537 _errorCode = STEPW_MUST_BE_POSITIVE;
02538 }
02539
02540 return ((_errorCode != OK) ? NULL:
02541 (new ippScanOnLineCommand
02542 (_tag,
02543 getValue(0), getValue(2), getValue(4), getValue(6),
02544 getValue(8), getValue(10), getValue(12), getValue(14),
02545 getValue(16), getValue(18))));
02546 }
02547
02548
02549
02550
02551
02552
02553
02554
02555
02556
02557
02558
02559
02560
02561
02562
02563
02564
02565
02566 ippCommandPtr ippCommandParser::makeScanOnLineHint()
02567 {
02568 if ((_argCount != 3) || !match(_argTypes,"#,#")) {
02569 _errorCode = BAD_ARGUMENTS;
02570 return 0;
02571 }
02572
02573 if (getValue(0) < 0 || getValue(2) < 0) {
02574 _errorCode = BAD_ARGUMENTS;
02575 return 0;
02576 }
02577 return ((_errorCode != OK) ? NULL:
02578 (new ippScanOnLineHintCommand(_tag, getValue(0), getValue(2))));
02579 }
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602 ippCommandPtr ippCommandParser::makeScanUnknownHint()
02603 {
02604 if (_argCount != 1)
02605 _errorCode = MUST_HAVE_ONE_ARGUMENT;
02606 else if (_argTypes[0] != ARGDOUBLE)
02607 _errorCode = ARGUMENT_MUST_BE_A_NUMBER;
02608 else if (getValue(0) <= 0)
02609 _errorCode = ARGUMENT_MUST_BE_POSITIVE;
02610 return ((_errorCode != OK) ? NULL:
02611 (new ippScanUnknownHintCommand(_tag, getValue(0))));
02612 }
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638 ippCommandPtr ippCommandParser::makeSetCoordSystem()
02639 {
02640 if (_argCount != 1)
02641 _errorCode = MUST_HAVE_ONE_ARGUMENT;
02642 else if ((_argTypes[0] != ARGKEYWORD) ||
02643 ((_argKeywords[0] != MachineCsy) &&
02644 (_argKeywords[0] != MultipleArmCsy) &&
02645 (_argKeywords[0] != PartCsy) &&
02646 (_argKeywords[0] != MoveableMachineCsy)))
02647 _errorCode = BAD_ARGUMENTS;
02648 return ((_errorCode != OK) ? NULL :
02649 (new ippSetCoordSystemCommand(_tag, (ippCoordSysType)_argKeywords[0])));
02650 }
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675
02676
02677
02678 ippCommandPtr ippCommandParser::makeSetCsyTransformation()
02679 {
02680 if (_argCount != 13) {
02681 _errorCode = MUST_HAVE_7_ARGUMENTS;
02682 return 0;
02683 }
02684
02685 if (!match(_argTypes,"k,#,#,#,#,#,#")) {
02686 _errorCode = BAD_ARGUMENTS;
02687 return 0;
02688 }
02689
02690 ippCoordSysType type = (ippCoordSysType)_argKeywords[0];
02691 if (( type!= JogDisplayCsy) &&
02692 (type != JogMoveCsy) &&
02693 (type != MoveableMachineCsy) &&
02694 (type != MultipleArmCsy) &&
02695 (type != PartCsy) &&
02696 (type != SensorCsy)) {
02697 _errorCode = BAD_FIRST_ARGUMENT;
02698 }
02699
02700 if ((getValue(8) < 0) || (getValue(8) > 180)) {
02701 _errorCode = THETA_OUT_OF_RANGE;
02702 }
02703
02704 return ((_errorCode != OK) ? NULL :
02705 (new ippSetCsyTransformationCommand(_tag, type,
02706 getValue(2), getValue(4),
02707 getValue(6), getValue(8),
02708 getValue(10), getValue(12))));
02709 }
02710
02711
02712
02713
02714
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758 ippCommandPtr ippCommandParser::makeSetProp()
02759 {
02760 ippSetPropCommandPtr command = new ippSetPropCommand(_tag);
02761 for (int n = 0; ((n < _argCount) && (_errorCode == OK));n++) {
02762
02763 ippOtherKeyType key1 = ippOtherKeyType_INVALID;
02764 ippOtherKeyType key2 = EmptyKey;
02765 ippOtherKeyType key3 = EmptyKey;
02766 ippOtherKeyType key4 = EmptyKey;
02767 double value = 0;
02768 if (match(_argTypes,"k.k.k.kD",n)) {
02769 key1 = _argKeywords[n];
02770 key2 = _argKeywords[n+2];
02771 key3 = _argKeywords[n+4];
02772 key4 = _argKeywords[n+6];
02773 value = getValue(n+7);
02774 n += 8;
02775
02776 } else if (match(_argTypes,"k.k.kD",n)) {
02777 key1 = _argKeywords[n];
02778 key2 = _argKeywords[n+2];
02779 key3 = _argKeywords[n+4];
02780 value = getValue(n+5);
02781 n += 6;
02782 } else if (match(_argTypes,"k.kD",n)) {
02783 key1 = _argKeywords[n];
02784 key2 = _argKeywords[n+2];
02785 value = getValue(n+3);
02786 n += 4;
02787 } else if (match(_argTypes,"kD",n)) {
02788 key1 = _argKeywords[n];
02789 value = getValue(n+1);
02790 n += 2;
02791 } else {
02792 _errorCode = BAD_ARGUMENTS;
02793 }
02794 if (n < _argCount && _argTypes[n] != ARGCOMMA) {
02795 _errorCode = BAD_ARGUMENTS;
02796 }
02797 if(_errorCode == OK ) {
02798 ippProp prop(key1,key2,key3,key4);
02799 if (PropertyIsAllowedAndWritable(prop)) {
02800 command->addPropValue(prop,value);
02801 } else {
02802 _errorCode = BAD_ARGUMENTS;
02803 }
02804 }
02805 }
02806 if (_errorCode != OK) {
02807 return 0;
02808 }
02809 return command;
02810
02811 }
02812
02813
02814
02815
02816
02817
02818
02819
02820
02821
02822
02823
02824
02825
02826
02827
02828
02829
02830
02831
02832
02833 ippCommandPtr ippCommandParser::makeSetTool()
02834 {
02835 if (_argCount != 1)
02836 _errorCode = MUST_HAVE_ONE_ARGUMENT;
02837 else if (_argTypes[0] != ARGSTRING)
02838 _errorCode = ARGUMENT_MUST_BE_STRING;
02839 return((_errorCode != OK) ? NULL: (new ippSetToolCommand(_tag, _argStrings[0].c_str())));
02840 }
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853 ippCommandPtr ippCommandParser::makeStartSession()
02854 {
02855 if (_argCount != 0) {
02856 _errorCode = MUST_HAVE_NO_ARGUMENTS;
02857 }
02858 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, StartSession)));
02859 }
02860
02861
02862
02863
02864
02865
02866
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878 ippCommandPtr ippCommandParser::makeStopAllDaemons()
02879 {
02880 if (_argCount != 0)
02881 _errorCode = MUST_HAVE_NO_ARGUMENTS;
02882 return ((_errorCode != OK) ? NULL : (new ippCommand(_tag, StopAllDaemons)));
02883 }
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903 ippCommandPtr ippCommandParser::makeStopDaemon()
02904 {
02905 if (_argCount != 1)
02906 _errorCode = MUST_HAVE_ONE_ARGUMENT;
02907 else if (_argTypes[0] != ARGETAG)
02908 _errorCode = ARGUMENT_MUST_BE_EVENT_TAG;
02909 return((_errorCode != OK) ? NULL: (new ippStopDaemonCommand(_tag, _argInt)));
02910 }
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930
02931
02932
02933 ippCommandPtr ippCommandParser::makeTiltCenterPart()
02934 {
02935 if (_argCount != 13) {
02936 _errorCode = MUST_HAVE_7_ARGUMENTS;
02937 }
02938
02939 if (!match(_argTypes,"#,#,#,#,#,#,#")) {
02940 _errorCode = BAD_ARGUMENTS;
02941 }
02942
02943 return ((_errorCode != OK) ? NULL:
02944 new ippTiltCenterPartCommand(_tag, getValue(0), getValue(2),
02945 getValue(4), getValue(6),
02946 getValue(8), getValue(10),
02947 getValue(12)));
02948 }
02949
02950
02951
02952
02953
02954
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969
02970 ippCommandPtr ippCommandParser::makeTiltPart()
02971 {
02972 if (_argCount != 7) {
02973 _errorCode = MUST_HAVE_4_ARGUMENTS;
02974 } else if (!match(_argTypes,"#,#,#,#")) {
02975 _errorCode = BAD_ARGUMENTS;
02976 }
02977
02978 return ((_errorCode != OK) ? NULL:
02979 new ippTiltPartCommand(_tag, getValue(0), getValue(2),
02980 getValue(4), getValue(6)));
02981 }
02982
02983
02984
02985 ippCommandPtr ippCommandParser::makeEnumToolCollection()
02986 {
02987 if (_argCount != 1)
02988 _errorCode = MUST_HAVE_ONE_ARGUMENT;
02989 else if (_argTypes[0] != ARGSTRING)
02990 _errorCode = ARGUMENT_MUST_BE_STRING;
02991 return ((_errorCode != OK) ? NULL :
02992 (new ippEnumToolCollectionCommand(_tag, _argStrings[0].c_str())));
02993 }
02994
02995 ippCommandPtr ippCommandParser::makeEnumAllToolCollections()
02996 {
02997 if (_argCount != 1)
02998 _errorCode = MUST_HAVE_ONE_ARGUMENT;
02999 else if (_argTypes[0] != ARGSTRING)
03000 _errorCode = ARGUMENT_MUST_BE_STRING;
03001 return ((_errorCode != OK) ? NULL :
03002 (new ippEnumAllToolCollectionsCommand(_tag, _argStrings[0].c_str())));
03003 }
03004
03005 ippCommandPtr ippCommandParser::makeOpenToolCollection()
03006 {
03007 if (_argCount != 1)
03008 _errorCode = MUST_HAVE_ONE_ARGUMENT;
03009 else if (_argTypes[0] != ARGSTRING)
03010 _errorCode = ARGUMENT_MUST_BE_STRING;
03011 return ((_errorCode != OK) ? NULL :
03012 (new ippOpenToolCollectionCommand(_tag, _argStrings[0].c_str())));
03013 }
03014
03015
03016 ippCommandPtr ippCommandParser::makeSaveActiveCoordSystem()
03017 {
03018 if (_argCount != 1)
03019 _errorCode = MUST_HAVE_ONE_ARGUMENT;
03020 else if (_argTypes[0] != ARGSTRING)
03021 _errorCode = ARGUMENT_MUST_BE_STRING;
03022 return ((_errorCode != OK) ? NULL :
03023 (new ippSaveActiveCoordSystemCommand(_tag, _argStrings[0].c_str())));
03024 }
03025
03026 ippCommandPtr ippCommandParser::makeLoadCoordSystem()
03027 {
03028 if (_argCount != 1)
03029 _errorCode = MUST_HAVE_ONE_ARGUMENT;
03030 else if (_argTypes[0] != ARGSTRING)
03031 _errorCode = ARGUMENT_MUST_BE_STRING;
03032 return ((_errorCode != OK) ? NULL :
03033 (new ippLoadCoordSystemCommand(_tag, _argStrings[0].c_str())));
03034 }
03035
03036 ippCommandPtr ippCommandParser::makeDeleteCoordSystem()
03037 {
03038 if (_argCount != 1)
03039 _errorCode = MUST_HAVE_ONE_ARGUMENT;
03040 else if (_argTypes[0] != ARGSTRING)
03041 _errorCode = ARGUMENT_MUST_BE_STRING;
03042 return ((_errorCode != OK) ? NULL :
03043 (new ippDeleteCoordSystemCommand(_tag, _argStrings[0].c_str())));
03044 }
03045
03046 ippCommandPtr ippCommandParser::makeEnumCoordSystems()
03047 {
03048 if (_argCount != 0)
03049 _errorCode = MUST_HAVE_NO_ARGUMENTS;
03050 return ((_errorCode != OK) ? NULL :
03051 (new ippEnumCoordSystemsCommand(_tag)));
03052 }
03053
03054 ippCommandPtr ippCommandParser::makeGetNamedCsyTransformation()
03055 {
03056 if (_argCount != 1)
03057 _errorCode = MUST_HAVE_ONE_ARGUMENT;
03058 else if (_argTypes[0] != ARGSTRING)
03059 _errorCode = ARGUMENT_MUST_BE_STRING;
03060 return ((_errorCode != OK) ? NULL :
03061 (new ippGetNamedCsyTransformationCommand(_tag, _argStrings[0].c_str())));
03062 return 0;
03063 }
03064
03065 ippCommandPtr ippCommandParser::makeSaveNamedCsyTransformation()
03066 {
03067 double x0=0;
03068 double y0=0;
03069 double z0=0;
03070 double theta=0;
03071 double phi=0;
03072 double psi=0;
03073
03074 if (_argCount != 13) {
03075 _errorCode = MUST_HAVE_7_ARGUMENTS;
03076 return 0;
03077 }
03078 if (!match(_argTypes,"s,#,#,#,#,#,#")) {
03079 _errorCode = BAD_ARGUMENTS;
03080 return 0;
03081 }
03082 x0 = getValue(2);
03083 y0 = getValue(4);
03084 z0 = getValue(6);
03085 theta = getValue(8);
03086 phi = getValue(10);
03087 psi = getValue(12);
03088 return ((_errorCode != OK) ? NULL :
03089 (new ippSaveNamedCsyTransformationCommand(_tag,
03090 _argStrings[0].c_str(),x0,y0,z0,theta,phi,psi)));
03091 return 0;
03092 }
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109 ippCommandPtr ippCommandParser::makeScanOnCurveHint()
03110 {
03111 if (!match(_argTypes,"#,#")) {
03112 _errorCode = BAD_ARGUMENTS;
03113 return 0;
03114 }
03115 double density = getValue(0);
03116 double minRadiusOfCurvature = getValue(2);
03117 if ( density <=0 ) {
03118 _errorCode = DENSITY_MUST_BE_POSITIVE;
03119 }
03120 if (minRadiusOfCurvature<=0){
03121 _errorCode = MINIMUM_RADIUS_OF_CURVATURE_MUST_BE_POSITIVE;
03122 }
03123 return ((_errorCode != OK) ? NULL :
03124 (new ippScanOnCurveHintCommand(_tag,density,minRadiusOfCurvature)));
03125 }
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136 ippCommandPtr ippCommandParser::makeScanOnCurveDensity()
03137 {
03138 bool hasDis = false;
03139 bool hasAngle = false;
03140 bool hasAtNominals = false;
03141 double dis =0.1;
03142 double angle = 0.0;
03143 bool atNominals = false;
03144 int n = 0;
03145 while (n < _argCount && _errorCode == OK) {
03146 int old_n=n;
03147 CheckOptionalArgumentValue(n,hasDis,Dis,DIS_ARGUMENT_USED_TWICE,DIS_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS,dis);
03148 CheckOptionalArgumentValue(n,hasAngle,Angle,ANGLE_ARGUMENT_USED_TWICE,ANGLE_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS,angle);
03149 CheckOptionalArgumentValue(n,hasAtNominals,AtNominals,ATNOMINALS_ARGUMENT_USED_TWICE,Z_NOT_FOLLOWED_BY_NUMBER_IN_PARENS,atNominals);
03150 if (old_n == n) {
03151
03152 _errorCode = BAD_ARGUMENTS;
03153 }
03154 }
03155 if ((_errorCode == OK)&&(hasDis == false) && (hasAngle == false) && (hasAtNominals == false)) {
03156 _errorCode = BAD_ARGUMENTS;
03157 }
03158 return ((_errorCode != OK) ? NULL:
03159 (new ippScanOnCurveDensityCommand(_tag, dis, hasAngle, angle,atNominals)));
03160 }
03161 ippCommandPtr ippCommandParser::makeScanUnknownDensity()
03162 {
03163 bool hasDis = false;
03164 bool hasAngle = false;
03165 bool hasAtNominals = false;
03166 double dis =0.1;
03167 double angle = 0.0;
03168 int n = 0;
03169 while (n < _argCount && _errorCode == OK) {
03170 int old_n=n;
03171 CheckOptionalArgumentValue(n,hasDis,Dis,DIS_ARGUMENT_USED_TWICE,DIS_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS,dis);
03172 CheckOptionalArgumentValue(n,hasAngle,Angle,ANGLE_ARGUMENT_USED_TWICE,ANGLE_MUST_BE_FOLLOWED_BY_NUMBER_IN_PARENS,angle);
03173 if (old_n == n) {
03174
03175 _errorCode = BAD_ARGUMENTS;
03176 }
03177 }
03178 if ((_errorCode == OK)&&(hasDis == false) && (hasAngle == false) && (hasAtNominals == false)) {
03179 _errorCode = BAD_ARGUMENTS;
03180 }
03181 return ((_errorCode != OK) ? NULL:
03182 (new ippScanUnknownDensityCommand(_tag, dis, hasAngle, angle)));
03183 }
03184
03185
03186 ippCommandPtr ippCommandParser::makeScanOnCurve()
03187 {
03188
03189 int n1 = _argDoubles.size();
03190 int n2 = _argTypes.size();
03191 int n3 = _argKeywords.size();
03192 int n4 = _argStrings.size();
03193
03194 IPP_ASSERT(_argDoubles.size() >=_argCount);
03195 IPP_ASSERT(_argTypes.size() >=_argCount);
03196 IPP_ASSERT(_argKeywords.size() >=_argCount);
03197
03198
03199
03200
03201
03202
03203 bool bClose = false;
03204
03205 if (!match(_argTypes,"kD,kD,k")) {
03206 _errorCode = BAD_ARGUMENTS;
03207 return 0;
03208 }
03209 if ( _argKeywords[0] != Closed ) {
03210 _errorCode = BAD_ARGUMENTS;
03211 return 0;
03212 }
03213 if (!IsBoolean(getValue(1))) {
03214 _errorCode = BAD_ARGUMENTS;
03215 return 0;
03216 }
03217 bClose = AsBoolean(getValue(1));
03218 if ( _argKeywords[3] != Format ) {
03219 _errorCode = BAD_ARGUMENTS;
03220 return 0;
03221 }
03222 if ( _argKeywords[6] != Data ) {
03223 _errorCode = BAD_ARGUMENTS;
03224 return 0;
03225 }
03226 ippScanOnCurveCommand::FormatType type = ippScanOnCurveCommand::FormatType((int)getValue(4));
03227 int nb_per_point = 0;
03228 switch(type) {
03229 case ippScanOnCurveCommand::Type1: nb_per_point = 7; break;
03230 case ippScanOnCurveCommand::Type2: nb_per_point = 10; break;
03231 case ippScanOnCurveCommand::Type3: nb_per_point = 13; break;
03232 default: IPP_ASSERT(0);
03233 }
03234 int n=7;
03235 int count = 0;
03236 ippScanOnCurveCommandPtr command = new ippScanOnCurveCommand(_tag,bClose,type);
03237 while (_argTypes[n] == ARGIJK && n<_argCount) {
03238 count++; n++;
03239 }
03240 if ( ( count % nb_per_point ) != 0 ) {
03241
03242 _errorCode = BAD_NUMBER_OF_ARGUMENT_FOR_DATA_IN_SCANONCURVE;
03243 return 0;
03244 }
03245
03246 n = count/nb_per_point;
03247 int k=7;
03248 for (int i=0;i<n;i++) {
03249 if (!IsInteger(getValue(k+6))) {
03250 _errorCode = ARGUMENT_MUST_BE_INTEGER;
03251 }
03252 switch(type) {
03253 case ippScanOnCurveCommand::Type1:
03254 command->addPoint(getValue(k),getValue(k+1),getValue(k+2),
03255 getValue(k+3),getValue(k+4),getValue(k+5),AsInteger(getValue(k+6))
03256 );
03257 break;
03258 case ippScanOnCurveCommand::Type2:
03259 command->addPoint(getValue(k),getValue(k+1),getValue(k+2),
03260 getValue(k+3),getValue(k+4),getValue(k+5),AsInteger(getValue(k+6)),
03261 getValue(k+7),getValue(k+8),getValue(k+9)
03262 );
03263 break;
03264 case ippScanOnCurveCommand::Type3:
03265 command->addPoint(getValue(k),getValue(k+1),getValue(k+2),
03266 getValue(k+3),getValue(k+4),getValue(k+5),AsInteger(getValue(k+6)),
03267 getValue(k+7),getValue(k+8),getValue(k+9),
03268 getValue(k+10),getValue(k+11),getValue(k+12)
03269 );
03270 break;
03271 }
03272 k+=nb_per_point;
03273 }
03274
03275 return (_errorCode == OK) ? command : NULL;
03276 }
03277
03278 ippCommandPtr ippCommandParser::makeScanOnHelix()
03279 {
03280 if (_argCount != 25) {
03281 _errorCode = BAD_ARGUMENTS;
03282 return 0;
03283 }
03284
03285
03286
03287 if (!match(_argTypes,"#,#,#,#,#,#,#,#,#,#,#,#,#")) {
03288 _errorCode = BAD_ARGUMENTS;
03289 return 0;
03290 }
03291
03292 if (getValue(22) <= 0) {
03293 _errorCode = STEPW_MUST_BE_POSITIVE;
03294 }
03295
03296 return ((_errorCode != OK) ? NULL:
03297 (new ippScanOnHelixCommand
03298 (_tag,
03299 getValue(0), getValue(2), getValue(4), getValue(6),
03300 getValue(8), getValue(10), getValue(12), getValue(14),
03301 getValue(16), getValue(18), getValue(20), getValue(22),
03302 getValue(24) )));
03303 }
03304
03305 ippCommandPtr ippCommandParser::makePtMeasSelfCenter()
03306 {
03307 bool hasX = false;
03308 bool hasY = false;
03309 bool hasZ = false;
03310 bool hasIJK = false;
03311 double x = 0;
03312 double y = 0;
03313 double z = 0;
03314 double i = 0;
03315 double j = 0;
03316 double k = 0;
03317
03318 int n=0;
03319 while (n < _argCount && _errorCode == OK) {
03320 int old_n=n;
03321 CheckOptionalArgumentValue(n,hasX ,_X , X_ARGUMENT_USED_TWICE, X_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, x);
03322 CheckOptionalArgumentValue(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE, Y_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, y);
03323 CheckOptionalArgumentValue(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE, Z_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, z);
03324 CheckOptionalArgumentValue(n,hasIJK ,_IJK , IJK_ARGUMENT_USED_TWICE,IJK_NOT_FOLLOWED_BY_ARGIJK, i,j,k);
03325 if (old_n == n) {
03326
03327 _errorCode = BAD_ARGUMENTS;
03328 }
03329 }
03330 if (!hasX || !hasY || !hasZ || !hasIJK ) {
03331
03332 _errorCode = BAD_ARGUMENTS;
03333 }
03334 return (_errorCode != OK) ? NULL:
03335 new ippPtMeasSelfCenterCommand(_tag, x, y, z, ippTargetVector(i,j,k) );
03336 }
03337
03338 ippCommandPtr ippCommandParser::makePtMeasSelfCenterLocked()
03339 {
03340 bool hasX = false;
03341 bool hasY = false;
03342 bool hasZ = false;
03343 bool hasIJK = false;
03344 bool hasLMN = false;
03345 double x = 0;
03346 double y = 0;
03347 double z = 0;
03348 double i1 = 0;
03349 double j1 = 0;
03350 double k1 = 0;
03351 double i2 = 0;
03352 double j2 = 0;
03353 double k2 = 0;
03354
03355 int n=0;
03356 while (n < _argCount && _errorCode == OK) {
03357 int old_n=n;
03358 CheckOptionalArgumentValue(n,hasX ,_X , X_ARGUMENT_USED_TWICE, X_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, x);
03359 CheckOptionalArgumentValue(n,hasY ,_Y , Y_ARGUMENT_USED_TWICE, Y_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, y);
03360 CheckOptionalArgumentValue(n,hasZ ,_Z , Z_ARGUMENT_USED_TWICE, Z_NOT_FOLLOWED_BY_NUMBER_IN_PARENS, z);
03361 CheckOptionalArgumentValue(n,hasIJK ,_IJK , IJK_ARGUMENT_USED_TWICE, IJK_NOT_FOLLOWED_BY_ARGIJK, i1,j1,k1);
03362 CheckOptionalArgumentValue(n,hasLMN ,_LMN , LMN_ARGUMENT_USED_TWICE, IJK_NOT_FOLLOWED_BY_ARGIJK, i2,j2,k2);
03363 if (old_n == n) {
03364
03365 _errorCode = BAD_ARGUMENTS;
03366 }
03367 }
03368 if (!hasX || !hasY || !hasZ || !hasIJK ||!hasLMN ) {
03369
03370 _errorCode = BAD_ARGUMENTS;
03371 }
03372 return (_errorCode != OK) ? NULL:
03373 new ippPtMeasSelfCenterLockedCommand(_tag, x, y, z, ippTargetVector(i1,j1,k1) ,ippTargetVector(i2,j2,k2));}
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393 ippCommandPtr ippCommandParser::makeCommand()
03394 {
03395 switch(_commandName)
03396 {
03397
03398
03399
03400
03401 #define ENUM(value,function) case ipp::value: return IPP_CONCAT(make,value)();
03402 COMMAND_ENUMERATION
03403 #undef ENUM
03404
03405 default:
03406 return makeAbortE();
03407 }
03408 }
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424
03425
03426
03427
03428
03429
03430
03431
03432
03433
03434
03435
03436
03437 ippCommandPtr ippCommandParser::parseCommand()
03438
03439 {
03440 ippCommandPtr aCommand = 0;
03441
03442 _commandName =ippCommandNameType_INVALID;
03443
03444 parseTag();
03445
03446 if (_errorCode == OK) {
03447 unSpaceInputArray();
03448 }
03449
03450 if (_errorCode == OK) {
03451 parseCmdName();
03452 }
03453 if (_errorCode == OK) {
03454 parseCmdArguments();
03455 }
03456
03457 if ((_errorCode == OK) &&
03458 ((_inputArray[_arrayIndex] != 13) ||
03459 (_inputArray[_arrayIndex + 1] != 10) ||
03460 (_inputArray[_arrayIndex + 2] != 0)))
03461 {
03462 _errorCode = BAD_CHARACTER_AFTER_COMMAND_END;
03463 }
03464
03465 if (_errorCode == OK) {
03466 if ( (_commandName == AbortE) ||
03467 (_commandName == GetErrStatusE) ||
03468 (_commandName == GetPropE) ||
03469 (_commandName == OnMoveReportE)
03470 ) {
03471 if (!_isEvent) {
03472 _errorCode = EVENT_COMMAND_MUST_HAVE_EVENT_TAG;
03473 }
03474 } else {
03475 if (_isEvent) {
03476 _errorCode = NON_EVENT_COMMAND_MUST_NOT_HAVE_EVENT_TAG;
03477 }
03478 }
03479 }
03480 if (_errorCode == OK) {
03481 aCommand = makeCommand();
03482 }
03483
03484
03485 if (_errorCode != OK ) {
03486 if (aCommand) {
03487 aCommand = 0;
03488 }
03489 }
03490 return ((_errorCode != OK) ? NULL : aCommand);
03491 }
03492
03493
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535 void ippCommandParser::parseCmdArguments()
03536 {
03537 char c;
03538 char d;
03539
03540
03541
03542 for (_argCount = 0; ((c = _inputArray[_arrayIndex]) != ')' ); _argCount++) {
03543
03544 if (_argCount +3 >= _argSize) {
03545 makeArraysBigger();
03546 }
03547
03548 d = _inputArray[_arrayIndex + 1];
03549
03550 if (c == ',') {
03551
03552 _argTypes[_argCount] = ARGCOMMA;
03553
03554 } else if ((c == '.') && ( d >= 'A') && (d <= 'Z' )) {
03555
03556 _argTypes[_argCount] = ARGDOT;
03557
03558 } else if ((c == '(') && (d == ')')) {
03559
03560 _arrayIndex++;
03561 _argTypes[_argCount] = ARGPARENEMPTY;
03562
03563 } else if ((c == '(') && ((d == '-') ||(d == '+') ||(d == '.') || isdigit(d))) {
03564
03565
03566 _arrayIndex++;
03567 if ((_argTypes[_argCount - 1] == ARGKEYWORD) &&
03568 (_argKeywords[_argCount - 1] == Data) ) {
03569
03570 parseData();
03571
03572 } else if ((_argTypes[_argCount - 1] == ARGKEYWORD) &&
03573 (_argKeywords[_argCount - 1] == _IJK ||_argKeywords[_argCount - 1] == _LMN ) ) {
03574
03575
03576 parseData();
03577
03578 } else {
03579
03580 parseNumber(ARGDOUBLE);
03581
03582 if (_errorCode != OK) {
03583 ;
03584 } else if (_inputArray[_arrayIndex + 1] == ')') {
03585 _arrayIndex++;
03586 _argTypes[_argCount] = ARGPARENDOUBLE;
03587
03588 } else {
03589 _errorCode = BAD_COMMAND_ARGUMENTS;
03590
03591 }
03592 }
03593 } else if (c == '"') {
03594
03595 parseString();
03596
03597 } else if ((c == '-') || (c == '+') || (c == '.') || isdigit(c)) {
03598
03599 parseNumber(ARGDOUBLE);
03600
03601 } else if ((c >= 'A') && (c <= 'Z')) {
03602
03603 parseKeyword();
03604
03605 } else {
03606
03607 _errorCode = BAD_COMMAND_ARGUMENTS;
03608
03609 }
03610 if (_errorCode != OK) {
03611 break;
03612 }
03613
03614 _arrayIndex++;
03615 }
03616 _arrayIndex++;
03617
03618 }
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632
03633
03634
03635
03636
03637
03638
03639
03640
03641
03642 ippCommandHashTable::ippCommandHashTable()
03643 {
03644 for (int i=0; i<ippCOMMANDNAMETYPE_MAXIMUM;i++)
03645 {
03646 #define ENUM(a,b) _map.insert(_Pair(b,a));
03647 COMMAND_ENUMERATION
03648 #undef ENUM
03649 }
03650 }
03651 ippCommandNameType ippCommandHashTable::find(const std::string& name)
03652 {
03653 _Iter i = _map.find((name));
03654 if (i == _map.end()) {
03655 return ippCommandNameType_INVALID;
03656 }
03657 return i->second;
03658 }
03659
03660 void ippCommandParser::parseCmdName()
03661 {
03662
03663 const char * name = (_inputArray + 6);
03664
03665
03666 const char* paren = strstr(name,"(");
03667 if (!paren) {
03668 _errorCode = BAD_COMMAND_NAME;
03669 return;
03670 }
03671 int cmdLength = (paren-name);
03672
03673
03674
03675 _errorCode = OK;
03676 _commandName = g_command_hash.find(std::string(name,cmdLength));
03677
03678 if (_commandName == ippCommandNameType_INVALID) {
03679 _errorCode = BAD_COMMAND_NAME;
03680 }
03681
03682
03683 _arrayIndex = ( paren - _inputArray) +1;
03684 }
03685
03686
03687
03688
03689
03690 class ippKeyWordHashTable
03691 {
03692 typedef std::map<std::string,ippOtherKeyType> Map;
03693 typedef std::map<std::string,ippOtherKeyType>::const_iterator _Iter;
03694 typedef std::pair <std::string, ippOtherKeyType> _Pair;
03695 Map _map;
03696 public:
03697 ippKeyWordHashTable();
03698 ippOtherKeyType find(const std::string& string);
03699 } g_keyword_hash;
03700
03701 ippKeyWordHashTable::ippKeyWordHashTable()
03702 {
03703 for (int i=0; i<ippOTHERKEYTYPE_MAXIMUM;i++)
03704 {
03705 #define ENUM(a,b) _map.insert(_Pair(b,a));
03706 KEYWORD_ENUMERATION
03707 #undef ENUM
03708 }
03709 }
03710 ippOtherKeyType ippKeyWordHashTable::find(const std::string& name)
03711 {
03712 _Iter i = _map.find((name));
03713 if (i == _map.end()) {
03714 return ippOtherKeyType_INVALID;
03715 }
03716 return i->second;
03717 }
03718
03719
03720
03721
03722
03723
03724
03725
03726
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761 ippOtherKeyType getFromString(const std::string& keyword )
03762 {
03763 return g_keyword_hash.find(std::string(keyword));
03764 }
03765
03766 void ippCommandParser::parseKeyword()
03767 {
03768
03769 _argKeywords[_argCount] = ippOtherKeyType_INVALID;
03770 const char* keyword = (_inputArray + _arrayIndex);
03771
03772
03773 const char* endkeyword = keyword;
03774 while(isalpha(*endkeyword++));
03775
03776 int keywordLength = (endkeyword-keyword)-1;
03777
03778
03779
03780 _errorCode = OK;
03781
03782 if (keyword[0] == 'E') {
03783 if (isdigit(keyword[1]) && isdigit(keyword[2]) &&
03784 isdigit(keyword[3]) && isdigit(keyword[4]))
03785 {
03786 _argKeywords[_argCount] = TagKey;
03787 _argInt = (unsigned int)((1000*(keyword[1]-'0'))+
03788 (100 *(keyword[2]-'0'))+
03789 (10 *(keyword[3]-'0')) +
03790 (1 *(keyword[4]-'0')));
03791 _arrayIndex+=4;
03792 keywordLength = 1;
03793 }
03794 }
03795
03796 if(ippOtherKeyType_INVALID == _argKeywords[_argCount]) {
03797 _argKeywords[_argCount] = getFromString(std::string(keyword,keywordLength));
03798 if (ippOtherKeyType_INVALID== _argKeywords[_argCount]) {
03799 _errorCode = BAD_KEYWORD;
03800 return;
03801 }
03802 }
03803
03804 if (_argKeywords[_argCount] == Format ) {
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820 static const char* type1= ippScanOnCurveCommand::getFormatString(ippScanOnCurveCommand::Type1);
03821 static int type1_length = strlen(type1);
03822 static const char* type2= ippScanOnCurveCommand::getFormatString(ippScanOnCurveCommand::Type2);
03823 static int type2_length = strlen(type2);
03824 static const char* type3= ippScanOnCurveCommand::getFormatString(ippScanOnCurveCommand::Type3);
03825 static int type3_length = strlen(type3);
03826
03827 int l = strlen(keyword);
03828 if (strncmp(keyword,type1,type1_length) == 0 ) {
03829 _inputArray[_arrayIndex+type1_length-3] = '(';
03830 _inputArray[_arrayIndex+type1_length-2] = '1';
03831 keywordLength = type1_length-3;
03832
03833 } else if (strncmp(keyword,type2,type2_length) == 0 ){
03834 _inputArray[_arrayIndex+type2_length-3] = '(';
03835 _inputArray[_arrayIndex+type2_length-2] = '2';
03836 keywordLength = type2_length-3;
03837
03838 } else if (strncmp(keyword,type3,type3_length) == 0 ){
03839 _inputArray[_arrayIndex+type3_length-3] = '(';
03840 _inputArray[_arrayIndex+type3_length-2] = '3';
03841 keywordLength = type3_length-3;
03842 } else {
03843 _errorCode = BAD_SYNTAX_FOR_FORMAT_IN_SCANONCURVE;
03844 return;
03845 }
03846
03847 }
03848
03849 _arrayIndex = (_arrayIndex + keywordLength ) -1;
03850 if ((_inputArray[_arrayIndex + 1] == '.') ||
03851 (_inputArray[_arrayIndex + 1] == ',') ||
03852 (_inputArray[_arrayIndex + 1] == '(') ||
03853 (_inputArray[_arrayIndex + 1] == ')'))
03854 {
03855 _argTypes[_argCount] = ((_argKeywords[_argCount] == TagKey) ? ARGETAG : ARGKEYWORD);
03856 } else {
03857 _errorCode = BAD_CHARACTER_AFTER_KEYWORD;
03858 }
03859 }
03860
03861
03862
03863
03864
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885
03886
03887
03888
03889
03890
03891
03892
03893
03894
03895
03896
03897
03898
03899
03900
03901
03902
03903 double ippCommandParser::getValue(int index) const
03904 {
03905 IPP_ASSERT(index >=0 && index<=_argDoubles.size());
03906 IPP_ASSERT(_argTypes[index] == ARGDOUBLE || _argTypes[index] == ARGIJK || _argTypes[index] == ARGPARENDOUBLE);
03907 return _argDoubles[index];
03908 }
03909
03910 void ippCommandParser::parseNumber(ippArgItemType argType)
03911 {
03912 IPP_ASSERT(argType == ARGDOUBLE || argType == ARGIJK);
03913 IPP_ASSERT_MSG(_errorCode == OK,"Parser in error state !");
03914
03915 int sign = 0;
03916 int dot = 0;
03917 int k;
03918 int j;
03919 char save;
03920
03921 if ((_inputArray[_arrayIndex] == '-') || (_inputArray[_arrayIndex] == '+')) {
03922 sign = 1;
03923 }
03924
03925 for (k = (_arrayIndex + sign);((_errorCode == OK) &&((_inputArray[k] == '.') || ((_inputArray[k] > 47) && (_inputArray[k] < 58)))); k++) {
03926 if (_inputArray[k] == '.') {
03927 if (dot == 0) {
03928 dot = 1;
03929 } else {
03930 _errorCode = BAD_NUMBER_TWO_DECIMAL_POINTS;
03931 }
03932 }
03933 }
03934
03935 if ((_errorCode == OK) && ((_arrayIndex + sign + dot) == k)) {
03936 _errorCode = BAD_NUMBER_NO_DIGITS;
03937 }
03938 if ((_errorCode == OK) && ((k - (_arrayIndex + sign + dot)) > 16)) {
03939 _errorCode = BAD_NUMBER_MORE_THAN_16_DIGITS;
03940 }
03941 if ((_errorCode == OK) && ((_inputArray[k] == 'E') || (_inputArray[k] == 'e'))) {
03942 k++;
03943 if ((_inputArray[k] == '+') || (_inputArray[k] == '-')) {
03944 k++;
03945 }
03946 for (j = 0; ((_inputArray[k] > 47) && (_inputArray[k] < 58)); j++) {
03947 k++;
03948 }
03949 if ((j < 1) || (j > 3)) {
03950 _errorCode = BAD_E_NUMBER_EXPONENT_MUST_HAVE_ONE_TWO_OR_THREE_DIGITS;
03951 }
03952 }
03953
03954 if (_errorCode == OK) {
03955 save = _inputArray[k];
03956 _inputArray[k] = 0;
03957 double value =0;
03958 sscanf((_inputArray + _arrayIndex), "%lf", &value);
03959
03960 if (_argCount +3 >= _argSize) {
03961 makeArraysBigger();
03962 }
03963
03964 IPP_ASSERT(_argDoubles.size() > _argCount);
03965 IPP_ASSERT(_argTypes.size() > _argCount);
03966
03967 _argDoubles[_argCount] = value;
03968 _argTypes[_argCount]= argType;
03969
03970 _inputArray[k] = save;
03971 _arrayIndex = (k - 1);
03972 }
03973 }
03974
03975
03976
03977
03978
03979
03980
03981
03982
03983
03984
03985
03986
03987
03988
03989
03990
03991
03992
03993
03994
03995
03996
03997
03998
03999
04000
04001
04002 void ippCommandParser::parseString()
04003 {
04004 int start;
04005 char c;
04006
04007 _arrayIndex++;
04008
04009 start = _arrayIndex;
04010
04011 for (; ((c = _inputArray[_arrayIndex]) != 34); _arrayIndex++){
04012 if ((c < 32) || (c > 126)) {
04013 _errorCode = BAD_STRING;
04014 break;
04015 }
04016 }
04017 if (start == _arrayIndex) {
04018 _errorCode = BAD_STRING;
04019 }
04020 if (_errorCode == OK) {
04021 _inputArray[_arrayIndex] = 0;
04022 _argStrings[_argCount] = _inputArray + start;
04023 _inputArray[_arrayIndex] = 34;
04024 _argTypes[_argCount] = ARGSTRING;
04025 }
04026 }
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039
04040
04041
04042
04043
04044
04045
04046
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063 void ippCommandParser::parseTag()
04064 {
04065 _errorCode = OK;
04066 if ((_inputArray[1] < 48) ||
04067 (_inputArray[1] > 57) ||
04068 (_inputArray[2] < 48) ||
04069 (_inputArray[2] > 57) ||
04070 (_inputArray[3] < 48) ||
04071 (_inputArray[3] > 57) ||
04072 (_inputArray[4] < 48) ||
04073 (_inputArray[4] > 57)) {
04074
04075 _errorCode = BAD_TAG_CHARACTER;
04076
04077
04078 } else if (_inputArray[5] != 32) {
04079
04080 _errorCode = SPACE_MISSING_AFTER_TAG;
04081
04082 } else if (_inputArray[0] == 'E') {
04083
04084 _isEvent = true;
04085 sscanf((_inputArray + 1), "%d", &_tag);
04086 if (_tag == 0) {
04087 _errorCode = TAG_NUMBER_OUT_OF_RANGE_FOR_EVENT_TAG;
04088 }
04089
04090 } else if ( isdigit(_inputArray[0]) ) {
04091
04092 _isEvent = false;
04093 sscanf(_inputArray, "%d", &_tag);
04094 if (_tag == 0) {
04095 _errorCode = TAG_NUMBER_OUT_OF_RANGE_FOR_COMMAND_TAG;
04096 }
04097
04098 } else {
04099 _errorCode = BAD_TAG_CHARACTER;
04100 }
04101 }
04102
04103
04104
04105
04106
04107
04108
04109
04110
04111
04112
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122
04123
04124
04125
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135
04136 void ippCommandParser::parseData()
04137 {
04138 char c;
04139 int n =0;
04140 while(_errorCode == OK) {
04141 if (_inputArray[_arrayIndex+1] == ')') {
04142 _argCount--;
04143 break;
04144 }
04145 if (n > 0) {
04146 _arrayIndex++;
04147 if (_inputArray[_arrayIndex] != ',') {
04148 _errorCode = BAD_IJK_NUMBERS;
04149 break;
04150 } else {
04151 _arrayIndex++;
04152 }
04153 }
04154
04155 c = _inputArray[_arrayIndex];
04156 if ((c == '-') || (c == '+') ||(c == '.') || isdigit(c)) {
04157 parseNumber(ARGIJK);
04158
04159 _argCount++;
04160 } else{
04161 _errorCode = BAD_IJK_NUMBERS;
04162 break;
04163 }
04164 n++;
04165 }
04166
04167 if (_errorCode == OK) {
04168 _arrayIndex++;
04169 if (_inputArray[_arrayIndex] != ')') {
04170 _errorCode = BAD_IJK_NUMBERS;
04171 }
04172 }
04173
04174
04175 }
04176
04177
04214 bool UnSpaceInputArray(char* _inputArray,int start)
04215 {
04216 bool result =true;
04217 char c;
04218 int n;
04219 int gap = 0;
04220 bool stringing = false;
04221 bool spaceBefore = false;
04222 bool puncBefore = false;
04223
04224 for (n = start; _inputArray[n-1] != NULL; n++){
04225
04226 c = _inputArray[n];
04227 if (stringing){
04228 if (c == '"') { stringing = false; }
04229 } else if (c == ' ') {
04230 gap++;
04231 if (!puncBefore) {spaceBefore = true;}
04232 continue;
04233 } else if (spaceBefore) {
04234
04235 if ((c == '(') || (c == ')') || (c == ',')) {
04236 spaceBefore = false;
04237 puncBefore = true;
04238 } else {
04239 result = false;
04240 break;
04241 }
04242 } else if ((c == '(') || (c == ')') || (c == ',')) {
04243 puncBefore = true;
04244 } else {
04245 puncBefore = false;
04246 if (c == '"') {
04247 stringing = true;
04248 }
04249 }
04250 _inputArray[n - gap] = c;
04251 }
04252 return result;
04253
04254 }
04255
04256 void ippCommandParser::unSpaceInputArray()
04257 {
04258 if(!::UnSpaceInputArray(_inputArray,6)) {
04259 _errorCode =ILLEGAL_SPACE;
04260 }
04261 }