Subversion Repositories DevTools

Rev

Rev 2104 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

using System;
using System.Text;

namespace EA_DocGen
{
        /// <summary>
        /// Summary description for DocSectionTracking.
        /// </summary>
        public class DocSectionTracking
        {
      private static int[] DocSection = null;
      private static int   iDocSection = 0;

                public static void initialise()
                {
         DocSection = new int[EA_Constants.MAX_HEADING_LEVEL + 1];
         for (int i=0; i<DocSection.Length; i++)
         {
            DocSection[i] = 0;
         }
         iDocSection = 0;
                }


      public static void trackDocSection(int recurse_level)
      {
         if (recurse_level > EA_Constants.MAX_HEADING_LEVEL)
         {
            throw new System.StackOverflowException(EA_Constants.maxRecursionDepthException );
         }

         iDocSection = recurse_level;
         DocSection[iDocSection]++;     
         for (int i=iDocSection+1; i<DocSection.Length; i++)
            DocSection[i] = 0;
      }

      public static void appendHeadingNumber(ref StringBuilder sb)
      {
         for (int i = 1; i<=iDocSection; i++)
         {
            if (i!=1)
               sb.Append(".");
            sb.Append(DocSection[i].ToString());
         }
      }

      public static string formHeadingString(string headingName)
      {
         StringBuilder sb = new StringBuilder("");
         appendHeadingNumber(ref sb);
         sb.Append("\t");
         sb.Append(headingName);
         return sb.ToString();
      }
        }
}