Пример #1
0
        /// <summary>
        /// Convert flags to 'friendly' representation, suitable for diagnostics
        /// or embedded comments in generated source code.  This form is essentially
        /// the same as that in flags specifications in the 'specification' file.
        /// </summary>
        /// <returns>Formatted string.</returns>
        public string GetFriendlyFlags()
        {
            var builder = new StringBuilder();

            // iterate through bits in the flags array.  Each bit corresponds to a flag.
            for (int i = 0; i < Spec.NumFlags; i++)
            {
                if (flags.GetMaskBit(i))
                {
                    // insert ',' separator, if required
                    if (builder.Length != 0)
                    {
                        builder.Append(",");
                    }

                    // is the flag inverted?
                    if (!flags.GetValueBit(i))
                    {
                        builder.Append("!");
                    }

                    // add the flag's name
                    builder.Append(Spec.GetFlag(i).ToString());
                }
            }

            return(builder.ToString());
        }