Sketcher: ExternalGeometryExtension - refactor flag string to type in static function
This commit is contained in:
committed by
abdullahtahiriyo
parent
ec5976ec28
commit
6b05767a0c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user