Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/re2/util/util.h

Issue 10575037: Include RE2 library (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed valgrind specific code that is in Chromium already Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2009 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #ifndef RE2_UTIL_UTIL_H__
6 #define RE2_UTIL_UTIL_H__
7
8 // C
9 #include <stdio.h>
10 #include <string.h>
11 #include <stdint.h>
12 #include <stddef.h> // For size_t
13 #include <assert.h>
14 #include <stdarg.h>
15 #ifndef WIN32
16 #include <sys/time.h>
17 #endif
18 #include <time.h>
19
20 // C++
21 #include <vector>
22 #include <string>
23 #include <algorithm>
24 #include <iosfwd>
25 #include <map>
26 #include <stack>
27 #include <iostream>
28 #include <utility>
29 #include <set>
30
31 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
32
33 // Use std names.
34 using std::set;
35 using std::pair;
36 using std::vector;
37 using std::string;
38 using std::min;
39 using std::max;
40 using std::ostream;
41 using std::map;
42 using std::stack;
43 using std::sort;
44 using std::swap;
45 using std::make_pair;
46
47 #if defined(__GNUC__) && !defined(USE_CXX0X)
48
49 #include <tr1/unordered_set>
50 using std::tr1::unordered_set;
51
52 #else
53
54 #include <unordered_set>
55 #ifdef WIN32
56 using std::tr1::unordered_set;
57 #else
58 using std::unordered_set;
59 #endif
60
61 #endif
62
63 namespace re2 {
64
65 typedef int8_t int8;
66 typedef uint8_t uint8;
67 typedef int16_t int16;
68 typedef uint16_t uint16;
69 typedef int32_t int32;
70 typedef uint32_t uint32;
71 typedef int64_t int64;
72 typedef uint64_t uint64;
73
74 typedef unsigned long ulong;
75 typedef unsigned int uint;
76 typedef unsigned short ushort;
77
78 // COMPILE_ASSERT causes a compile error about msg if expr is not true.
79 template<bool> struct CompileAssert {};
80 #define COMPILE_ASSERT(expr, msg) \
81 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
82
83 // DISALLOW_EVIL_CONSTRUCTORS disallows the copy and operator= functions.
84 // It goes in the private: declarations in a class.
85 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
86 TypeName(const TypeName&); \
87 void operator=(const TypeName&)
88
89 #define arraysize(array) (sizeof(array)/sizeof((array)[0]))
90
91 class StringPiece;
92
93 string CEscape(const StringPiece& src);
94 int CEscapeString(const char* src, int src_len, char* dest, int dest_len);
95
96 extern string StringPrintf(const char* format, ...);
97 extern void SStringPrintf(string* dst, const char* format, ...);
98 extern void StringAppendF(string* dst, const char* format, ...);
99 extern string PrefixSuccessor(const StringPiece& prefix);
100
101 uint32 hashword(const uint32*, size_t, uint32);
102 void hashword2(const uint32*, size_t, uint32*, uint32*);
103
104 static inline uint32 Hash32StringWithSeed(const char* s, int len, uint32 seed) {
105 return hashword((uint32*)s, len/4, seed);
106 }
107
108 static inline uint64 Hash64StringWithSeed(const char* s, int len, uint32 seed) {
109 uint32 x, y;
110 x = seed;
111 y = 0;
112 hashword2((uint32*)s, len/4, &x, &y);
113 return ((uint64)x << 32) | y;
114 }
115
116 } // namespace re2
117
118 #include "util/arena.h"
119 #include "util/logging.h"
120 #include "util/mutex.h"
121 #include "util/utf.h"
122
123 #endif // RE2_UTIL_UTIL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698