Subversion Repositories DevTools

Rev

Rev 2122 | Rev 2132 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2122 Rev 2124
Line 1271... Line 1271...
1271
         {
1271
         {
1272
            MarkContentWithAPIStereotype(element); // recursion
1272
            MarkContentWithAPIStereotype(element); // recursion
1273
         }
1273
         }
1274
      }
1274
      }
1275
 
1275
 
-
 
1276
      /// <summary>
-
 
1277
      /// This processes a requirement tag for use when sorting requirements, in a way designed to overcome 
-
 
1278
      /// the problem of sorting alphanumeric strings that contain outline numberig but that do not use
-
 
1279
      /// leading zero's in that nunmbering, which distorts the sorting outcome in a way that is undesirable 
-
 
1280
      /// for the human reader.
-
 
1281
      /// The function will also work ok if the input string does not contain any numbering.
-
 
1282
      /// The output of the function is to be used in compare operations by IComparer derived classes.
-
 
1283
      /// </summary>
-
 
1284
      /// <param name="sIn"></param>
-
 
1285
      /// <param name="desiredFieldWidth"></param>
-
 
1286
      /// <returns></returns>
-
 
1287
      public static string OutlineNumberMunging(string sIn, int desiredFieldWidth)
-
 
1288
      {
-
 
1289
         // create a "fabric" filled with 0's into which we can serialise our resulting string
-
 
1290
         const int max_str_len = 100;     // should easily be big enough for a requirement tag.
-
 
1291
         string sOut = new string('0',max_str_len);   
-
 
1292
         char[] sOutChArr = sOut.ToCharArray();
-
 
1293
         
-
 
1294
         int iIn = 0;
-
 
1295
         int iOut = 0;
-
 
1296
 
-
 
1297
         while (iIn < sIn.Length && iOut < max_str_len)
-
 
1298
         {
-
 
1299
            if ( System.Char.IsNumber(sIn[iIn]) )
-
 
1300
            {
-
 
1301
               // Here we have to work out how long the number is, and determine how many leading
-
 
1302
               // zeros to give it. We assume that the desired field width as given to us is always going 
-
 
1303
               // to be sufficient for our needs here. If this is not the case, then the worse that can 
-
 
1304
               // happen is that the number will have no leading zeros, and the sorting of tags may not
-
 
1305
               // be perfect.
-
 
1306
               int iLookAhead = iIn+1;
-
 
1307
               while (iLookAhead < sIn.Length && System.Char.IsNumber(sIn[iLookAhead]))
-
 
1308
               {
-
 
1309
                  iLookAhead++;
-
 
1310
               }
-
 
1311
               int numberLength = iLookAhead - iIn;
-
 
1312
 
-
 
1313
               int numberOfLeadingZerosRequired = desiredFieldWidth - numberLength;
-
 
1314
 
-
 
1315
               // advance by the count of leading zeros required.
-
 
1316
               if (numberOfLeadingZerosRequired > 0)
-
 
1317
                  iOut += numberOfLeadingZerosRequired;
-
 
1318
 
-
 
1319
               // Serialise the number. We dont have to serialise the leading zero's because our char array 
-
 
1320
               // was initialised with 0's to begin with.
-
 
1321
               while(numberLength > 0 && iOut < max_str_len)
-
 
1322
               {
-
 
1323
                  sOutChArr[iOut++] = sIn[iIn++];  // serialise a char forming the number
-
 
1324
                  numberLength--;
-
 
1325
               }
-
 
1326
            }
-
 
1327
            else if (sIn[iIn] == '.')  // do not feed '.' chars through to the output because they can mess up the sorting of tags
-
 
1328
            {
-
 
1329
               iOut++;
-
 
1330
               iIn++;
-
 
1331
            }
-
 
1332
            else
-
 
1333
            {
-
 
1334
               sOutChArr[iOut++] = sIn[iIn++];  // just serialise the char from input to output
-
 
1335
            }
-
 
1336
         }
-
 
1337
           
-
 
1338
         // If we did produce an output string, return it, else return the input unaltered.
-
 
1339
         if (iOut > 0)
-
 
1340
            return new string(sOutChArr); 
-
 
1341
         else
-
 
1342
            return sIn;
-
 
1343
      }
1276
 
1344
 
1277
 
1345
 
1278
      #region Temporary or experimental code
1346
      #region Temporary or experimental code
1279
 
1347
 
1280
 
1348