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

xtl_bitflags Struct Reference

#include <xtl_bitflags.h>

List of all members.


Detailed Description

Encapsulates bit operations on an integer type.

The following code demonstrates use of xtl_bitflags struct:

// xtl_bitflags.cpp
// demonstrates cttl_impl::xtl_bitflags usage

#include <iostream>
#include "cttl/xtl_bitflags.h"

int main()
{
    using cttl_impl::xtl_bitflags;

    xtl_bitflags flags( 1 );
    std::cout << "flags " << flags << std::endl;
    std::cout << " flags.clear( 1 ) ";   flags.clear( 1 );  std::cout << std::endl;
    std::cout << " flags.set( 128 ) ";   flags.set( 128 );  std::cout << std::endl;
    std::cout << "  flags.test( 2 ) " << flags.test( 2 );   std::cout << std::endl;
    std::cout << "flags.test( 128 ) " << flags.test( 128 ); std::cout << std::endl;
    std::cout << "   flags.set( 2 ) ";   flags.set( 2 );    std::cout << std::endl;
    std::cout << "  flags.test( 2 ) " << flags.test( 2 );   std::cout << std::endl;
    std::cout << " flags.clear( 2 ) ";   flags.clear( 2 );  std::cout << std::endl;
    std::cout << "  flags.test( 2 ) " << flags.test( 2 );   std::cout << std::endl;
    std::cout << "flags.test( 128 ) " << flags.test( 128 ); std::cout << std::endl;

    return 0;
}
This sample program prints:
flags 1
 flags.clear( 1 )
 flags.set( 128 )
  flags.test( 2 ) 0
flags.test( 128 ) 128
   flags.set( 2 )
  flags.test( 2 ) 2
 flags.clear( 2 )
  flags.test( 2 ) 0
flags.test( 128 ) 128

Definition at line 49 of file xtl_bitflags.h.

Public Types

typedef unsigned int value_type
 Defines type that represents bits of the integer.

Public Member Functions

 xtl_bitflags (value_type flags_=0)
 Constructs new object and sets flags provided by the user.
value_type clear (value_type flags_)
 Clears (sets to zero) bits specified by the caller.
value_type set (value_type flags_)
 Sets bits provided by the user.
value_type test (value_type flags_) const
 Tests if bits are set.
bool exact_test (value_type flags_) const
 Tests flags.
 operator value_type () const
 Converts encapsulated bits to the xtl_bitflags::value_type.

Public Attributes

value_type bits
 Stores encapsulated bits.


Constructor & Destructor Documentation

xtl_bitflags value_type  flags_ = 0  )  [inline]
 

Constructs new object and sets flags provided by the user.

Parameters:
flags_ Bit values to initialize the new object.

Definition at line 60 of file xtl_bitflags.h.


Member Function Documentation

value_type clear value_type  flags_  )  [inline]
 

Clears (sets to zero) bits specified by the caller.

Parameters:
flags_ Specifies bits to be cleared.
Returns:
Old bit values.

Definition at line 73 of file xtl_bitflags.h.

bool exact_test value_type  flags_  )  const [inline]
 

Tests flags.

Parameters:
flags_ Specifies bits to be tested.
Returns:
Non-zero result only if all flags_ are set.

Definition at line 119 of file xtl_bitflags.h.

value_type set value_type  flags_  )  [inline]
 

Sets bits provided by the user.

Parameters:
flags_ Specifies bits to be set.
Returns:
Old bit values.

Definition at line 89 of file xtl_bitflags.h.

value_type test value_type  flags_  )  const [inline]
 

Tests if bits are set.

Parameters:
flags_ Specifies bits to be tested.
Returns:
Non-zero result if at least one of the flags_ is set.

Definition at line 105 of file xtl_bitflags.h.


The documentation for this struct was generated from the following file:
Generated on Thu Nov 2 17:45:23 2006 for Common Text Transformation Library by  doxygen 1.3.9.1