1// Copyright (C) 2014 Google Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14// 15// Work-around for problems with the RE2 library. Must be the first #include 16// statement in the compilation unit. Do not #include in other header files. 17 18#ifndef I18N_ADDRESSINPUT_UTIL_RE2PTR_H_ 19#define I18N_ADDRESSINPUT_UTIL_RE2PTR_H_ 20 21// RE2 will, in some environments, define class RE2 inside namespace re2 and 22// then have a public "using re2::RE2;" statement to bring that definition into 23// the root namespace, while in other environments it will define class RE2 24// directly in the root namespace. 25// 26// Because of that, it's impossible to write a portable forward declaration of 27// class RE2. 28// 29// The work-around in this file works by wrapping pointers to RE2 object in the 30// simple struct RE2ptr, which is trivial to forward declare. 31 32#include <re2/re2.h> 33 34namespace i18n { 35namespace addressinput { 36 37struct RE2ptr { 38 RE2ptr(RE2* init_ptr) : ptr(init_ptr) {} 39 ~RE2ptr() { delete ptr; } 40 RE2* const ptr; 41}; 42 43} // namespace addressinput 44} // namespace i18n 45 46#endif // I18N_ADDRESSINPUT_UTIL_RE2PTR_H_ 47