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
This commit is contained in:
Sameer Agarwal
2019-04-18 07:54:37 -07:00
parent c0aa9a2631
commit 53dc6213fa
2 changed files with 39 additions and 0 deletions
+6
View File
@@ -498,6 +498,12 @@ CERES_EXPORT bool StringToNumericDiffMethodType(
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);
+33
View File
@@ -336,6 +336,39 @@ const char* TerminationTypeToString(TerminationType type) {
}
}
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