internal FixedWidthOptions(Queue<String> queue) { Boolean parsingComplete = false; Boolean gotLineStart = false; Boolean gotLineLength = false; Boolean gotTermStart = false; Boolean gotTermLength = false; while (queue.Count > 0 && !parsingComplete) { var field = queue.Peek(); switch (field) { case "-h": { queue.Dequeue(); this.HeaderLineID = queue.DequeueArgument("-h"); break; } case "-ls": { queue.Dequeue(); this.LineIDStart = queue.DequeueUInt32("-hs"); gotLineStart = true; break; } case "-ll": { queue.Dequeue(); this.LineIDLength = queue.DequeueUInt32("-hl"); gotLineLength = true; break; } case "-t": { queue.Dequeue(); this.TermLineID = queue.DequeueArgument("-t"); break; } case "-ts": { queue.Dequeue(); this.TermStart = queue.DequeueUInt32("-ts"); gotTermStart = true; break; } case "-tl": { queue.Dequeue(); this.TermLength = queue.DequeueUInt32("-tl"); gotTermLength = true; break; } default: { parsingComplete = true; break; } } } if (this.HeaderLineID == null) { throw new Exception("Missing required term 'Header ID' (-h)."); } if (this.TermLineID == null) { throw new Exception("Missing required term 'Term Line ID' (-t)."); } if (!gotLineStart) { throw new Exception("Missing required term 'Line ID Start' (-ls)."); } if (!gotLineLength) { throw new Exception("Missing required term 'Line ID Length' (-ll)."); } if (!gotTermStart) { throw new Exception("Missing required term 'Term Start' (-ts)."); } if (!gotTermLength) { throw new Exception("Missing required term 'Term Length' (-tl)."); } }
internal DelimitedOptions(Queue<String> queue) { Boolean parsingComplete = false; while (queue.Count > 0 && !parsingComplete) { var field = queue.Peek(); switch (field) { case "-d": { queue.Dequeue(); this.Delimiter = queue.DequeueArgument("-d"); break; } case "-q": { queue.Dequeue(); this.Qualifier = queue.DequeueChar("-q"); break; } case "-h": { queue.Dequeue(); this.HeaderLineID = queue.DequeueArgument("-h"); break; } case "-ti": { queue.Dequeue(); this.TermIndex = queue.DequeueUInt32("-ti"); break; } case "-li": { queue.Dequeue(); this.LineIDIndex = queue.DequeueUInt32("-li"); break; } case "-t": { queue.Dequeue(); this.TermLineID = queue.DequeueArgument("-t"); break; } default: { parsingComplete = true; break; } } } if (this.Delimiter == null) { this.Delimiter = ","; } if (this.HeaderLineID == null) { throw new Exception("Missing required term 'Header ID' (-h)."); } if (this.TermLineID == null) { throw new Exception("Missing required term 'Term Line ID' (-t)."); } }