1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF) */
3 /* (C) Copyright IBM Corp. 2001 */
4 /* */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0. */
6 /*****************************************************************************/
7
8 #ifndef STAF_CommandParserInlImpl
9 #define STAF_CommandParserInlImpl
10
11 #include "STAF.h"
12 #include "STAFCommandParser.h"
13 #include "STAFException.h"
14
optionTimes(const STAFString & optionName)15 STAF_INLINE unsigned int STAFCommandParseResult::optionTimes(
16 const STAFString &optionName)
17 {
18 unsigned int osRC = 0;
19 unsigned int numTimes = 0;
20
21 STAFRC_t rc = STAFCommandParseResultGetOptionTimes(fResultImpl,
22 optionName.getImpl(), &numTimes, &osRC);
23
24 STAFException::checkRC(rc, "STAFCommandParseResultGetOptionTimes", osRC);
25
26 return numTimes;
27 }
28
29
optionValue(const STAFString & optionName,unsigned int number)30 STAF_INLINE STAFString STAFCommandParseResult::optionValue(
31 const STAFString &optionName, unsigned int number)
32 {
33 unsigned int osRC = 0;
34 STAFString_t optValue = 0;
35
36 STAFRC_t rc = STAFCommandParseResultGetOptionValue(fResultImpl,
37 optionName.getImpl(), number, &optValue, &osRC);
38
39 STAFException::checkRC(rc, "STAFCommandParseResultGetOptionValue", osRC);
40
41 return optValue;
42 }
43
44
numInstances()45 STAF_INLINE unsigned int STAFCommandParseResult::numInstances()
46 {
47 unsigned int osRC = 0;
48 unsigned int numInst = 0;
49
50 STAFRC_t rc = STAFCommandParseResultGetNumInstances(fResultImpl,
51 &numInst, &osRC);
52
53 STAFException::checkRC(rc, "STAFCommandParseResultGetNumInstances", osRC);
54
55 return numInst;
56 }
57
58
instanceName(unsigned int number)59 STAF_INLINE STAFString STAFCommandParseResult::instanceName(unsigned int number)
60 {
61 unsigned int osRC = 0;
62 STAFString_t instName = 0;
63
64 STAFRC_t rc = STAFCommandParseResultGetInstanceName(fResultImpl, number,
65 &instName, &osRC);
66
67 STAFException::checkRC(rc, "STAFCommandParseResultGetInstanceName", osRC);
68
69 return instName;
70 }
71
72
instanceValue(unsigned int number)73 STAF_INLINE STAFString STAFCommandParseResult::instanceValue(unsigned int number)
74 {
75 unsigned int osRC = 0;
76 STAFString_t instValue = 0;
77
78 STAFRC_t rc = STAFCommandParseResultGetInstanceValue(fResultImpl, number,
79 &instValue, &osRC);
80
81 STAFException::checkRC(rc, "STAFCommandParseResultGetInstanceValue", osRC);
82
83 return instValue;
84 }
85
86
numArgs()87 STAF_INLINE unsigned int STAFCommandParseResult::numArgs()
88 {
89 unsigned int osRC = 0;
90 unsigned int numArg = 0;
91
92 STAFRC_t rc = STAFCommandParseResultGetNumArgs(fResultImpl, &numArg, &osRC);
93
94 STAFException::checkRC(rc, "STAFCommandParseResultGetNumArgs", osRC);
95
96 return numArg;
97 }
98
99
arg(unsigned int number)100 STAF_INLINE STAFString STAFCommandParseResult::arg(unsigned int number)
101 {
102 unsigned int osRC = 0;
103 STAFString_t argValue = 0;
104
105 STAFRC_t rc = STAFCommandParseResultGetArgValue(fResultImpl, number,
106 &argValue, &osRC);
107
108 STAFException::checkRC(rc, "STAFCommandParseResultGetArgValue", osRC);
109
110 return argValue;
111 }
112
113
~STAFCommandParseResult()114 STAF_INLINE STAFCommandParseResult::~STAFCommandParseResult()
115 {
116 unsigned int osRC = 0;
117 STAFRC_t rc = STAFCommandParseResultDestruct(&fResultImpl, &osRC);
118 }
119
120
121 // Begin inline declarations for STAFCommandParser
122
STAFCommandParser(unsigned int maxArgs,bool caseSensitive)123 STAF_INLINE STAFCommandParser::STAFCommandParser(unsigned int maxArgs,
124 bool caseSensitive)
125 : fParserImpl(0)
126 {
127 unsigned int osRC = 0;
128 STAFRC_t rc = STAFCommandParserConstruct(&fParserImpl, maxArgs,
129 caseSensitive, &osRC);
130
131 STAFException::checkRC(rc, "STAFCommandParserConstruct", osRC);
132 }
133
134
addOption(const STAFString & option,unsigned int numAllowed,ValueRequirement valueReq)135 STAF_INLINE void STAFCommandParser::addOption(const STAFString &option,
136 unsigned int numAllowed, ValueRequirement valueReq)
137 {
138 unsigned int osRC = 0;
139
140 STAFRC_t rc = STAFCommandParserAddOption(fParserImpl, option.getImpl(),
141 numAllowed, valueReq, &osRC);
142
143 STAFException::checkRC(rc, "STAFCommandParserAddOption", osRC);
144 }
145
146
addOptionGroup(const STAFString & group,unsigned int minAllowed,unsigned int maxAllowed)147 STAF_INLINE void STAFCommandParser::addOptionGroup(const STAFString &group,
148 unsigned int minAllowed, unsigned int maxAllowed)
149 {
150 unsigned int osRC = 0;
151
152 STAFRC_t rc = STAFCommandParserAddOptionGroup(fParserImpl,
153 group.getImpl(), minAllowed, maxAllowed, &osRC);
154
155 STAFException::checkRC(rc, "STAFCommandParserAddOptionGroup", osRC);
156 }
157
158
addOptionNeed(const STAFString & needers,const STAFString & needees)159 STAF_INLINE void STAFCommandParser::addOptionNeed(const STAFString &needers,
160 const STAFString &needees)
161 {
162 unsigned int osRC = 0;
163
164 STAFRC_t rc = STAFCommandParserAddOptionNeed(fParserImpl,
165 needers.getImpl(), needees.getImpl(), &osRC);
166
167 STAFException::checkRC(rc, "STAFCommandParserAddOptionNeed", osRC);
168 }
169
170
parse(const STAFString & parseString)171 STAF_INLINE STAFCommandParseResultPtr STAFCommandParser::parse(
172 const STAFString &parseString)
173 {
174 unsigned int osRC = 0;
175 STAFCommandParseResult_t result = 0;
176 STAFString_t errorBuffer = 0;
177
178 STAFRC_t rc = STAFCommandParserParseString(fParserImpl,
179 parseString.getImpl(), &result, &errorBuffer, &osRC);
180
181 return STAFCommandParseResultPtr(
182 new STAFCommandParseResult(result, rc, errorBuffer),
183 STAFCommandParseResultPtr::INIT);
184 }
185
186
~STAFCommandParser()187 STAF_INLINE STAFCommandParser::~STAFCommandParser()
188 {
189 unsigned int osRC = 0;
190 STAFRC_t rc = STAFCommandParserDestruct(&fParserImpl, &osRC);
191 }
192
193 #endif
194