OSB_LIB::GreaterName< T, S > Struct Template Reference

Inheritance diagram for OSB_LIB::GreaterName< T, S >:

Inheritance graph
[legend]
Collaboration diagram for OSB_LIB::GreaterName< T, S >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T, typename S = std::string>
struct OSB_LIB::GreaterName< T, S >

Descending sort of objects by name.

Parameters:
T Class or struct to sort, it must have a member function name() returning S.
S The type returned by the member function T::name().
Optionally the class allows for case-insensitive sorting.

Usage example

      #include <list>
      #include "stringutil.h"

      struct Demo {
          const std::string& name() const { return name_; }
          Demo(const std::string& name) : name_(name) {}
          std::string name_;
      };

      void foo()
      {
          std::list<Demo*> list;
          list.push_back(new Demo("a"));
          list.push_back(new Demo("B"));
          list.push_back(new Demo("c"));

          // descending case-insensitive sort
          list.sort(OSB_LIB::GreaterName<Demo*>(true));
      }

Definition at line 460 of file stringutil.h.

Public Member Functions

Private Attributes


Constructor & Destructor Documentation

template<typename T, typename S = std::string>
OSB_LIB::GreaterName< T, S >::GreaterName ( bool  ignoreCase = false  )  [inline]

Constructor with flag to ignore the case.

Definition at line 462 of file stringutil.h.


Member Function Documentation

template<typename T, typename S = std::string>
bool OSB_LIB::GreaterName< T, S >::operator() ( const T &  lhs,
const T &  rhs 
) const [inline]

The comparison function.

Definition at line 468 of file stringutil.h.

References OSB_LIB::GreaterName< T, S >::ignoreCase_.


Member Data Documentation

template<typename T, typename S = std::string>
bool OSB_LIB::GreaterName< T, S >::ignoreCase_ [private]

Flag to ignore the case when comparing the 2 names.

Definition at line 477 of file stringutil.h.

Referenced by OSB_LIB::GreaterName< T, S >::operator()().


The documentation for this struct was generated from the following file:
Generated on Sat Sep 2 14:13:20 2006 for OSB Library by  doxygen 1.4.7