1*78bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*78bc99aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*78bc99aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*78bc99aaSAndrew Rist  * distributed with this work for additional information
6*78bc99aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*78bc99aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*78bc99aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*78bc99aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*78bc99aaSAndrew Rist  *
11*78bc99aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*78bc99aaSAndrew Rist  *
13*78bc99aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*78bc99aaSAndrew Rist  * software distributed under the License is distributed on an
15*78bc99aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*78bc99aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*78bc99aaSAndrew Rist  * specific language governing permissions and limitations
18*78bc99aaSAndrew Rist  * under the License.
19*78bc99aaSAndrew Rist  *
20*78bc99aaSAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <tokens/stmstarr.hxx>
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
27cdf0e10cSrcweir #include <x_parse.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
StmArrayStatus(intt i_nStatusSize,const INT16 * in_aArrayModel,F_CRTOK i_fTokenCreateFunction,bool in_bIsDefault)31cdf0e10cSrcweir StmArrayStatus::StmArrayStatus( intt			i_nStatusSize,
32cdf0e10cSrcweir 								const INT16 * 	in_aArrayModel,
33cdf0e10cSrcweir 								F_CRTOK			i_fTokenCreateFunction,
34cdf0e10cSrcweir 							    bool			in_bIsDefault )
35cdf0e10cSrcweir 	:	dpBranches(new StmStatus::Branch[i_nStatusSize]),
36cdf0e10cSrcweir 		nNrOfBranches(i_nStatusSize),
37cdf0e10cSrcweir 		fTokenCreateFunction(i_fTokenCreateFunction),
38cdf0e10cSrcweir 		bIsADefault(in_bIsDefault)
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 	if (in_aArrayModel != 0)
41cdf0e10cSrcweir 	{
42cdf0e10cSrcweir 		intt count = 0;
43cdf0e10cSrcweir 		for (const INT16 * get = in_aArrayModel; count < nNrOfBranches; count++, get++)
44cdf0e10cSrcweir 			dpBranches[count] = *get;
45cdf0e10cSrcweir 	}
46cdf0e10cSrcweir 	else //
47cdf0e10cSrcweir 	{
48cdf0e10cSrcweir 		memset(dpBranches, 0, nNrOfBranches);
49cdf0e10cSrcweir 	}  // endif
50cdf0e10cSrcweir }
51cdf0e10cSrcweir 
~StmArrayStatus()52cdf0e10cSrcweir StmArrayStatus::~StmArrayStatus()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	delete [] dpBranches;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir bool
SetBranch(intt in_nBranchIx,StmStatus::Branch in_nBranch)58cdf0e10cSrcweir StmArrayStatus::SetBranch( intt    		 	 in_nBranchIx,
59cdf0e10cSrcweir 						   StmStatus::Branch in_nBranch )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	if ( csv::in_range(intt(0), in_nBranchIx, intt(nNrOfBranches) ) )
62cdf0e10cSrcweir 	{
63cdf0e10cSrcweir 		dpBranches[in_nBranchIx] = in_nBranch;
64cdf0e10cSrcweir 		return true;
65cdf0e10cSrcweir 	}
66cdf0e10cSrcweir 	return false;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 
70cdf0e10cSrcweir StmStatus::Branch
NextBy(intt in_nIndex) const71cdf0e10cSrcweir StmArrayStatus::NextBy(intt in_nIndex) const
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	if (in_nIndex < 0)
74cdf0e10cSrcweir 		throw X_Parser(X_Parser::x_InvalidChar, "", String::Null_(), 0);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	return in_nIndex < nNrOfBranches
77cdf0e10cSrcweir 				?	dpBranches[in_nIndex]
78cdf0e10cSrcweir 				:   dpBranches[nNrOfBranches - 1];
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
82cdf0e10cSrcweir bool
IsADefault() const83cdf0e10cSrcweir StmArrayStatus::IsADefault() const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	return bIsADefault;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir StmArrayStatus *
AsArray()89cdf0e10cSrcweir StmArrayStatus::AsArray()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	return this;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94