Salome HOME
Meet the coding style (line length <= 100)
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Tools.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    ExchangePlugin_Tools.cpp
4 // Created: May 15, 2015
5 // Author:  Sergey POKHODENKO
6
7 #include <ExchangePlugin_Tools.h>
8
9 #include <sstream>
10
11 std::list<std::string> ExchangePlugin_Tools::split(const std::string& theString, char theDelimiter)
12 {
13   std::list<std::string> theResult;
14   std::istringstream aStream(theString);
15   std::string aSection;
16   while (std::getline(aStream, aSection, theDelimiter))
17     theResult.push_back(aSection);
18   return theResult;
19 }
20
21 std::string ExchangePlugin_Tools::selectionType2xaoDimension(const std::string& theType)
22 {
23   if (theType == "Vertices" || theType == "vertex")
24     return "vertex";
25   else if (theType == "Edges" || theType == "edge")
26     return "edge";
27   else if (theType == "Faces" || theType == "face")
28     return "face";
29   else if (theType == "Solids" || theType == "solid")
30     return "solid";
31   else if (theType == "Part" || theType == "part")
32     return "part";
33
34   return std::string();
35 }
36
37 std::string ExchangePlugin_Tools::xaoDimension2selectionType(const std::string& theDimension)
38 {
39   if (theDimension == "vertex")
40     return "vertex";
41   else if (theDimension == "edge")
42     return "edge";
43   else if (theDimension == "face")
44     return "face";
45   else if (theDimension == "solid")
46     return "solid";
47
48   return std::string();
49 }
50
51
52 std::string ExchangePlugin_Tools::valuesType2xaoType(
53   const ModelAPI_AttributeTables::ValueType& theType)
54 {
55   switch(theType) {
56   case ModelAPI_AttributeTables::BOOLEAN:
57     return "boolean";
58   case ModelAPI_AttributeTables::INTEGER:
59     return "integer";
60   case ModelAPI_AttributeTables::DOUBLE:
61     return "double";
62   case ModelAPI_AttributeTables::STRING:
63     return "string";
64   }
65   return "";
66 }
67
68 ModelAPI_AttributeTables::ValueType ExchangePlugin_Tools::xaoType2valuesType(std::string theType)
69 {
70   if (theType == "boolean")
71     return ModelAPI_AttributeTables::BOOLEAN;
72   if (theType == "integer")
73     return ModelAPI_AttributeTables::INTEGER;
74   if (theType == "double")
75     return ModelAPI_AttributeTables::DOUBLE;
76   if (theType == "string")
77     return ModelAPI_AttributeTables::STRING;
78   return ModelAPI_AttributeTables::DOUBLE;
79 }