1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ADC_CPP_SRECOVER_HXX
25 #define ADC_CPP_SRECOVER_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 #include "cxt2ary.hxx"
32 #include <ary/info/docstore.hxx>
33 	// COMPONENTS
34 	// PARAMETERS
35 
36 namespace cpp
37 {
38 
39 /** Implementation struct for cpp::ContextForAry.
40 */
41 struct ContextForAry::S_RecoveryGuard
42 {
43   public:
44                         S_RecoveryGuard();
45                         ~S_RecoveryGuard();
46 
Resetcpp::ContextForAry::S_RecoveryGuard47     void                Reset()                 { bIsWithinRecovery = false; nBlockBracketsCounter = 0; }
48 
49     void                StartWaitingFor_Recovery();
50 
51     void                Hdl_SwBracketOpen();
52     void                Hdl_SwBracketClose();
53     void                Hdl_Semicolon();
54 
55     bool                IsWithinRecovery() const;
56 
57   private:
58     // DATA
59     bool                bIsWithinRecovery;
60     intt                nBlockBracketsCounter;
61 };
62 
63 
64 
65 // IMPLEMENTATION
66 
67 /*  The implementation is in header, though not all inline, because this file
68     is included in cxt2ary.cxx only!
69 */
70 
71 ContextForAry::
S_RecoveryGuard()72 S_RecoveryGuard::S_RecoveryGuard()
73     :   bIsWithinRecovery(false),
74         nBlockBracketsCounter(0)
75 {
76 }
77 
78 ContextForAry::
~S_RecoveryGuard()79 S_RecoveryGuard::~S_RecoveryGuard()
80 {
81 }
82 
83 inline void
84 ContextForAry::
StartWaitingFor_Recovery()85 S_RecoveryGuard::StartWaitingFor_Recovery()
86 {
87     bIsWithinRecovery = true;
88     nBlockBracketsCounter = 0;
89 }
90 
91 void
92 ContextForAry::
Hdl_SwBracketOpen()93 S_RecoveryGuard::Hdl_SwBracketOpen()
94 {
95     if ( bIsWithinRecovery )
96         ++nBlockBracketsCounter;
97 }
98 
99 void
100 ContextForAry::
Hdl_SwBracketClose()101 S_RecoveryGuard::Hdl_SwBracketClose()
102 {
103     if ( bIsWithinRecovery )
104         --nBlockBracketsCounter;
105 }
106 
107 inline void
108 ContextForAry::
Hdl_Semicolon()109 S_RecoveryGuard::Hdl_Semicolon()
110 {
111     if (bIsWithinRecovery AND nBlockBracketsCounter == 0)
112        bIsWithinRecovery = false;
113 }
114 
115 inline bool
116 ContextForAry::
IsWithinRecovery() const117 S_RecoveryGuard::IsWithinRecovery() const
118 {
119     return bIsWithinRecovery;
120 }
121 
122 
123 
124 }   // namespace cpp
125 
126 
127 #endif
128 
129