MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / create

Method create

src/openms/source/CONCEPT/VersionInfo.cpp:54–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 }
53
54 VersionInfo::VersionDetails VersionInfo::VersionDetails::create(const String & version) //static
55 {
56 VersionInfo::VersionDetails result;
57
58 size_t first_dot = version.find('.');
59 // we demand at least one "."
60 if (first_dot == string::npos)
61 {
62 return VersionInfo::VersionDetails::EMPTY;
63 }
64
65 try
66 {
67 result.version_major = String(version.substr(0, first_dot)).toInt();
68 }
69 catch (Exception::ConversionError & /*e*/)
70 {
71 return VersionInfo::VersionDetails::EMPTY;
72 }
73
74 // returns npos if no second "." is found - which does not hurt
75 size_t second_dot = version.find('.', first_dot + 1);
76 try
77 {
78 result.version_minor = String(version.substr(first_dot + 1, second_dot - (first_dot + 1))).toInt();
79 }
80 catch (Exception::ConversionError & /*e*/)
81 {
82 return VersionInfo::VersionDetails::EMPTY;
83 }
84
85 // if there is no second dot: return
86 if (second_dot == string::npos)
87 {
88 return result;
89 }
90
91 // returns npos if no final pre-release dash "-" is found - which does not hurt
92 size_t pre_release_dash = version.find('-', second_dot + 1);
93 try
94 {
95 result.version_patch = String(version.substr(second_dot + 1, pre_release_dash - (second_dot + 1))).toInt();
96 }
97 catch (Exception::ConversionError & /*e*/)
98 {
99 return VersionInfo::VersionDetails::EMPTY;
100 }
101
102 if (pre_release_dash == string::npos)
103 {
104 return result;
105 }
106
107 result.pre_release_identifier = String(version.substr(pre_release_dash + 1, version.size() - (pre_release_dash + 1)));
108
109 return result;
110 }
111

Callers 5

main_Method · 0.45
exportFeatureMapMethod · 0.45
exportFeatureMapMethod · 0.45
testVersionFunction · 0.45
testIsotopeMarkerFunction · 0.45

Calls 5

toIntMethod · 0.80
substrMethod · 0.80
StringClass · 0.50
findMethod · 0.45
sizeMethod · 0.45

Tested by 2

testVersionFunction · 0.36
testIsotopeMarkerFunction · 0.36