MCPcopy Create free account
hub / github.com/dmlc/parameter_server / FileLineReader

Class FileLineReader

src/util/filelinereader.h:16–40  ·  view source on GitHub ↗

The FileLineReader class will read a text file specified by 'filename' line by line. Each line will be cleaned with respect to termination ('\n' and '\r'). The line callback will be called in sequence on each line.

Source from the content-addressed store, hash-verified

14// termination ('\n' and '\r'). The line callback will be called in
15// sequence on each line.
16class FileLineReader {
17 public:
18 // Creates a file line reader object that will read the file 'filename'
19 // line by line.
20 explicit FileLineReader(const DataConfig& data_conf) :
21 data_conf_(data_conf), loaded_successfully_(false) {};
22
23 ~FileLineReader() { }
24
25 // Sets the line callback and takes ownership.
26 void set_line_callback(std::function<void(char*)> callback) {
27 line_callback_ = callback;
28 }
29
30 // Reloads the file line by line.
31 void Reload();
32
33 // Indicates if the file was loaded successfully.
34 bool loaded_successfully() const { return loaded_successfully_; }
35
36 private:
37 DataConfig data_conf_;
38 std::function<void(char*)> line_callback_;
39 bool loaded_successfully_;
40};
41
42} // namespace PS

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected