Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

xtl_bitflags.h

Go to the documentation of this file.
00001 
00002 // Common Text Transformation Library
00003 // Copyright (C) 1997-2006 by Igor Kholodov. 
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the
00017 // Free Software Foundation, Inc.,
00018 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 // mailto:cttl@users.sourceforge.net
00021 // http://sourceforge.net/projects/cttl/
00023 
00033 #ifndef _CTTL_XTL_BITFLAGS_H_INCLUDED_
00034 #define _CTTL_XTL_BITFLAGS_H_INCLUDED_
00035 
00039 namespace cttl_impl {
00040 
00049 struct xtl_bitflags
00050 {
00052     typedef unsigned int value_type;
00053 
00060     xtl_bitflags( value_type flags_ = 0 ) 
00061         : bits( flags_ )
00062     {}
00063 
00073     value_type clear( value_type flags_ )
00074     {
00075         value_type old_value = bits;
00076         bits &= ~flags_;
00077         return old_value;
00078     }
00079 
00089     value_type set( value_type flags_ )
00090     {
00091         value_type old_value = bits;
00092         bits |= flags_;
00093         return old_value;
00094     }
00095 
00105     value_type test( value_type flags_ ) const
00106     {
00107         return bits & flags_;
00108     }
00109 
00119     bool exact_test( value_type flags_ ) const
00120     {
00121         return ( bits & flags_ ) == flags_;
00122     }
00123 
00125     operator value_type() const
00126     {
00127         return bits;
00128     }
00129 
00131     value_type bits;
00132 
00133 };  // struct xtl_bitflags
00134 
00135 }   // namespace cttl_impl
00136 
00137 #endif //_CTTL_XTL_BITFLAGS_H_INCLUDED_

Generated on Thu Nov 2 17:44:06 2006 for Common Text Transformation Library by  doxygen 1.3.9.1