Sierra Toolkit  Version of the Day
ci_traits.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef STK_UTIL_UTIL_CI_TRAITS_H
10 #define STK_UTIL_UTIL_CI_TRAITS_H
11 
12 #include <cctype>
13 #include <string>
14 
22 struct ignorecase_traits : public std::char_traits<char>
23 {
33  static bool eq(const char &c1, const char &c2) {
34  return std::toupper(c1) == std::toupper(c2);
35  }
36 
46  static bool lt(const char &c1, const char &c2) {
47  return std::toupper(c1) < std::toupper(c2);
48  }
49 
63  static int compare(const char *s1, const char *s2, std::size_t n);
64 
78  static const char *find(const char *s, std::size_t n, const char &c);
79 };
80 
81 #endif // STK_UTIL_UTIL_CI_TRAITS_H
static bool lt(const char &c1, const char &c2)
Member function lt return true is c1 less than c2.
Definition: ci_traits.hpp:46
Class ignorecase_traits is a character traits class that ignores case during compares.
Definition: ci_traits.hpp:22
static const char * find(const char *s, std::size_t n, const char &c)
Member function find returns char pointer to first occurrence of character c in first n characters of...
Definition: ci_traits.cpp:25
static int compare(const char *s1, const char *s2, std::size_t n)
Member function compare compares up to n characters of s1 and s2 and returns -1 if s1 is less then s2...
Definition: ci_traits.cpp:12
static bool eq(const char &c1, const char &c2)
Member function eq return true is c1 and c2 are equal.
Definition: ci_traits.hpp:33