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

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: Fixed windows include dirs Created 8 years, 6 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 // Use std names.
32 using std::set;
33 using std::pair;
34 using std::vector;
35 using std::string;
36 using std::min;
37 using std::max;
38 using std::ostream;
39 using std::map;
40 using std::stack;
41 using std::sort;
42 using std::swap;
43 using std::make_pair;
44
45 #if defined(__GNUC__) && !defined(USE_CXX0X)
46
47 #include <tr1/unordered_set>
48 using std::tr1::unordered_set;
49
50 #else
51
52 #include <unordered_set>
53 #ifdef WIN32
54 using std::tr1::unordered_set;
55 #else
56 using std::unordered_set;
57 #endif
58
59 #endif
60
61 namespace re2 {
62
63 typedef int8_t int8;
64 typedef uint8_t uint8;
65 typedef int16_t int16;
66 typedef uint16_t uint16;
67 typedef int32_t int32;
68 typedef uint32_t uint32;
69 typedef int64_t int64;
70 typedef uint64_t uint64;
71
72 typedef unsigned long ulong;
73 typedef unsigned int uint;
74 typedef unsigned short ushort;
75
76 // COMPILE_ASSERT causes a compile error about msg if expr is not true.
77 template<bool> struct CompileAssert {};
78 #define COMPILE_ASSERT(expr, msg) \
79 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
80
81 // DISALLOW_EVIL_CONSTRUCTORS disallows the copy and operator= functions.
82 // It goes in the private: declarations in a class.
83 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
84 TypeName(const TypeName&); \
85 void operator=(const TypeName&)
86
87 #define arraysize(array) (sizeof(array)/sizeof((array)[0]))
88
89 // Fake lock annotations. For real ones, see
90 // http://code.google.com/p/data-race-test/
91 #define ANNOTATE_PUBLISH_MEMORY_RANGE(a, b)
92 #define ANNOTATE_IGNORE_WRITES_BEGIN()
93 #define ANNOTATE_IGNORE_WRITES_END()
94 #define ANNOTATE_BENIGN_RACE(a, b)
95 #define NO_THREAD_SAFETY_ANALYSIS
96 #define ANNOTATE_HAPPENS_BEFORE(x)
97 #define ANNOTATE_HAPPENS_AFTER(x)
98
99 class StringPiece;
100
101 string CEscape(const StringPiece& src);
102 int CEscapeString(const char* src, int src_len, char* dest, int dest_len);
103
104 extern string StringPrintf(const char* format, ...);
105 extern void SStringPrintf(string* dst, const char* format, ...);
106 extern void StringAppendF(string* dst, const char* format, ...);
107 extern string PrefixSuccessor(const StringPiece& prefix);
108
109 uint32 hashword(const uint32*, size_t, uint32);
110 void hashword2(const uint32*, size_t, uint32*, uint32*);
111
112 static inline uint32 Hash32StringWithSeed(const char* s, int len, uint32 seed) {
113 return hashword((uint32*)s, len/4, seed);
114 }
115
116 static inline uint64 Hash64StringWithSeed(const char* s, int len, uint32 seed) {
117 uint32 x, y;
118 x = seed;
119 y = 0;
120 hashword2((uint32*)s, len/4, &x, &y);
121 return ((uint64)x << 32) | y;
122 }
123
124 int RunningOnValgrind();
125
126 } // namespace re2
127
128 #include "util/arena.h"
129 #include "util/logging.h"
130 #include "util/mutex.h"
131 #include "util/utf.h"
132
133 #endif // RE2_UTIL_UTIL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698