Add some missing string-to-enum-to-string convertors.
LoggingTypeToString
StringtoLoggingType
DumpFormatTypeToString
StringtoDumpFormatType
Fixes https://github.com/ceres-solver/ceres-solver/issues/470
Change-Id: Ic7eb98dada008c869a686fbdf2c7ff9ab81dad54
diff --git a/include/ceres/types.h b/include/ceres/types.h
index d01e921..4473ad5 100644
--- a/include/ceres/types.h
+++ b/include/ceres/types.h
@@ -498,6 +498,12 @@
std::string value,
NumericDiffMethodType* type);
+CERES_EXPORT const char* LoggingTypeToString(LoggingType type);
+CERES_EXPORT bool StringtoLoggingType(std::string value, LoggingType* type);
+
+CERES_EXPORT const char* DumpFormatTypeToString(DumpFormatType type);
+CERES_EXPORT bool StringtoDumpFormatType(std::string value, LoggingType* type);
+
CERES_EXPORT const char* TerminationTypeToString(TerminationType type);
CERES_EXPORT bool IsSchurType(LinearSolverType type);
diff --git a/internal/ceres/types.cc b/internal/ceres/types.cc
index 932ec7d..4691414 100644
--- a/internal/ceres/types.cc
+++ b/internal/ceres/types.cc
@@ -336,6 +336,39 @@
}
}
+const char* LoggingTypeToString(LoggingType type) {
+ switch (type) {
+ CASESTR(SILENT);
+ CASESTR(PER_MINIMIZER_ITERATION);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringtoLoggingType(std::string value, LoggingType* type) {
+ UpperCase(&value);
+ STRENUM(SILENT);
+ STRENUM(PER_MINIMIZER_ITERATION);
+ return false;
+}
+
+
+const char* DumpFormatTypeToString(DumpFormatType type) {
+ switch (type) {
+ CASESTR(CONSOLE);
+ CASESTR(TEXTFILE);
+ default:
+ return "UNKNOWN";
+ }
+}
+
+bool StringtoDumpFormatType(std::string value, DumpFormatType* type) {
+ UpperCase(&value);
+ STRENUM(CONSOLE);
+ STRENUM(TEXTFILE);
+ return false;
+}
+
#undef CASESTR
#undef STRENUM