Chromium Code Reviews| Index: chrome/tools/profile_reset/jtl_parser.h |
| diff --git a/chrome/tools/profile_reset/jtl_parser.h b/chrome/tools/profile_reset/jtl_parser.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99715ff6e534a0430ce8c6b7c5b5dd2176a9b73c |
| --- /dev/null |
| +++ b/chrome/tools/profile_reset/jtl_parser.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_TOOLS_PROFILE_RESET_JTL_PARSER_H_ |
| +#define CHROME_TOOLS_PROFILE_RESET_JTL_PARSER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/values.h" |
| + |
| +// Parses text-based JTL source code into a stream of operation names, arguments |
| +// and separator kinds. |
| +class JtlParser { |
| + public: |
| + explicit JtlParser(const std::string& compacted_source, |
| + const std::vector<size_t>& newline_indices); |
|
battre
2013/09/27 15:00:01
nit: no explicit needed.
engedy
2013/10/01 10:48:10
Done.
|
| + ~JtlParser(); |
| + |
| + // Convenience method for compacting |source_code| first, and then creating a |
| + // corresponding parser for it. |
| + static JtlParser* Create(const std::string& source_code); |
| + |
| + // Removes comments from |verbose_text| and compacts it into whitespace-free |
| + // format. For each newline character removed between the i-th and (i-1)-st |
| + // retained character in |compacted_text|, |newline_indices| will contain the |
| + // index 'i'. Elements in |newline_indices| will be monotonically increasing. |
|
battre
2013/09/27 15:00:01
I don't understand this comment what goes into new
engedy
2013/10/01 10:48:10
Rephrased, please take another look.
|
| + static void RemoveCommentsAndAllWhitespace( |
| + const std::string& verbose_text, |
| + std::string* compacted_text, |
| + std::vector<size_t>* newline_indices); |
| + |
| + bool HasNextOperation(); |
| + bool ParseNextOperation(std::string* name, |
| + base::ListValue* args, |
| + bool* ends_sentence); |
|
battre
2013/09/27 15:00:01
Can you add a comment to this function? In particu
engedy
2013/10/01 10:48:10
Done.
|
| + |
| + // Returns on which line the retained character at position |compacted_index| |
| + // was originally located. |
| + size_t GetOriginalLineNumber(size_t compacted_index) const; |
| + |
| + const std::string& compacted_source() const { return compacted_source_; } |
| + size_t last_line_number() const; |
| + std::string last_context() const; |
| + |
| + private: |
| + // Contains pre-compiled regular expressions and related state. Factored out |
| + // to prevent this header from depending on RE2 headers. |
| + struct ParsingState; |
| + |
| + std::string compacted_source_; |
| + std::vector<size_t> newline_indices_; |
| + scoped_ptr<ParsingState> state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(JtlParser); |
| +}; |
| + |
| +#endif // CHROME_TOOLS_PROFILE_RESET_JTL_PARSER_H_ |