mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-05 15:57:01 +08:00
Clean up some sloppy include directives
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <string>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <alpr.h>
|
#include <alpr.h>
|
||||||
#include "openalprgo.h"
|
#include "openalprgo.h"
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <string>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <alpr.h>
|
#include <alpr.h>
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
#include "beanstalk.h"
|
#include "beanstalk.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#include "beanstalk.hpp"
|
#include "beanstalk.hpp"
|
||||||
#include <stdexcept>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <stdexcept>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#ifndef OPENALPR_BENCHMARKUTILS_H
|
#ifndef OPENALPR_BENCHMARKUTILS_H
|
||||||
#define OPENALPR_BENCHMARKUTILS_H
|
#define OPENALPR_BENCHMARKUTILS_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
std::vector<std::string> filterByExtension(std::vector<std::string> fileList, std::string extension);
|
std::vector<std::string> filterByExtension(std::vector<std::string> fileList, std::string extension);
|
||||||
|
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
#include "endtoendtest.h"
|
#include "endtoendtest.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace alpr;
|
using namespace alpr;
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
#ifndef OPENALPR_ENDTOENDTEST_H
|
#ifndef OPENALPR_ENDTOENDTEST_H
|
||||||
#define OPENALPR_ENDTOENDTEST_H
|
#define OPENALPR_ENDTOENDTEST_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
|
@@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <vector>
|
||||||
#include "../tclap/CmdLine.h"
|
#include "../tclap/CmdLine.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "support/utf8.h"
|
#include "support/utf8.h"
|
||||||
|
@@ -20,6 +20,8 @@
|
|||||||
#include "alpr.h"
|
#include "alpr.h"
|
||||||
#include "alpr_impl.h"
|
#include "alpr_impl.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -20,10 +20,9 @@
|
|||||||
#ifndef OPENALPR_ALPR_H
|
#ifndef OPENALPR_ALPR_H
|
||||||
#define OPENALPR_ALPR_H
|
#define OPENALPR_ALPR_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
#include <fstream>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define OPENALPR_DLL_EXPORT __declspec( dllexport )
|
#define OPENALPR_DLL_EXPORT __declspec( dllexport )
|
||||||
|
@@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#include "support/filesystem.h"
|
#include "support/filesystem.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include "opencv2/opencv.hpp"
|
#include "opencv2/opencv.hpp"
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
|
@@ -24,11 +24,8 @@
|
|||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <string>
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdlib.h> /* getenv */
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
|
@@ -20,8 +20,8 @@
|
|||||||
#ifndef OPENALPR_REGIONDETECTOR_H
|
#ifndef OPENALPR_REGIONDETECTOR_H
|
||||||
#define OPENALPR_REGIONDETECTOR_H
|
#define OPENALPR_REGIONDETECTOR_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "detectorcpu.h"
|
#include "detectorcpu.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
#ifndef OPENALPR_DETECTORCPU_H
|
#ifndef OPENALPR_DETECTORCPU_H
|
||||||
#define OPENALPR_DETECTORCPU_H
|
#define OPENALPR_DETECTORCPU_H
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "opencv2/objdetect/objdetect.hpp"
|
#include "opencv2/objdetect/objdetect.hpp"
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#define OPENALPR_DETECTORCUDA_H
|
#define OPENALPR_DETECTORCUDA_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef COMPILE_GPU
|
#ifdef COMPILE_GPU
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#ifndef OPENALPR_DETECTORMASK_H
|
#ifndef OPENALPR_DETECTORMASK_H
|
||||||
#define OPENALPR_DETECTORMASK_H
|
#define OPENALPR_DETECTORMASK_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <string>
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "prewarp.h"
|
#include "prewarp.h"
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
#ifndef OPENALPR_DETECTORMORPH_H
|
#ifndef OPENALPR_DETECTORMORPH_H
|
||||||
#define OPENALPR_DETECTORMORPH_H
|
#define OPENALPR_DETECTORMORPH_H
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "opencv2/objdetect/objdetect.hpp"
|
#include "opencv2/objdetect/objdetect.hpp"
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
#ifndef OPENALPR_DETECTOROPENCL_H
|
#ifndef OPENALPR_DETECTOROPENCL_H
|
||||||
#define OPENALPR_DETECTOROPENCL_H
|
#define OPENALPR_DETECTOROPENCL_H
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if OPENCV_MAJOR_VERSION == 3
|
#if OPENCV_MAJOR_VERSION == 3
|
||||||
|
@@ -17,7 +17,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vector>
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "scorekeeper.h"
|
#include "scorekeeper.h"
|
||||||
|
|
||||||
|
@@ -21,8 +21,7 @@
|
|||||||
#define OPENALPR_SCOREKEEPER_H
|
#define OPENALPR_SCOREKEEPER_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <vector>
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
#ifndef OPENALPR_LICENSEPLATECANDIDATE_H
|
#ifndef OPENALPR_LICENSEPLATECANDIDATE_H
|
||||||
#define OPENALPR_LICENSEPLATECANDIDATE_H
|
#define OPENALPR_LICENSEPLATECANDIDATE_H
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
|
@@ -20,9 +20,6 @@
|
|||||||
#ifndef OPENALPR_SEGMENT_H
|
#ifndef OPENALPR_SEGMENT_H
|
||||||
#define OPENALPR_SEGMENT_H
|
#define OPENALPR_SEGMENT_H
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
#define OPENALPR_SEGMENTATIONGROUP_H
|
#define OPENALPR_SEGMENTATIONGROUP_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
|
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
#ifndef OPENALPR_TESSERACTOCR_H
|
#ifndef OPENALPR_TESSERACTOCR_H
|
||||||
#define OPENALPR_TESSERACTOCR_H
|
#define OPENALPR_TESSERACTOCR_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <vector>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "postprocess.h"
|
#include "postprocess.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <queue>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
|
@@ -23,12 +23,9 @@
|
|||||||
#include "regexrule.h"
|
#include "regexrule.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <queue>
|
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "regexrule.h"
|
#include "regexrule.h"
|
||||||
|
@@ -20,10 +20,8 @@
|
|||||||
#ifndef OPENALPR_REGEXRULE_H
|
#ifndef OPENALPR_REGEXRULE_H
|
||||||
#define OPENALPR_REGEXRULE_H
|
#define OPENALPR_REGEXRULE_H
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
|
||||||
#include <vector>
|
|
||||||
#include "support/re2.h"
|
#include "support/re2.h"
|
||||||
#include "support/utf8.h"
|
#include "support/utf8.h"
|
||||||
#include "support/tinythread.h"
|
#include "support/tinythread.h"
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "result_aggregator.h"
|
#include "result_aggregator.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
|
@@ -1,6 +1,11 @@
|
|||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
|
@@ -13,14 +13,10 @@ typedef int mode_t;
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
{
|
{
|
||||||
|
@@ -27,6 +27,29 @@
|
|||||||
#include "util/flags.h"
|
#include "util/flags.h"
|
||||||
#include "util/sparse_set.h"
|
#include "util/sparse_set.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(USE_CXX0X) && !defined(_LIBCPP_ABI_VERSION)
|
||||||
|
|
||||||
|
#include <tr1/unordered_set>
|
||||||
|
using std::tr1::unordered_set;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
#if defined(_WIN32)
|
||||||
|
using std::tr1::unordered_set;
|
||||||
|
#else
|
||||||
|
using std::unordered_set;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using std::swap;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
DEFINE_bool(re2_dfa_bail_when_slow, true,
|
DEFINE_bool(re2_dfa_bail_when_slow, true,
|
||||||
"Whether the RE2 DFA should bail out early "
|
"Whether the RE2 DFA should bail out early "
|
||||||
"if the NFA would be faster (for testing).");
|
"if the NFA would be faster (for testing).");
|
||||||
@@ -168,6 +191,7 @@ class DFA {
|
|||||||
#endif // STL_MSVC
|
#endif // STL_MSVC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef STL_MSVC
|
#ifdef STL_MSVC
|
||||||
typedef unordered_set<State*, StateHash> StateSet;
|
typedef unordered_set<State*, StateHash> StateSet;
|
||||||
#else // !STL_MSVC
|
#else // !STL_MSVC
|
||||||
@@ -711,7 +735,7 @@ DFA::State* DFA::WorkqToCachedState(Workq* q, uint flag) {
|
|||||||
int* markp = ip;
|
int* markp = ip;
|
||||||
while (markp < ep && *markp != Mark)
|
while (markp < ep && *markp != Mark)
|
||||||
markp++;
|
markp++;
|
||||||
sort(ip, markp);
|
std::sort(ip, markp);
|
||||||
if (markp < ep)
|
if (markp < ep)
|
||||||
markp++;
|
markp++;
|
||||||
ip = markp;
|
ip = markp;
|
||||||
|
@@ -29,6 +29,8 @@
|
|||||||
#include "util/sparse_array.h"
|
#include "util/sparse_array.h"
|
||||||
#include "util/sparse_set.h"
|
#include "util/sparse_set.h"
|
||||||
|
|
||||||
|
using std::swap;
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
class NFA {
|
class NFA {
|
||||||
|
@@ -476,8 +476,8 @@ bool Prog::IsOnePass() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ip->foldcase()) {
|
if (ip->foldcase()) {
|
||||||
Rune lo = max<Rune>(ip->lo(), 'a') + 'A' - 'a';
|
Rune lo = std::max<Rune>(ip->lo(), 'a') + 'A' - 'a';
|
||||||
Rune hi = min<Rune>(ip->hi(), 'z') + 'A' - 'a';
|
Rune hi = std::min<Rune>(ip->hi(), 'z') + 'A' - 'a';
|
||||||
for (int c = lo; c <= hi; c++) {
|
for (int c = lo; c <= hi; c++) {
|
||||||
int b = bytemap_[c];
|
int b = bytemap_[c];
|
||||||
c = unbytemap_[b]; // last c in class
|
c = unbytemap_[b]; // last c in class
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
// Regular expression parse state.
|
// Regular expression parse state.
|
||||||
// The list of parsed regexps so far is maintained as a vector of
|
// The list of parsed regexps so far is maintained as a vector of
|
||||||
// Regexp pointers called the stack. Left parenthesis and vertical
|
// Regexp pointers called the stack. Left parenthesis and vertical
|
||||||
@@ -340,7 +342,7 @@ static void AddFoldedRange(CharClassBuilder* cc, Rune lo, Rune hi, int depth) {
|
|||||||
// Add in the result of folding the range lo - f->hi
|
// Add in the result of folding the range lo - f->hi
|
||||||
// and that range's fold, recursively.
|
// and that range's fold, recursively.
|
||||||
Rune lo1 = lo;
|
Rune lo1 = lo;
|
||||||
Rune hi1 = min<Rune>(hi, f->hi);
|
Rune hi1 = std::min<Rune>(hi, f->hi);
|
||||||
switch (f->delta) {
|
switch (f->delta) {
|
||||||
default:
|
default:
|
||||||
lo1 += f->delta;
|
lo1 += f->delta;
|
||||||
|
@@ -8,6 +8,9 @@
|
|||||||
#include "re2/unicode_casefold.h"
|
#include "re2/unicode_casefold.h"
|
||||||
#include "re2/walker-inl.h"
|
#include "re2/walker-inl.h"
|
||||||
|
|
||||||
|
using std::set;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
static const int Trace = false;
|
static const int Trace = false;
|
||||||
|
@@ -9,6 +9,9 @@
|
|||||||
#ifndef RE2_PREFILTER_H_
|
#ifndef RE2_PREFILTER_H_
|
||||||
#define RE2_PREFILTER_H_
|
#define RE2_PREFILTER_H_
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
@@ -32,19 +35,19 @@ class Prefilter {
|
|||||||
~Prefilter();
|
~Prefilter();
|
||||||
|
|
||||||
Op op() { return op_; }
|
Op op() { return op_; }
|
||||||
const string& atom() const { return atom_; }
|
const std::string& atom() const { return atom_; }
|
||||||
void set_unique_id(int id) { unique_id_ = id; }
|
void set_unique_id(int id) { unique_id_ = id; }
|
||||||
int unique_id() const { return unique_id_; }
|
int unique_id() const { return unique_id_; }
|
||||||
|
|
||||||
// The children of the Prefilter node.
|
// The children of the Prefilter node.
|
||||||
vector<Prefilter*>* subs() {
|
std::vector<Prefilter*>* subs() {
|
||||||
CHECK(op_ == AND || op_ == OR);
|
CHECK(op_ == AND || op_ == OR);
|
||||||
return subs_;
|
return subs_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the children vector. Prefilter takes ownership of subs and
|
// Set the children vector. Prefilter takes ownership of subs and
|
||||||
// subs_ will be deleted when Prefilter is deleted.
|
// subs_ will be deleted when Prefilter is deleted.
|
||||||
void set_subs(vector<Prefilter*>* subs) { subs_ = subs; }
|
void set_subs(std::vector<Prefilter*>* subs) { subs_ = subs; }
|
||||||
|
|
||||||
// Given a RE2, return a Prefilter. The caller takes ownership of
|
// Given a RE2, return a Prefilter. The caller takes ownership of
|
||||||
// the Prefilter and should deallocate it. Returns NULL if Prefilter
|
// the Prefilter and should deallocate it. Returns NULL if Prefilter
|
||||||
@@ -52,7 +55,7 @@ class Prefilter {
|
|||||||
static Prefilter* FromRE2(const RE2* re2);
|
static Prefilter* FromRE2(const RE2* re2);
|
||||||
|
|
||||||
// Returns a readable debug string of the prefilter.
|
// Returns a readable debug string of the prefilter.
|
||||||
string DebugString() const;
|
std::string DebugString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Info;
|
class Info;
|
||||||
@@ -70,9 +73,9 @@ class Prefilter {
|
|||||||
|
|
||||||
static Prefilter* FromRegexp(Regexp* a);
|
static Prefilter* FromRegexp(Regexp* a);
|
||||||
|
|
||||||
static Prefilter* FromString(const string& str);
|
static Prefilter* FromString(const std::string& str);
|
||||||
|
|
||||||
static Prefilter* OrStrings(set<string>* ss);
|
static Prefilter* OrStrings(std::set<std::string>* ss);
|
||||||
|
|
||||||
static Info* BuildInfo(Regexp* re);
|
static Info* BuildInfo(Regexp* re);
|
||||||
|
|
||||||
@@ -82,10 +85,10 @@ class Prefilter {
|
|||||||
Op op_;
|
Op op_;
|
||||||
|
|
||||||
// Sub-matches for AND or OR Prefilter.
|
// Sub-matches for AND or OR Prefilter.
|
||||||
vector<Prefilter*>* subs_;
|
std::vector<Prefilter*>* subs_;
|
||||||
|
|
||||||
// Actual string to match in leaf node.
|
// Actual string to match in leaf node.
|
||||||
string atom_;
|
std::string atom_;
|
||||||
|
|
||||||
// If different prefilters have the same string atom, or if they are
|
// If different prefilters have the same string atom, or if they are
|
||||||
// structurally the same (e.g., OR of same atom strings) they are
|
// structurally the same (e.g., OR of same atom strings) they are
|
||||||
|
@@ -8,6 +8,10 @@
|
|||||||
#include "re2/prefilter_tree.h"
|
#include "re2/prefilter_tree.h"
|
||||||
#include "re2.h"
|
#include "re2.h"
|
||||||
|
|
||||||
|
using std::set;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
DEFINE_int32(filtered_re2_min_atom_len,
|
DEFINE_int32(filtered_re2_min_atom_len,
|
||||||
3,
|
3,
|
||||||
"Strings less than this length are not stored as atoms");
|
"Strings less than this length are not stored as atoms");
|
||||||
|
@@ -16,13 +16,16 @@
|
|||||||
#ifndef RE2_PREFILTER_TREE_H_
|
#ifndef RE2_PREFILTER_TREE_H_
|
||||||
#define RE2_PREFILTER_TREE_H_
|
#define RE2_PREFILTER_TREE_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
#include "util/sparse_array.h"
|
#include "util/sparse_array.h"
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
typedef SparseArray<int> IntMap;
|
typedef SparseArray<int> IntMap;
|
||||||
typedef map<int, int> StdIntMap;
|
typedef std::map<int, int> StdIntMap;
|
||||||
|
|
||||||
class Prefilter;
|
class Prefilter;
|
||||||
|
|
||||||
@@ -42,15 +45,15 @@ class PrefilterTree {
|
|||||||
// The caller should use the returned set of strings to do string matching.
|
// The caller should use the returned set of strings to do string matching.
|
||||||
// Each time a string matches, the corresponding index then has to be
|
// Each time a string matches, the corresponding index then has to be
|
||||||
// and passed to RegexpsGivenStrings below.
|
// and passed to RegexpsGivenStrings below.
|
||||||
void Compile(vector<string>* atom_vec);
|
void Compile(std::vector<std::string>* atom_vec);
|
||||||
|
|
||||||
// Given the indices of the atoms that matched, returns the indexes
|
// Given the indices of the atoms that matched, returns the indexes
|
||||||
// of regexps that should be searched. The matched_atoms should
|
// of regexps that should be searched. The matched_atoms should
|
||||||
// contain all the ids of string atoms that were found to match the
|
// contain all the ids of string atoms that were found to match the
|
||||||
// content. The caller can use any string match engine to perform
|
// content. The caller can use any string match engine to perform
|
||||||
// this function. This function is thread safe.
|
// this function. This function is thread safe.
|
||||||
void RegexpsGivenStrings(const vector<int>& matched_atoms,
|
void RegexpsGivenStrings(const std::vector<int>& matched_atoms,
|
||||||
vector<int>* regexps) const;
|
std::vector<int>* regexps) const;
|
||||||
|
|
||||||
// Print debug prefilter. Also prints unique ids associated with
|
// Print debug prefilter. Also prints unique ids associated with
|
||||||
// nodes of the prefilter of the regexp.
|
// nodes of the prefilter of the regexp.
|
||||||
@@ -76,17 +79,17 @@ class PrefilterTree {
|
|||||||
|
|
||||||
// When this node is ready to trigger the parent, what are the
|
// When this node is ready to trigger the parent, what are the
|
||||||
// regexps that are triggered.
|
// regexps that are triggered.
|
||||||
vector<int> regexps;
|
std::vector<int> regexps;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This function assigns unique ids to various parts of the
|
// This function assigns unique ids to various parts of the
|
||||||
// prefilter, by looking at if these nodes are already in the
|
// prefilter, by looking at if these nodes are already in the
|
||||||
// PrefilterTree.
|
// PrefilterTree.
|
||||||
void AssignUniqueIds(vector<string>* atom_vec);
|
void AssignUniqueIds(std::vector<std::string>* atom_vec);
|
||||||
|
|
||||||
// Given the matching atoms, find the regexps to be triggered.
|
// Given the matching atoms, find the regexps to be triggered.
|
||||||
void PropagateMatch(const vector<int>& atom_ids,
|
void PropagateMatch(const std::vector<int>& atom_ids,
|
||||||
IntMap* regexps) const;
|
IntMap* regexps) const;
|
||||||
|
|
||||||
// Returns the prefilter node that has the same NodeString as this
|
// Returns the prefilter node that has the same NodeString as this
|
||||||
@@ -95,30 +98,30 @@ class PrefilterTree {
|
|||||||
|
|
||||||
// A string that uniquely identifies the node. Assumes that the
|
// A string that uniquely identifies the node. Assumes that the
|
||||||
// children of node has already been assigned unique ids.
|
// children of node has already been assigned unique ids.
|
||||||
string NodeString(Prefilter* node) const;
|
std::string NodeString(Prefilter* node) const;
|
||||||
|
|
||||||
// Recursively constructs a readable prefilter string.
|
// Recursively constructs a readable prefilter string.
|
||||||
string DebugNodeString(Prefilter* node) const;
|
std::string DebugNodeString(Prefilter* node) const;
|
||||||
|
|
||||||
// Used for debugging.
|
// Used for debugging.
|
||||||
void PrintDebugInfo();
|
void PrintDebugInfo();
|
||||||
|
|
||||||
// These are all the nodes formed by Compile. Essentially, there is
|
// These are all the nodes formed by Compile. Essentially, there is
|
||||||
// one node for each unique atom and each unique AND/OR node.
|
// one node for each unique atom and each unique AND/OR node.
|
||||||
vector<Entry> entries_;
|
std::vector<Entry> entries_;
|
||||||
|
|
||||||
// Map node string to canonical Prefilter node.
|
// Map node string to canonical Prefilter node.
|
||||||
map<string, Prefilter*> node_map_;
|
std::map<std::string, Prefilter*> node_map_;
|
||||||
|
|
||||||
// indices of regexps that always pass through the filter (since we
|
// indices of regexps that always pass through the filter (since we
|
||||||
// found no required literals in these regexps).
|
// found no required literals in these regexps).
|
||||||
vector<int> unfiltered_;
|
std::vector<int> unfiltered_;
|
||||||
|
|
||||||
// vector of Prefilter for all regexps.
|
// vector of Prefilter for all regexps.
|
||||||
vector<Prefilter*> prefilter_vec_;
|
std::vector<Prefilter*> prefilter_vec_;
|
||||||
|
|
||||||
// Atom index in returned strings to entry id mapping.
|
// Atom index in returned strings to entry id mapping.
|
||||||
vector<int> atom_index_to_id_;
|
std::vector<int> atom_index_to_id_;
|
||||||
|
|
||||||
// Has the prefilter tree been compiled.
|
// Has the prefilter tree been compiled.
|
||||||
bool compiled_;
|
bool compiled_;
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
#include "re2/util/sparse_array.h"
|
#include "re2/util/sparse_array.h"
|
||||||
#include "re2.h"
|
#include "re2.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
// Simple fixed-size bitmap.
|
// Simple fixed-size bitmap.
|
||||||
@@ -273,7 +275,7 @@ class Prog {
|
|||||||
bool SearchDFA(const StringPiece& text, const StringPiece& context,
|
bool SearchDFA(const StringPiece& text, const StringPiece& context,
|
||||||
Anchor anchor, MatchKind kind,
|
Anchor anchor, MatchKind kind,
|
||||||
StringPiece* match0, bool* failed,
|
StringPiece* match0, bool* failed,
|
||||||
vector<int>* matches);
|
std::vector<int>* matches);
|
||||||
|
|
||||||
// Build the entire DFA for the given match kind. FOR TESTING ONLY.
|
// Build the entire DFA for the given match kind. FOR TESTING ONLY.
|
||||||
// Usually the DFA is built out incrementally, as needed, which
|
// Usually the DFA is built out incrementally, as needed, which
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "re2.h"
|
#include "re2.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@@ -5,11 +5,17 @@
|
|||||||
// Regular expression representation.
|
// Regular expression representation.
|
||||||
// Tested by parse_test.cc
|
// Tested by parse_test.cc
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
#include "re2/regexp.h"
|
#include "re2/regexp.h"
|
||||||
#include "re2/stringpiece.h"
|
#include "re2/stringpiece.h"
|
||||||
#include "re2/walker-inl.h"
|
#include "re2/walker-inl.h"
|
||||||
|
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
// Constructor. Allocates vectors as appropriate for operator.
|
// Constructor. Allocates vectors as appropriate for operator.
|
||||||
@@ -712,13 +718,13 @@ bool CharClassBuilder::AddRange(Rune lo, Rune hi) {
|
|||||||
if (lo <= 'z' && hi >= 'A') {
|
if (lo <= 'z' && hi >= 'A') {
|
||||||
// Overlaps some alpha, maybe not all.
|
// Overlaps some alpha, maybe not all.
|
||||||
// Update bitmaps telling which ASCII letters are in the set.
|
// Update bitmaps telling which ASCII letters are in the set.
|
||||||
Rune lo1 = max<Rune>(lo, 'A');
|
Rune lo1 = std::max<Rune>(lo, 'A');
|
||||||
Rune hi1 = min<Rune>(hi, 'Z');
|
Rune hi1 = std::min<Rune>(hi, 'Z');
|
||||||
if (lo1 <= hi1)
|
if (lo1 <= hi1)
|
||||||
upper_ |= ((1 << (hi1 - lo1 + 1)) - 1) << (lo1 - 'A');
|
upper_ |= ((1 << (hi1 - lo1 + 1)) - 1) << (lo1 - 'A');
|
||||||
|
|
||||||
lo1 = max<Rune>(lo, 'a');
|
lo1 = std::max<Rune>(lo, 'a');
|
||||||
hi1 = min<Rune>(hi, 'z');
|
hi1 = std::min<Rune>(hi, 'z');
|
||||||
if (lo1 <= hi1)
|
if (lo1 <= hi1)
|
||||||
lower_ |= ((1 << (hi1 - lo1 + 1)) - 1) << (lo1 - 'a');
|
lower_ |= ((1 << (hi1 - lo1 + 1)) - 1) << (lo1 - 'a');
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,9 @@
|
|||||||
#ifndef RE2_REGEXP_H__
|
#ifndef RE2_REGEXP_H__
|
||||||
#define RE2_REGEXP_H__
|
#define RE2_REGEXP_H__
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
#include "re2/stringpiece.h"
|
#include "re2/stringpiece.h"
|
||||||
|
|
||||||
@@ -187,7 +190,7 @@ class RegexpStatus {
|
|||||||
|
|
||||||
void set_code(enum RegexpStatusCode code) { code_ = code; }
|
void set_code(enum RegexpStatusCode code) { code_ = code; }
|
||||||
void set_error_arg(const StringPiece& error_arg) { error_arg_ = error_arg; }
|
void set_error_arg(const StringPiece& error_arg) { error_arg_ = error_arg; }
|
||||||
void set_tmp(string* tmp) { delete tmp_; tmp_ = tmp; }
|
void set_tmp(std::string* tmp) { delete tmp_; tmp_ = tmp; }
|
||||||
enum RegexpStatusCode code() const { return code_; }
|
enum RegexpStatusCode code() const { return code_; }
|
||||||
const StringPiece& error_arg() const { return error_arg_; }
|
const StringPiece& error_arg() const { return error_arg_; }
|
||||||
bool ok() const { return code() == kRegexpSuccess; }
|
bool ok() const { return code() == kRegexpSuccess; }
|
||||||
@@ -197,16 +200,16 @@ class RegexpStatus {
|
|||||||
|
|
||||||
// Returns text equivalent of code, e.g.:
|
// Returns text equivalent of code, e.g.:
|
||||||
// "Bad character class"
|
// "Bad character class"
|
||||||
static string CodeText(enum RegexpStatusCode code);
|
static std::string CodeText(enum RegexpStatusCode code);
|
||||||
|
|
||||||
// Returns text describing error, e.g.:
|
// Returns text describing error, e.g.:
|
||||||
// "Bad character class: [z-a]"
|
// "Bad character class: [z-a]"
|
||||||
string Text() const;
|
std::string Text() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum RegexpStatusCode code_; // Kind of error
|
enum RegexpStatusCode code_; // Kind of error
|
||||||
StringPiece error_arg_; // Piece of regexp containing syntax error.
|
StringPiece error_arg_; // Piece of regexp containing syntax error.
|
||||||
string* tmp_; // Temporary storage, possibly where error_arg_ is.
|
std::string* tmp_; // Temporary storage, possibly where error_arg_ is.
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RegexpStatus);
|
DISALLOW_COPY_AND_ASSIGN(RegexpStatus);
|
||||||
};
|
};
|
||||||
@@ -328,7 +331,7 @@ class Regexp {
|
|||||||
Rune rune() { DCHECK_EQ(op_, kRegexpLiteral); return rune_; }
|
Rune rune() { DCHECK_EQ(op_, kRegexpLiteral); return rune_; }
|
||||||
CharClass* cc() { DCHECK_EQ(op_, kRegexpCharClass); return cc_; }
|
CharClass* cc() { DCHECK_EQ(op_, kRegexpCharClass); return cc_; }
|
||||||
int cap() { DCHECK_EQ(op_, kRegexpCapture); return cap_; }
|
int cap() { DCHECK_EQ(op_, kRegexpCapture); return cap_; }
|
||||||
const string* name() { DCHECK_EQ(op_, kRegexpCapture); return name_; }
|
const std::string* name() { DCHECK_EQ(op_, kRegexpCapture); return name_; }
|
||||||
Rune* runes() { DCHECK_EQ(op_, kRegexpLiteralString); return runes_; }
|
Rune* runes() { DCHECK_EQ(op_, kRegexpLiteralString); return runes_; }
|
||||||
int nrunes() { DCHECK_EQ(op_, kRegexpLiteralString); return nrunes_; }
|
int nrunes() { DCHECK_EQ(op_, kRegexpLiteralString); return nrunes_; }
|
||||||
int match_id() { DCHECK_EQ(op_, kRegexpHaveMatch); return match_id_; }
|
int match_id() { DCHECK_EQ(op_, kRegexpHaveMatch); return match_id_; }
|
||||||
@@ -359,7 +362,7 @@ class Regexp {
|
|||||||
// string representation of the simplified form. Returns true on success.
|
// string representation of the simplified form. Returns true on success.
|
||||||
// Returns false and sets *status (if status != NULL) on parse error.
|
// Returns false and sets *status (if status != NULL) on parse error.
|
||||||
static bool SimplifyRegexp(const StringPiece& src, ParseFlags flags,
|
static bool SimplifyRegexp(const StringPiece& src, ParseFlags flags,
|
||||||
string* dst,
|
std::string* dst,
|
||||||
RegexpStatus* status);
|
RegexpStatus* status);
|
||||||
|
|
||||||
// Returns the number of capturing groups in the regexp.
|
// Returns the number of capturing groups in the regexp.
|
||||||
@@ -369,16 +372,16 @@ class Regexp {
|
|||||||
// Returns a map from names to capturing group indices,
|
// Returns a map from names to capturing group indices,
|
||||||
// or NULL if the regexp contains no named capture groups.
|
// or NULL if the regexp contains no named capture groups.
|
||||||
// The caller is responsible for deleting the map.
|
// The caller is responsible for deleting the map.
|
||||||
map<string, int>* NamedCaptures();
|
std::map<std::string, int>* NamedCaptures();
|
||||||
|
|
||||||
// Returns a map from capturing group indices to capturing group
|
// Returns a map from capturing group indices to capturing group
|
||||||
// names or NULL if the regexp contains no named capture groups. The
|
// names or NULL if the regexp contains no named capture groups. The
|
||||||
// caller is responsible for deleting the map.
|
// caller is responsible for deleting the map.
|
||||||
map<int, string>* CaptureNames();
|
std::map<int, std::string>* CaptureNames();
|
||||||
|
|
||||||
// Returns a string representation of the current regexp,
|
// Returns a string representation of the current regexp,
|
||||||
// using as few parentheses as possible.
|
// using as few parentheses as possible.
|
||||||
string ToString();
|
std::string ToString();
|
||||||
|
|
||||||
// Convenience functions. They consume the passed reference,
|
// Convenience functions. They consume the passed reference,
|
||||||
// so in many cases you should use, e.g., Plus(re->Incref(), flags).
|
// so in many cases you should use, e.g., Plus(re->Incref(), flags).
|
||||||
@@ -400,7 +403,7 @@ class Regexp {
|
|||||||
|
|
||||||
// Debugging function. Returns string format for regexp
|
// Debugging function. Returns string format for regexp
|
||||||
// that makes structure clear. Does NOT use regexp syntax.
|
// that makes structure clear. Does NOT use regexp syntax.
|
||||||
string Dump();
|
std::string Dump();
|
||||||
|
|
||||||
// Helper traversal class, defined fully in walker-inl.h.
|
// Helper traversal class, defined fully in walker-inl.h.
|
||||||
template<typename T> class Walker;
|
template<typename T> class Walker;
|
||||||
@@ -427,7 +430,7 @@ class Regexp {
|
|||||||
// begin with a non-empty fixed string (perhaps after ASCII
|
// begin with a non-empty fixed string (perhaps after ASCII
|
||||||
// case-folding). If so, returns the prefix and the sub-regexp that
|
// case-folding). If so, returns the prefix and the sub-regexp that
|
||||||
// follows it.
|
// follows it.
|
||||||
bool RequiredPrefix(string* prefix, bool *foldcase, Regexp** suffix);
|
bool RequiredPrefix(std::string* prefix, bool *foldcase, Regexp** suffix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constructor allocates vectors as appropriate for operator.
|
// Constructor allocates vectors as appropriate for operator.
|
||||||
@@ -550,7 +553,7 @@ class Regexp {
|
|||||||
};
|
};
|
||||||
struct { // Capture
|
struct { // Capture
|
||||||
int cap_;
|
int cap_;
|
||||||
string* name_;
|
std::string* name_;
|
||||||
};
|
};
|
||||||
struct { // LiteralString
|
struct { // LiteralString
|
||||||
int nrunes_;
|
int nrunes_;
|
||||||
@@ -572,7 +575,7 @@ class Regexp {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Character class set: contains non-overlapping, non-abutting RuneRanges.
|
// Character class set: contains non-overlapping, non-abutting RuneRanges.
|
||||||
typedef set<RuneRange, RuneRangeLess> RuneRangeSet;
|
typedef std::set<RuneRange, RuneRangeLess> RuneRangeSet;
|
||||||
|
|
||||||
class CharClassBuilder {
|
class CharClassBuilder {
|
||||||
public:
|
public:
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
// Parses the regexp src and then simplifies it and sets *dst to the
|
// Parses the regexp src and then simplifies it and sets *dst to the
|
||||||
// string representation of the simplified form. Returns true on success.
|
// string representation of the simplified form. Returns true on success.
|
||||||
// Returns false and sets *error (if error != NULL) on error.
|
// Returns false and sets *error (if error != NULL) on error.
|
||||||
|
@@ -2,9 +2,12 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "re2/stringpiece.h"
|
#include "re2/stringpiece.h"
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
using re2::StringPiece;
|
using re2::StringPiece;
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& o, const StringPiece& piece) {
|
std::ostream& operator<<(std::ostream& o, const StringPiece& piece) {
|
||||||
@@ -34,7 +37,7 @@ void StringPiece::CopyToString(string* target) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int StringPiece::copy(char* buf, size_type n, size_type pos) const {
|
int StringPiece::copy(char* buf, size_type n, size_type pos) const {
|
||||||
int ret = min(length_ - pos, n);
|
int ret = std::min(length_ - pos, n);
|
||||||
memcpy(buf, ptr_ + pos, ret);
|
memcpy(buf, ptr_ + pos, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -64,16 +67,16 @@ int StringPiece::find(char c, size_type pos) const {
|
|||||||
int StringPiece::rfind(const StringPiece& s, size_type pos) const {
|
int StringPiece::rfind(const StringPiece& s, size_type pos) const {
|
||||||
if (length_ < s.length_) return npos;
|
if (length_ < s.length_) return npos;
|
||||||
const size_t ulen = length_;
|
const size_t ulen = length_;
|
||||||
if (s.length_ == 0) return min(ulen, pos);
|
if (s.length_ == 0) return std::min(ulen, pos);
|
||||||
|
|
||||||
const char* last = ptr_ + min(ulen - s.length_, pos) + s.length_;
|
const char* last = ptr_ + std::min(ulen - s.length_, pos) + s.length_;
|
||||||
const char* result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_);
|
const char* result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_);
|
||||||
return result != last ? result - ptr_ : npos;
|
return result != last ? result - ptr_ : npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StringPiece::rfind(char c, size_type pos) const {
|
int StringPiece::rfind(char c, size_type pos) const {
|
||||||
if (length_ <= 0) return npos;
|
if (length_ <= 0) return npos;
|
||||||
for (int i = min(pos, static_cast<size_type>(length_ - 1));
|
for (int i = std::min(pos, static_cast<size_type>(length_ - 1));
|
||||||
i >= 0; --i) {
|
i >= 0; --i) {
|
||||||
if (ptr_[i] == c) {
|
if (ptr_[i] == c) {
|
||||||
return i;
|
return i;
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
#include "re2/regexp.h"
|
#include "re2/regexp.h"
|
||||||
#include "re2/walker-inl.h"
|
#include "re2/walker-inl.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@@ -7,7 +7,11 @@
|
|||||||
#ifndef RE2_UTIL_LOGGING_H__
|
#ifndef RE2_UTIL_LOGGING_H__
|
||||||
#define RE2_UTIL_LOGGING_H__
|
#define RE2_UTIL_LOGGING_H__
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ostream>
|
||||||
#include <stdio.h> /* for fwrite */
|
#include <stdio.h> /* for fwrite */
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Debug-only checking.
|
// Debug-only checking.
|
||||||
@@ -53,7 +57,7 @@ class LogMessage {
|
|||||||
}
|
}
|
||||||
void Flush() {
|
void Flush() {
|
||||||
stream() << "\n";
|
stream() << "\n";
|
||||||
string s = str_.str();
|
std::string s = str_.str();
|
||||||
size_t n = s.size();
|
size_t n = s.size();
|
||||||
if (fwrite(s.data(), 1, n, stderr) < n) {} // shut up gcc
|
if (fwrite(s.data(), 1, n, stderr) < n) {} // shut up gcc
|
||||||
flushed_ = true;
|
flushed_ = true;
|
||||||
@@ -63,7 +67,7 @@ class LogMessage {
|
|||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ostream& stream() { return str_; }
|
std::ostream& stream() { return str_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool flushed_;
|
bool flushed_;
|
||||||
|
@@ -94,6 +94,10 @@
|
|||||||
|
|
||||||
#include "re2/util/util.h"
|
#include "re2/util/util.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
@@ -107,8 +111,8 @@ class SparseArray {
|
|||||||
class IndexValue;
|
class IndexValue;
|
||||||
|
|
||||||
typedef IndexValue value_type;
|
typedef IndexValue value_type;
|
||||||
typedef typename vector<IndexValue>::iterator iterator;
|
typedef typename std::vector<IndexValue>::iterator iterator;
|
||||||
typedef typename vector<IndexValue>::const_iterator const_iterator;
|
typedef typename std::vector<IndexValue>::const_iterator const_iterator;
|
||||||
|
|
||||||
inline const IndexValue& iv(int i) const;
|
inline const IndexValue& iv(int i) const;
|
||||||
|
|
||||||
@@ -160,7 +164,7 @@ class SparseArray {
|
|||||||
// Set the value at index i to v.
|
// Set the value at index i to v.
|
||||||
inline iterator set(int i, Value v);
|
inline iterator set(int i, Value v);
|
||||||
|
|
||||||
pair<iterator, bool> insert(const value_type& new_value);
|
std::pair<iterator, bool> insert(const value_type& new_value);
|
||||||
|
|
||||||
// Returns the value at index i
|
// Returns the value at index i
|
||||||
// or defaultv if index i is not initialized in the array.
|
// or defaultv if index i is not initialized in the array.
|
||||||
@@ -223,7 +227,7 @@ class SparseArray {
|
|||||||
int size_;
|
int size_;
|
||||||
int max_size_;
|
int max_size_;
|
||||||
int* sparse_to_dense_;
|
int* sparse_to_dense_;
|
||||||
vector<IndexValue> dense_;
|
std::vector<IndexValue> dense_;
|
||||||
bool valgrind_;
|
bool valgrind_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(SparseArray);
|
DISALLOW_COPY_AND_ASSIGN(SparseArray);
|
||||||
@@ -318,14 +322,14 @@ typename SparseArray<Value>::iterator SparseArray<Value>::set(int i, Value v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
pair<typename SparseArray<Value>::iterator, bool> SparseArray<Value>::insert(
|
std::pair<typename SparseArray<Value>::iterator, bool> SparseArray<Value>::insert(
|
||||||
const value_type& new_value) {
|
const value_type& new_value) {
|
||||||
DebugCheckInvariants();
|
DebugCheckInvariants();
|
||||||
pair<typename SparseArray<Value>::iterator, bool> p;
|
std::pair<typename SparseArray<Value>::iterator, bool> p;
|
||||||
if (has_index(new_value.index_)) {
|
if (has_index(new_value.index_)) {
|
||||||
p = make_pair(dense_.begin() + sparse_to_dense_[new_value.index_], false);
|
p = std::make_pair(dense_.begin() + sparse_to_dense_[new_value.index_], false);
|
||||||
} else {
|
} else {
|
||||||
p = make_pair(set_new(new_value.index_, new_value.second), true);
|
p = std::make_pair(set_new(new_value.index_, new_value.second), true);
|
||||||
}
|
}
|
||||||
DebugCheckInvariants();
|
DebugCheckInvariants();
|
||||||
return p;
|
return p;
|
||||||
|
@@ -49,6 +49,8 @@
|
|||||||
|
|
||||||
#include "re2/util/util.h"
|
#include "re2/util/util.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
static bool InitMemory() {
|
static bool InitMemory() {
|
||||||
|
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
#include "re2/util/util.h"
|
#include "re2/util/util.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
static void StringAppendV(string* dst, const char* format, va_list ap) {
|
static void StringAppendV(string* dst, const char* format, va_list ap) {
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// CEscapeString()
|
// CEscapeString()
|
||||||
// Copies 'src' to 'dest', escaping dangerous characters using
|
// Copies 'src' to 'dest', escaping dangerous characters using
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
#ifndef RE2_UTIL_UTF_H__
|
#ifndef RE2_UTIL_UTF_H__
|
||||||
#define RE2_UTIL_UTF_H__
|
#define RE2_UTIL_UTF_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
|
|
||||||
|
@@ -6,60 +6,15 @@
|
|||||||
#define RE2_UTIL_UTIL_H__
|
#define RE2_UTIL_UTIL_H__
|
||||||
|
|
||||||
// C
|
// C
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h> // For size_t
|
#include <stddef.h> // For size_t
|
||||||
#include <assert.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <time.h> // For clock_gettime, CLOCK_REALTIME
|
|
||||||
#include <ctype.h> // For isdigit, isalpha
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
#include <sys/time.h> // For gettimeofday
|
#include <sys/time.h> // For gettimeofday
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
#include <ctime>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <map>
|
|
||||||
#include <stack>
|
|
||||||
#include <ostream>
|
|
||||||
#include <utility>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
// Use std names.
|
|
||||||
using std::set;
|
|
||||||
using std::pair;
|
|
||||||
using std::vector;
|
|
||||||
using std::string;
|
|
||||||
using std::min;
|
|
||||||
using std::max;
|
|
||||||
using std::ostream;
|
|
||||||
using std::map;
|
|
||||||
using std::stack;
|
|
||||||
using std::sort;
|
|
||||||
using std::swap;
|
|
||||||
using std::make_pair;
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(USE_CXX0X) && !defined(_LIBCPP_ABI_VERSION)
|
|
||||||
|
|
||||||
#include <tr1/unordered_set>
|
|
||||||
using std::tr1::unordered_set;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
#if defined(_WIN32)
|
|
||||||
using std::tr1::unordered_set;
|
|
||||||
#else
|
|
||||||
using std::unordered_set;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
@@ -120,13 +75,13 @@ template<bool> struct CompileAssert {};
|
|||||||
|
|
||||||
class StringPiece;
|
class StringPiece;
|
||||||
|
|
||||||
string CEscape(const StringPiece& src);
|
std::string CEscape(const StringPiece& src);
|
||||||
int CEscapeString(const char* src, int src_len, char* dest, int dest_len);
|
int CEscapeString(const char* src, int src_len, char* dest, int dest_len);
|
||||||
|
|
||||||
extern string StringPrintf(const char* format, ...);
|
extern std::string StringPrintf(const char* format, ...);
|
||||||
extern void SStringPrintf(string* dst, const char* format, ...);
|
extern void SStringPrintf(std::string* dst, const char* format, ...);
|
||||||
extern void StringAppendF(string* dst, const char* format, ...);
|
extern void StringAppendF(std::string* dst, const char* format, ...);
|
||||||
extern string PrefixSuccessor(const StringPiece& prefix);
|
extern std::string PrefixSuccessor(const StringPiece& prefix);
|
||||||
|
|
||||||
uint32 hashword(const uint32*, size_t, uint32);
|
uint32 hashword(const uint32*, size_t, uint32);
|
||||||
void hashword2(const uint32*, size_t, uint32*, uint32*);
|
void hashword2(const uint32*, size_t, uint32*, uint32*);
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
#ifndef RE2_WALKER_INL_H__
|
#ifndef RE2_WALKER_INL_H__
|
||||||
#define RE2_WALKER_INL_H__
|
#define RE2_WALKER_INL_H__
|
||||||
|
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
#include "re2/regexp.h"
|
#include "re2/regexp.h"
|
||||||
|
|
||||||
namespace re2 {
|
namespace re2 {
|
||||||
@@ -86,7 +88,7 @@ template<typename T> class Regexp::Walker {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Walk state for the entire traversal.
|
// Walk state for the entire traversal.
|
||||||
stack<WalkState<T> >* stack_;
|
std::stack<WalkState<T> >* stack_;
|
||||||
bool stopped_early_;
|
bool stopped_early_;
|
||||||
int max_visits_;
|
int max_visits_;
|
||||||
|
|
||||||
@@ -130,7 +132,7 @@ template<typename T> struct WalkState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> Regexp::Walker<T>::Walker() {
|
template<typename T> Regexp::Walker<T>::Walker() {
|
||||||
stack_ = new stack<WalkState<T> >;
|
stack_ = new std::stack<WalkState<T> >;
|
||||||
stopped_early_ = false;
|
stopped_early_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <iostream>
|
|
||||||
int cmpVersion(const char *v1, const char *v2)
|
int cmpVersion(const char *v1, const char *v2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
#ifndef OPENALPR_VERSION_H
|
#ifndef OPENALPR_VERSION_H
|
||||||
#define OPENALPR_VERSION_H
|
#define OPENALPR_VERSION_H
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return 1 if v1 > v2
|
* return 1 if v1 > v2
|
||||||
* return 0 if v1 = v2
|
* return 0 if v1 = v2
|
||||||
|
@@ -20,9 +20,8 @@
|
|||||||
#ifndef OPENALPR_UTILITY_H
|
#ifndef OPENALPR_UTILITY_H
|
||||||
#define OPENALPR_UTILITY_H
|
#define OPENALPR_UTILITY_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <vector>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "support/timing.h"
|
#include "support/timing.h"
|
||||||
@@ -30,7 +29,6 @@
|
|||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "binarize_wolf.h"
|
#include "binarize_wolf.h"
|
||||||
#include <vector>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
namespace alpr
|
namespace alpr
|
||||||
|
@@ -34,9 +34,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#if defined(HAVE_SSTREAM)
|
#if defined(HAVE_SSTREAM)
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@@ -43,8 +43,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdlib.h> // Needed for exit(), which isn't defined in some envs.
|
#include <stdlib.h> // Needed for exit(), which isn't defined in some envs.
|
||||||
|
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,8 +26,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace TCLAP
|
namespace TCLAP
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace TCLAP
|
namespace TCLAP
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace TCLAP
|
namespace TCLAP
|
||||||
{
|
{
|
||||||
|
@@ -2,8 +2,10 @@
|
|||||||
#define OPENALPR_VIDEOBUFFER_H
|
#define OPENALPR_VIDEOBUFFER_H
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user