1<!DOCTYPE html>
2<!--
3Copyright (c) 2014 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7<link rel="import" href="/tracing/base/base.html">
8<script>
9'use strict';
10
11tr.exportTo('tr.importer', function() {
12  /**
13   * @constructor
14   */
15  function SimpleLineReader(text) {
16    this.lines_ = text.split('\n');
17    this.curLine_ = 0;
18
19    this.savedLines_ = undefined;
20  }
21
22  SimpleLineReader.prototype = {
23    advanceToLineMatching: function(regex) {
24      for (; this.curLine_ < this.lines_.length; this.curLine_++) {
25        var line = this.lines_[this.curLine_];
26        if (this.savedLines_ !== undefined)
27          this.savedLines_.push(line);
28        if (regex.test(line))
29          return true;
30      }
31      return false;
32    },
33
34    get curLineNumber() {
35      return this.curLine_;
36    },
37
38    beginSavingLines: function() {
39      this.savedLines_ = [];
40    },
41
42    endSavingLinesAndGetResult: function() {
43      var tmp = this.savedLines_;
44      this.savedLines_ = undefined;
45      return tmp;
46    }
47  };
48
49  return {
50    SimpleLineReader: SimpleLineReader
51  };
52});
53</script>
54