Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
codegen.cc
Go to the documentation of this file.
1// Copyright 2010-2025 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#include <iostream>
15#include <memory>
16#include <string>
17
18#include "absl/flags/flag.h"
19#include "absl/log/check.h"
20#include "absl/log/log.h"
21#include "absl/strings/string_view.h"
26
27ABSL_FLAG(std::string, binding_type, "", "The binding type to generate.");
28
30
31namespace {
32void Main() {
33 const std::string binding_type = absl::GetFlag(FLAGS_binding_type);
34 if (binding_type == "c99_h") {
35 std::cout << C99Declarations()->GenerateCode();
36 } else if (binding_type == "c99_cc") {
37 std::cout << C99Definitions()->GenerateCode();
38 } else if (binding_type == "python_enums") {
39 std::cout << PythonEnums()->GenerateCode();
40 } else {
41 LOG(FATAL) << "unknown binding type: '" << binding_type << "'";
42 }
43}
44
45} // namespace
46} // namespace operations_research::math_opt::codegen
47
48int main(int argc, char** argv) {
49 InitGoogle(argv[0], &argc, &argv, /*remove_flags=*/true);
50 operations_research::math_opt::codegen::Main();
51 return 0;
52}
ABSL_FLAG(std::string, binding_type, "", "The binding type to generate.")
int main(int argc, char **argv)
Definition codegen.cc:48
void InitGoogle(absl::string_view usage, int *argc, char ***argv, bool deprecated)
Definition init_google.h:49
Language-agnostic utilities for Elemental codegen.
Definition codegen.cc:29
std::unique_ptr< CodeGenerator > PythonEnums()
std::unique_ptr< CodeGenerator > C99Definitions()
Returns a generator for C99 definitions.
Definition gen_c.cc:241
std::unique_ptr< CodeGenerator > C99Declarations()
Returns a generator for C99 declarations.
Definition gen_c.cc:237