hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxSearchInterface.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <ctype.h>
3 
5 #include "SphinxError.hpp"
6 #include "SphinxMessageConst.hpp"
7 
8 namespace HCE
9 {
10 namespace sphinx
11 {
12 //-----------------------------------------------------------------------------
14 :errorMsg(""), errorCode(NO_ERROR), _isError(false)
15 {
16 }
17 //-----------------------------------------------------------------------------
18 bool SphinxSearchInterface::insensitiveCompare(const std::string& lhs, const std::string& rhs)
19 {
20  std::string lhsCpy(lhs);
21  std::string rhsCpy(rhs);
22  std::transform(lhsCpy.begin(), lhsCpy.end(), lhsCpy.begin(), tolower);
23  std::transform(rhsCpy.begin(), rhsCpy.end(), rhsCpy.begin(), tolower);
24  return (lhsCpy == rhsCpy);
25 }
26 //-------------------------------------------------------------------
27 size_t SphinxSearchInterface::getTimeInterval(timeval& start, timeval& stop)
28 {
29  size_t result = 0;
30  if (start.tv_sec == stop.tv_sec)
31  result = abs(stop.tv_usec - start.tv_usec);
32  else if (start.tv_sec > stop.tv_sec)
33  {
34  time_t sec = start.tv_sec - stop.tv_sec;
35  result = sec*1000000+start.tv_usec - stop.tv_usec;
36  }
37  else
38  {
39  time_t sec = stop.tv_sec - start.tv_sec;
40  result = sec*1000000+stop.tv_usec - start.tv_usec;
41  }
42  return result;
43 }
44 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
46 } // end namespace sphinx
47 } // end namespace HCE
48 
49 
50 
51