コード例 #1
0
        private List <PlainItemDescription> evaluatePlainItemDescription(ref CommonTree root)
        {
            IList <ITree> parseTreeChildren      = ((CommonTree)root.GetChild(1)).Children;
            List <PlainItemDescription> idesc    = new List <PlainItemDescription>();
            PlainItemDescription        lastItem = null;

            String[] names = new String[parseTreeChildren.Count];
            for (int i = 0; i < parseTreeChildren.Count; i++)
            {
                PlainItemDescription descr   = new PlainItemDescription();
                CommonTree           element = (CommonTree)parseTreeChildren[i];
                descr.columnId = element.Text;
                names[i]       = descr.columnId;
                if (element.ChildCount == 1 || (element.ChildCount == 2 && element.GetChild(1).Type != TextTableParser.INT))
                {
                    int length = Int16.Parse(element.GetChild(0).Text);
                    if (i == 0)
                    {
                        descr.from = 1;
                        descr.to   = length;
                    }
                    else
                    {
                        descr.from = lastItem.to + 1;
                        descr.to   = descr.from + length - 1;
                    }
                }
                else
                {
                    descr.from = Int16.Parse(element.GetChild(0).Text);
                    descr.to   = Int16.Parse(element.GetChild(1).Text);
                }

                if (element.GetChild(element.ChildCount - 1).Type != TextTableParser.INT)
                {
                    if (element.GetChild(element.ChildCount - 1).Type == TextTableParser.ALIGN_RIGHT)
                    {
                        descr.align = PlainItemDescription.align_type.right;
                    }
                }
                lastItem = descr;
                idesc.Add(descr);
            }
            return(idesc);
        }
コード例 #2
0
        private String generateFormatString(List <PlainItemDescription> itemDesc)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < itemDesc.Count; i++)
            {
                PlainItemDescription desc = itemDesc[i];
                sb.Append("{");
                sb.Append(i);
                sb.Append(",");
                sb.Append(desc.align == PlainItemDescription.align_type.left ? "-" : "");
                sb.Append(desc.length());
                sb.Append(":G}");
            }
            String formatString = sb.ToString();

            return(formatString);
        }