OR-Tools  9.6
scip_helper_macros.h
Go to the documentation of this file.
1 // Copyright 2010-2022 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 #ifndef OR_TOOLS_LINEAR_SOLVER_SCIP_HELPER_MACROS_H_
15 #define OR_TOOLS_LINEAR_SOLVER_SCIP_HELPER_MACROS_H_
16 
17 #include "absl/status/status.h"
18 #include "absl/strings/str_format.h"
20 
21 namespace operations_research {
22 namespace internal {
23 // Our own version of SCIP_CALL to do error management.
24 inline absl::Status ScipCodeToUtilStatus(/*SCIP_Retcode*/ int retcode,
25  const char* source_file,
26  int source_line,
27  const char* scip_statement) {
28  if (retcode == /*SCIP_OKAY*/ 1) return absl::OkStatus();
29  return absl::InvalidArgumentError(
30  absl::StrFormat("SCIP error code %d (file '%s', line %d) on '%s'",
31  retcode, source_file, source_line, scip_statement));
32 }
33 } // namespace internal
34 
35 #define SCIP_TO_STATUS(x) \
36  ::operations_research::internal::ScipCodeToUtilStatus(x, __FILE__, __LINE__, \
37  #x)
38 
39 #define RETURN_IF_SCIP_ERROR(x) RETURN_IF_ERROR(SCIP_TO_STATUS(x));
40 
41 } // namespace operations_research
42 
43 #endif // OR_TOOLS_LINEAR_SOLVER_SCIP_HELPER_MACROS_H_
absl::Status ScipCodeToUtilStatus(int retcode, const char *source_file, int source_line, const char *scip_statement)
Collection of objects used to extend the Constraint Solver library.