tesseract v5.3.3.20231005
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#include "export.h"
22#include "params.h"
23
24#include <cstdlib>
25
26#define INT_PARAM_FLAG(name, val, comment) INT_VAR(FLAGS_##name, val, comment)
27#define DECLARE_INT_PARAM_FLAG(name) extern INT_VAR_H(FLAGS_##name)
28#define DOUBLE_PARAM_FLAG(name, val, comment) double_VAR(FLAGS_##name, val, comment)
29#define DECLARE_DOUBLE_PARAM_FLAG(name) extern double_VAR_H(FLAGS_##name)
30#define BOOL_PARAM_FLAG(name, val, comment) BOOL_VAR(FLAGS_##name, val, comment)
31#define DECLARE_BOOL_PARAM_FLAG(name) extern BOOL_VAR_H(FLAGS_##name)
32#define STRING_PARAM_FLAG(name, val, comment) STRING_VAR(FLAGS_##name, val, comment)
33#define DECLARE_STRING_PARAM_FLAG(name) extern STRING_VAR_H(FLAGS_##name)
34
35namespace tesseract {
36
37// Flags from commontraining.cpp
38// Command line arguments for font_properties, xheights and unicharset.
39TESS_COMMON_TRAINING_API
41TESS_COMMON_TRAINING_API
43TESS_COMMON_TRAINING_API
45TESS_COMMON_TRAINING_API
47TESS_COMMON_TRAINING_API
49TESS_COMMON_TRAINING_API
51TESS_COMMON_TRAINING_API
53TESS_COMMON_TRAINING_API
54DECLARE_STRING_PARAM_FLAG(fontconfig_tmpdir);
55TESS_COMMON_TRAINING_API
57TESS_COMMON_TRAINING_API
59
60// Parse commandline flags and values. Prints the usage string and exits on
61// input of --help or --version.
62//
63// If remove_flags is true, the argv pointer is advanced so that (*argv)[1]
64// points to the first non-flag argument, (*argv)[0] points to the same string
65// as before, and argc is decremented to reflect the new shorter length of argv.
66// eg. If the input *argv is
67// { "program", "--foo=4", "--bar=true", "file1", "file2" } with *argc = 5, the
68// output *argv is { "program", "file1", "file2" } with *argc = 3
69TESS_COMMON_TRAINING_API
70void ParseCommandLineFlags(const char *usage, int *argc, char ***argv, const bool remove_flags);
71
72} // namespace tesseract
73
74#endif // TESSERACT_TRAINING_COMMANDLINEFLAGS_H_
TESS_COMMON_TRAINING_API DECLARE_INT_PARAM_FLAG(debug_level)
void ParseCommandLineFlags(const char *usage, int *argc, char ***argv, const bool remove_flags)
TESS_COMMON_TRAINING_API DECLARE_STRING_PARAM_FLAG(D)