1 // Copyright 2017 Google Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // Reads a file line by line and stores the data on the stack. This allows
16 // parsing files in one go without allocating.
17 #ifndef CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_
18 #define CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_
22 #include "cpu_features_macros.h"
23 #include "internal/string_view.h"
25 CPU_FEATURES_START_CPP_NAMESPACE
28 char buffer[STACK_LINE_READER_BUFFER_SIZE];
34 // Initializes a StackLineReader.
35 void StackLineReader_Initialize(StackLineReader* reader, int fd);
38 StringView line; // A view of the line.
39 bool eof; // Nothing more to read, we reached EOF.
40 bool full_line; // If false the line was truncated to
41 // STACK_LINE_READER_BUFFER_SIZE.
44 // Reads the file pointed to by fd and tries to read a full line.
45 LineResult StackLineReader_NextLine(StackLineReader* reader);
47 CPU_FEATURES_END_CPP_NAMESPACE
49 #endif // CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_