using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace CobXmlSupport
{
    public class RowWord
    {
        private string __wordSource;
        private int __startPos;
        private int __length;
        private bool __quoted;

        public RowWord(string wordSource, int strtPos,bool quoted)
        {
            __startPos = strtPos;
            __wordSource = wordSource;
            __length = __wordSource.Length;
            __quoted = quoted;
            //Debug.WriteLine(strtPos.ToString("00") + " " + wordSource);
        }

        public int startPos
        {
            get { return __startPos; }
            set { __startPos = value; }
        }


        public int length
        {
            get { return __length; }
        }

        public bool isQuoted
        {
            get { return __quoted; }
        }

        public bool isComment
        {
            get {
                return (this.__wordSource.StartsWith("*>") || this.__wordSource.StartsWith("*")); 
            }
        }

        public int endPos
        {
            get { return __startPos+__length-1; }
        }

        public override string ToString()
        {
            return __wordSource;
        }

        public string NumVal()
        {
            string numChars = "0123456789";
            string tmpStr = "";
            for (int i = 0; i < __wordSource.Length; i++)
            {
                tmpStr += numChars.IndexOf(__wordSource.Substring(i, 1))>-1?__wordSource.Substring(i, 1):"";
            }
            return tmpStr;
        }

    }
}
