checkediterator.hxx (4e7d57d8) | checkediterator.hxx (e62cf9b4) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 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 | 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 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 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. | 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 * | 19 * |
20 *************************************************************/ 21 22 23 24#ifndef __FRAMEWORK_CLASSES_CHECKEDITERATOR_HXX_ 25#define __FRAMEWORK_CLASSES_CHECKEDITERATOR_HXX_ 26 27//_________________________________________________________________________________________________________________ --- 25 unchanged lines hidden (view full) --- 53// exported const 54//_________________________________________________________________________________________________________________ 55 56//_________________________________________________________________________________________________________________ 57// exported definitions 58//_________________________________________________________________________________________________________________ 59 60/*-************************************************************************************************************//** | 20 *************************************************************/ 21 22 23 24#ifndef __FRAMEWORK_CLASSES_CHECKEDITERATOR_HXX_ 25#define __FRAMEWORK_CLASSES_CHECKEDITERATOR_HXX_ 26 27//_________________________________________________________________________________________________________________ --- 25 unchanged lines hidden (view full) --- 53// exported const 54//_________________________________________________________________________________________________________________ 55 56//_________________________________________________________________________________________________________________ 57// exported definitions 58//_________________________________________________________________________________________________________________ 59 60/*-************************************************************************************************************//** |
61 @short implement a iterator which support 2 end states! | 61 @short implement a iterator which support 2 end states! |
62 @descr For our search methods we need a "walking" iterator object with special functionality! 63 We must check for 3 different states of an iterator - normal position, exact end, after end. 64 It's necessary to detect if we have not found a entry and must return our default or 65 default already returned and we must break loop! 66 see using in class FilterCache too for further informations! 67 68 @Attention If your wish to debug this inline code ... 69 under windows and msdev you can use "set ENVCFLAGS=/Ob0" to do that! --- 140 unchanged lines hidden (view full) --- 210 @param - 211 @return A reference to our changed object himself. 212 213 @onerror - 214 *//*-*****************************************************************************************************/ 215 216 inline CheckedIterator& operator++() 217 { | 62 @descr For our search methods we need a "walking" iterator object with special functionality! 63 We must check for 3 different states of an iterator - normal position, exact end, after end. 64 It's necessary to detect if we have not found a entry and must return our default or 65 default already returned and we must break loop! 66 see using in class FilterCache too for further informations! 67 68 @Attention If your wish to debug this inline code ... 69 under windows and msdev you can use "set ENVCFLAGS=/Ob0" to do that! --- 140 unchanged lines hidden (view full) --- 210 @param - 211 @return A reference to our changed object himself. 212 213 @onerror - 214 *//*-*****************************************************************************************************/ 215 216 inline CheckedIterator& operator++() 217 { |
218 // Warn programmer if he forget to initailize object! | 218 // Warn programmer if he forget to initialize object! |
219 LOG_ASSERT2( m_pContainer==NULL, "CheckedIterator::operator++()", "Object not initialized!" ) 220 // Step to next element if any exist or set our end states. 221 switch( m_eEndState ) 222 { 223 case E_BEFOREEND: { 224 ++m_pPosition; 225 // If iterator reaching end ... set right state! 226 if( m_pPosition == m_pContainer->end() ) --- 13 unchanged lines hidden (view full) --- 240 241 /*-****************************************************************************************************//** 242 @short return true if internal iterator was not initialized before 243 @descr These will be true, if use start a new search by using these iterator mechanism! 244 245 @seealso class FilterCache 246 247 @param - | 219 LOG_ASSERT2( m_pContainer==NULL, "CheckedIterator::operator++()", "Object not initialized!" ) 220 // Step to next element if any exist or set our end states. 221 switch( m_eEndState ) 222 { 223 case E_BEFOREEND: { 224 ++m_pPosition; 225 // If iterator reaching end ... set right state! 226 if( m_pPosition == m_pContainer->end() ) --- 13 unchanged lines hidden (view full) --- 240 241 /*-****************************************************************************************************//** 242 @short return true if internal iterator was not initialized before 243 @descr These will be true, if use start a new search by using these iterator mechanism! 244 245 @seealso class FilterCache 246 247 @param - |
248 @return True if internalk state E_UNKNOWN - false otherwise. | 248 @return True if internal state E_UNKNOWN - false otherwise. |
249 250 @onerror - 251 *//*-*****************************************************************************************************/ 252 253 inline sal_Bool isUninitialized() 254 { 255 return( m_eEndState == E_UNKNOWN ); 256 } --- 47 unchanged lines hidden (view full) --- 304 @return A reference to value of container entry. 305 306 @onerror - 307 *//*-*****************************************************************************************************/ 308 309 inline typename TContainer::const_iterator getEntry() 310 { 311 // Warn programmer if he forget to initialize these object ... | 249 250 @onerror - 251 *//*-*****************************************************************************************************/ 252 253 inline sal_Bool isUninitialized() 254 { 255 return( m_eEndState == E_UNKNOWN ); 256 } --- 47 unchanged lines hidden (view full) --- 304 @return A reference to value of container entry. 305 306 @onerror - 307 *//*-*****************************************************************************************************/ 308 309 inline typename TContainer::const_iterator getEntry() 310 { 311 // Warn programmer if he forget to initialize these object ... |
312 LOG_ASSERT2( m_pContainer==NULL, "CheckedIterator::getEntry()", "Object not initialized!" ) | 312 LOG_ASSERT2( m_pContainer==NULL, "CheckedIterator::getEntry()", "Object not initialized!" ) |
313 // or try to read a non existing element! | 313 // or try to read a non existing element! |
314 LOG_ASSERT2( m_eEndState!=E_BEFOREEND, "CheckedIterator::getEntry()", "Wrong using of class detected!" ) | 314 LOG_ASSERT2( m_eEndState!=E_BEFOREEND, "CheckedIterator::getEntry()", "Wrong using of class detected!" ) |
315 | 315 |
316 return m_pPosition; | 316 return m_pPosition; |
317 } 318 319 //------------------------------------------------------------------------------------------------------------- 320 // private member 321 //------------------------------------------------------------------------------------------------------------- 322 323 private: 324 | 317 } 318 319 //------------------------------------------------------------------------------------------------------------- 320 // private member 321 //------------------------------------------------------------------------------------------------------------- 322 323 private: 324 |
325 // These enum defines our four states for an iterator position in curent container. | 325 // These enum defines our four states for an iterator position in current container. |
326 enum EEndState 327 { 328 E_UNKNOWN , 329 E_BEFOREEND , 330 E_END , 331 E_AFTEREND 332 }; 333 334 const TContainer* m_pContainer ; // pointer to current container 335 EEndState m_eEndState ; // "position state" of iterator! 336 typename TContainer::const_iterator m_pPosition ; // point to actual element in container 337}; 338 339} // namespace framework 340 341#endif // #ifndef __FRAMEWORK_CLASSES_CHECKEDITERATOR_HXX_ | 326 enum EEndState 327 { 328 E_UNKNOWN , 329 E_BEFOREEND , 330 E_END , 331 E_AFTEREND 332 }; 333 334 const TContainer* m_pContainer ; // pointer to current container 335 EEndState m_eEndState ; // "position state" of iterator! 336 typename TContainer::const_iterator m_pPosition ; // point to actual element in container 337}; 338 339} // namespace framework 340 341#endif // #ifndef __FRAMEWORK_CLASSES_CHECKEDITERATOR_HXX_ |