2
* Copyright 2012 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// Author: gagansingh@google.com (Gagan Singh)
19
#ifndef PAGESPEED_KERNEL_UTIL_RE2_H_
20
#define PAGESPEED_KERNEL_UTIL_RE2_H_
22
#include "pagespeed/kernel/base/string_util.h"
24
#include "third_party/re2/src/re2/re2.h"
29
const RE2::CannedOptions posix_syntax = RE2::POSIX_SYNTAX;
32
typedef re2::StringPiece Re2StringPiece;
33
// Converts a Google StringPiece into an RE2 StringPiece. These are of course
34
// the same basic thing but are declared in distinct namespaces and as far as
35
// C++ type-checking is concerned they are incompatible.
37
// TODO(jmarantz): In the re2 code itself there are no references to
38
// re2::StringPiece, always just plain StringPiece, so if we can
39
// arrange to get the right definition #included we should be all set.
40
// We could somehow rewrite '#include "re2/stringpiece.h"' to
41
// #include Chromium's stringpiece then everything would just work.
42
inline re2::StringPiece StringPieceToRe2(StringPiece sp) {
43
return re2::StringPiece(sp.data(), sp.size());
46
inline StringPiece Re2ToStringPiece(re2::StringPiece sp) {
47
return StringPiece(sp.data(), sp.size());
51
#endif // PAGESPEED_KERNEL_UTIL_RE2_H_