1
/**********************************************************************
3
* Description: Misc STL string utility functions.
4
* Author: Samuel Charron
5
* Created: Mon Nov 18 2013
7
* (C) Copyright 2013, Google Inc.
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
18
**********************************************************************/
20
#ifndef TESSERACT_TRAINING_UTIL_H_
21
#define TESSERACT_TRAINING_UTIL_H_
28
#ifdef USE_STD_NAMESPACE
33
// StringHash is the hashing functor needed by the stl hash map.
36
size_t operator()(const string& s) const {
38
const char* str = s.c_str();
39
for (int ch = 0; str[ch] != 0; ++ch) {
40
hash_code += str[ch] << (ch % 24);
45
#else // COMPILER_MSVC
46
struct StringHash : public stdext::hash_compare <string> {
47
size_t operator()(const string& s) const {
49
const char* str = s.c_str();
50
for (int ch = 0; str[ch] != 0; ++ch) {
51
hash_code += str[ch] << (ch % 24);
55
bool operator()(const string& s1, const string& s2) const {
59
#endif // !COMPILER_MSVC
61
#ifndef USE_STD_NAMESPACE
62
#include "base/heap-checker.h"
63
#define DISABLE_HEAP_LEAK_CHECK HeapLeakChecker::Disabler disabler
65
#define DISABLE_HEAP_LEAK_CHECK {}
68
#endif // TESSERACT_TRAINING_UTIL_H_