Sierra Toolkit  Version of the Day
ci_traits.cpp
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 #include <stk_util/util/ci_traits.hpp>
10 
11 int
13  const char * s1,
14  const char * s2,
15  std::size_t n)
16 {
17  for (std::size_t i = 0; i < n; ++i)
18  if (!eq(s1[i], s2[i]))
19  return lt(s1[i], s2[i]) ? -1 : 1;
20 
21  return 0;
22 }
23 
24 const char *
26  const char * s,
27  std::size_t n,
28  const char & c)
29 {
30  for (std::size_t i = 0; i < n; ++i)
31  if (eq(s[i], c))
32  return &(s[i]);
33 
34  return 0;
35 }
static bool lt(const char &c1, const char &c2)
Member function lt return true is c1 less than c2.
Definition: ci_traits.hpp:46
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