@@ -50,8 +50,8 @@ class Concore{
5050 oport = mapParser (" concore.oport" );
5151 std::map<std::string, int >::iterator it_iport = iport.begin ();
5252 std::map<std::string, int >::iterator it_oport = oport.begin ();
53- int iport_number = generateNumberString (it_iport->first );
54- int oport_number = generateNumberString (it_oport->first );
53+ int iport_number = ExtractNumeric (it_iport->first );
54+ int oport_number = ExtractNumeric (it_oport->first );
5555
5656 if (oport_number != -1 )
5757 {
@@ -76,38 +76,27 @@ class Concore{
7676 shmctl (shmId_create, IPC_RMID , nullptr );
7777 }
7878
79- std::map<char , int > createAlphabetMap () {
80- std::map<char , int > alphabetMap;
81-
82- for (char c = ' A' ; c <= ' Z' ; ++c) {
83- alphabetMap[c] = c - ' A' + 1 ;
84- }
85-
86- return alphabetMap;
87- }
88-
89- key_t generateNumberString (const std::string& str) {
90- std::map<char , int > alphabetMap = createAlphabetMap ();
79+ key_t ExtractNumeric (const std::string& str) {
9180 std::string numberString;
9281
9382 // Find the number of leading digits in the input string
9483 size_t numDigits = 0 ;
9584 std::string start_digit = " " ;
9685 while (numDigits < str.length () && std::isdigit (str[numDigits])) {
9786 numberString += str[numDigits];
98- ++numDigits;
87+ ++numDigits;
9988 }
10089
10190 if (numDigits == 0 )
10291 {
10392 return -1 ;
10493 }
10594
106- // Concatenate the numbers for the first three alphabet characters after the digits
107- for ( size_t i = numDigits; i < str. length () && i < numDigits + 3 ; ++i) {
108- char c = std::toupper (str[i]);
109- if (alphabetMap. count (c) > 0 ) {
110- numberString += std::to_string (alphabetMap[c]) ;
95+ if (numDigits == 1 )
96+ {
97+ if ( std::stoi (numberString) <= 0 )
98+ {
99+ return - 1 ;
111100 }
112101 }
113102
0 commit comments