Split Camera and Mic into two permissions on the Site Details page (under Site Settings).
[chromium-blink-merge.git] / third_party / android_crazy_linker / src / src / crazy_linker_line_reader.h
blobfda9053020130060382c23ced854275ce979bce0
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CRAZY_LINKER_LINE_READER_H
6 #define CRAZY_LINKER_LINE_READER_H
8 #include <string.h>
10 #include "crazy_linker_system.h"
12 namespace crazy {
14 // A class used to read text files line-by-line.
15 // Usage:
16 // LineReader reader("/path/to/file");
17 // while (reader.GetNextLine()) {
18 // const char* line = reader.line();
19 // size_t line_len = reader.length();
20 // ... line is not necessarily zero-terminated.
21 // }
23 class LineReader {
24 public:
25 LineReader();
26 explicit LineReader(const char* path);
27 ~LineReader();
29 // Open a new file for testing. Doesn't fail. If there was an error
30 // opening the file, GetNextLine() will simply return false.
31 void Open(const char* file_path);
33 // Grab next line. Returns true on success, or false otherwise.
34 bool GetNextLine();
36 // Return the start of the current line, this is _not_ zero-terminated
37 // and always contains a final newline (\n).
38 // Only call this after a successful GetNextLine().
39 const char* line() const;
41 // Return the line length, this includes the final \n.
42 // Only call this after a successful GetNextLine().
43 size_t length() const;
45 private:
46 void Reset(bool eof);
48 FileDescriptor fd_;
49 bool eof_;
50 size_t line_start_;
51 size_t line_len_;
52 size_t buff_size_;
53 size_t buff_capacity_;
54 char* buff_;
57 } // namespace crazy
59 #endif // CRAZY_LINKER_LINE_READER_H