コード例 #1
0
        private void ParseNonQuotedItem(LexListSettings settings)
        {
            string text = base.ReadNonQuotedToken(this._separatorMap, true);

            if (settings.TrimWhiteSpace)
            {
                text = text.Trim();
            }
            this._tokenList.Add(text);
        }
コード例 #2
0
 public override void Init(LexSettings settings)
 {
     base.Init(settings);
     this._separatorMap      = new Dictionary <string, string>();
     this._separatorMap[","] = ",";
     if (settings is LexListSettings)
     {
         LexListSettings lexListSettings = (LexListSettings)settings;
         this._separatorMap.Clear();
         this._separatorMap[lexListSettings.Delimeter] = lexListSettings.Delimeter;
     }
 }
コード例 #3
0
 public bool CheckAndHandleNewLine(LexListSettings settings)
 {
     if (this._reader.IsEol())
     {
         this._reader.ConsumeNewLine();
         if (settings.MultipleRecordsUsingNewLine)
         {
             this._lines.Add(this._tokenList);
             this._tokenList = new List <string>();
         }
         return(true);
     }
     return(false);
 }
コード例 #4
0
        private void ParseQuotedItem(LexListSettings settings)
        {
            string currentChar = this._reader.CurrentChar;
            string text        = this.ReadQuotedToken();

            if (settings.TrimWhiteSpace)
            {
                text = text.Trim();
            }
            this._tokenList.Add(text);
            if (this.Expect(currentChar))
            {
                this._reader.ReadChar();
            }
        }
コード例 #5
0
        public List <List <string> > ParseLines(string text)
        {
            LexListSettings settings = this._settings as LexListSettings;

            this.Reset(text);
            this._reader.ReadChar();
            this._reader.ConsumeWhiteSpace();
            while (!this._reader.IsEnd())
            {
                if (this._reader.IsWhiteSpace())
                {
                    this._reader.ConsumeWhiteSpace();
                }
                else
                {
                    if (this._reader.CurrentChar == "'" || this._reader.CurrentChar == "\"")
                    {
                        this.ParseQuotedItem(settings);
                    }
                    else
                    {
                        this.ParseNonQuotedItem(settings);
                    }
                    this.CheckAndConsumeWhiteSpace();
                    this.CheckAndHandleComma();
                    this.CheckAndConsumeWhiteSpace();
                    if (!this.CheckAndHandleNewLine(settings))
                    {
                        this._reader.ReadChar();
                    }
                }
            }
            base.CheckAndThrowErrors();
            if (this._tokenList.Count > 0)
            {
                this._lines.Add(this._tokenList);
            }
            return(this._lines);
        }
コード例 #6
0
 public LexList(LexListSettings settings)
 {
     this.Init(settings);
 }
コード例 #7
0
        public static List <List <string> > Parse(string text, LexListSettings settings)
        {
            LexList lexList = new LexList(settings);

            return(lexList.ParseLines(text));
        }