~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/util/string.h

  • Committer: Stewart Smith
  • Date: 2011-03-29 01:30:47 UTC
  • mto: (2257.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2258.
  • Revision ID: stewart@flamingspork.com-20110329013047-5ujzfx6pahmwuko2
have CachedDirectory print out a warning if we can't stat() something in a directory. We should always have access to at least stat() things in directories Drizzle is running in (otherwise there is likely a problem)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
  Some sections of this code came from the Boost examples.
34
34
*/
35
35
 
36
 
#ifndef DRIZZLED_UTIL_STRING_H
37
 
#define DRIZZLED_UTIL_STRING_H
 
36
#pragma once
38
37
 
 
38
#include <utility>
39
39
#include <string>
 
40
#include <vector>
 
41
 
40
42
#include <boost/algorithm/string/predicate.hpp>
 
43
#include <boost/foreach.hpp>
41
44
#include <boost/functional/hash.hpp>
42
 
 
43
 
namespace drizzled
44
 
{
45
 
 
46
 
namespace util
47
 
{
48
 
 
49
 
 
50
 
namespace string {
51
 
typedef boost::shared_ptr<std::string> shared_ptr;
52
 
typedef boost::shared_ptr<const std::string> const_shared_ptr;
 
45
#include <boost/shared_ptr.hpp>
 
46
 
 
47
namespace drizzled {
 
48
namespace util {
 
49
 
 
50
namespace string 
 
51
{
 
52
  typedef boost::shared_ptr<std::string> shared_ptr;
 
53
  typedef boost::shared_ptr<const std::string> const_shared_ptr;
 
54
  typedef std::vector<std::string> vector;
53
55
}
54
56
 
55
57
struct insensitive_equal_to : std::binary_function<std::string, std::string, bool>
56
58
{
57
59
  bool operator()(std::string const& x, std::string const& y) const
58
60
  {
59
 
    return boost::algorithm::iequals(x, y, std::locale());
 
61
    return boost::algorithm::iequals(x, y);
60
62
  }
61
63
};
62
64
 
65
67
  std::size_t operator()(std::string const& x) const
66
68
  {
67
69
    std::size_t seed = 0;
68
 
    std::locale locale;
69
 
 
70
 
    for(std::string::const_iterator it = x.begin(); it != x.end(); ++it)
71
 
    {
72
 
      boost::hash_combine(seed, std::toupper(*it, locale));
73
 
    }
74
 
 
 
70
    BOOST_FOREACH(std::string::const_reference it, x)
 
71
      boost::hash_combine(seed, std::toupper(it));
75
72
    return seed;
76
73
  }
77
74
};
81
78
  std::size_t operator()(std::vector<char> const& x) const
82
79
  {
83
80
    std::size_t seed = 0;
84
 
 
85
 
    for(std::vector<char>::const_iterator it = x.begin(); it != x.end(); ++it)
86
 
    {
87
 
      boost::hash_combine(seed, *it);
88
 
    }
89
 
 
 
81
    BOOST_FOREACH(std::vector<char>::const_reference it, x)
 
82
      boost::hash_combine(seed, it);
90
83
    return seed;
91
84
  }
92
85
};
94
87
} /* namespace util */
95
88
} /* namespace drizzled */
96
89
 
97
 
#endif /* DRIZZLED_UTIL_STRING_H */