tesseract 4.1.1
Loading...
Searching...
No Matches
commandlineflags.h
Go to the documentation of this file.
1/**********************************************************************
2 * File: commandlineflags.h
3 * Description: Header file for commandline flag parsing.
4 * Author: Ranjith Unnikrishnan
5 *
6 * (C) Copyright 2013, Google Inc.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 *
17 **********************************************************************/
18#ifndef TESSERACT_TRAINING_COMMANDLINEFLAGS_H_
19#define TESSERACT_TRAINING_COMMANDLINEFLAGS_H_
20
21#ifndef GOOGLE_TESSERACT
22
23#include <cstdlib>
24#include "params.h"
25
26#define INT_PARAM_FLAG(name, val, comment) \
27 INT_VAR(FLAGS_##name, val, comment)
28#define DECLARE_INT_PARAM_FLAG(name) \
29 extern INT_VAR_H(FLAGS_##name, 0, "")
30#define DOUBLE_PARAM_FLAG(name, val, comment) \
31 double_VAR(FLAGS_##name, val, comment)
32#define DECLARE_DOUBLE_PARAM_FLAG(name) \
33 extern double_VAR_H(FLAGS_##name, "", "")
34#define BOOL_PARAM_FLAG(name, val, comment) \
35 BOOL_VAR(FLAGS_##name, val, comment)
36#define DECLARE_BOOL_PARAM_FLAG(name) \
37 extern BOOL_VAR_H(FLAGS_##name, 0, "")
38#define STRING_PARAM_FLAG(name, val, comment) \
39 STRING_VAR(FLAGS_##name, val, comment)
40#define DECLARE_STRING_PARAM_FLAG(name) \
41 extern STRING_VAR_H(FLAGS_##name, "", "")
42
43#else
44
45#include "base/commandlineflags.h"
46#define INT_PARAM_FLAG(name, val, comment) \
47 DEFINE_int32(name, val, comment)
48#define DECLARE_INT_PARAM_FLAG(name) \
49 DECLARE_int32(name)
50#define DOUBLE_PARAM_FLAG(name, val, comment) \
51 DEFINE_double(name, val, comment)
52#define DECLARE_DOUBLE_PARAM_FLAG(name) \
53 DECLARE_double(name)
54#define BOOL_PARAM_FLAG(name, val, comment) \
55 DEFINE_bool(name, val, comment)
56#define DECLARE_BOOL_PARAM_FLAG(name) \
57 DECLARE_bool(name)
58#define STRING_PARAM_FLAG(name, val, comment) \
59 DEFINE_string(name, val, comment)
60#define DECLARE_STRING_PARAM_FLAG(name) \
61 DECLARE_string(name)
62
63#endif
64
65// Flags from commontraining.cpp
66// Command line arguments for font_properties, xheights and unicharset.
74DECLARE_STRING_PARAM_FLAG(fontconfig_tmpdir);
77
78namespace tesseract {
79
80// Parse commandline flags and values. Prints the usage string and exits on
81// input of --help or --version.
82//
83// If remove_flags is true, the argv pointer is advanced so that (*argv)[1]
84// points to the first non-flag argument, (*argv)[0] points to the same string
85// as before, and argc is decremented to reflect the new shorter length of argv.
86// eg. If the input *argv is
87// { "program", "--foo=4", "--bar=true", "file1", "file2" } with *argc = 5, the
88// output *argv is { "program", "file1", "file2" } with *argc = 3
89void ParseCommandLineFlags(const char* usage, int* argc,
90 char*** argv, const bool remove_flags);
91
92}
93
94#endif // TESSERACT_TRAINING_COMMANDLINEFLAGS_H_
#define DECLARE_INT_PARAM_FLAG(name)
#define DECLARE_STRING_PARAM_FLAG(name)
void ParseCommandLineFlags(const char *usage, int *argc, char ***argv, const bool remove_flags)