Sketcher: ExternalGeometryExtension - refactor flag string to type in static function

This commit is contained in:
Abdullah Tahiri
2020-12-05 06:51:44 +01:00
committed by abdullahtahiriyo
parent ec5976ec28
commit 6b05767a0c
3 changed files with 25 additions and 16 deletions

View File

@@ -85,3 +85,20 @@ PyObject * ExternalGeometryExtension::getPyObject(void)
return new ExternalGeometryExtensionPy(new ExternalGeometryExtension(*this));
}
bool ExternalGeometryExtension::getFlagsFromName(std::string str, ExternalGeometryExtension::Flag &flag)
{
auto pos = std::find_if( ExternalGeometryExtension::flag2str.begin(),
ExternalGeometryExtension::flag2str.end(),
[str](const char * val) {
return strcmp(val,str.c_str())==0;}
);
if( pos != ExternalGeometryExtension::flag2str.end()) {
int index = std::distance( ExternalGeometryExtension::flag2str.begin(), pos );
flag = static_cast<ExternalGeometryExtension::Flag>(index);
return true;
}
return false;
}