Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'util/file_piece.hh')
-rw-r--r--util/file_piece.hh32
1 files changed, 25 insertions, 7 deletions
diff --git a/util/file_piece.hh b/util/file_piece.hh
index 35f5eb648..d3d83054d 100644
--- a/util/file_piece.hh
+++ b/util/file_piece.hh
@@ -55,7 +55,7 @@ class FilePiece {
return Consume(FindDelimiterOrEOF(delim));
}
- // Read word until the line or file ends.
+ /// Read word until the line or file ends.
bool ReadWordSameLine(StringPiece &to, const bool *delim = kSpaces) {
assert(delim[static_cast<unsigned char>('\n')]);
// Skip non-enter spaces.
@@ -75,12 +75,30 @@ class FilePiece {
return true;
}
- // Unlike ReadDelimited, this includes leading spaces and consumes the delimiter.
- // It is similar to getline in that way.
- StringPiece ReadLine(char delim = '\n');
-
- // Doesn't throw EndOfFileException, just returns false.
- bool ReadLineOrEOF(StringPiece &to, char delim = '\n');
+ /** Read a line of text from the file.
+ *
+ * Unlike ReadDelimited, this includes leading spaces and consumes the
+ * delimiter. It is similar to getline in that way.
+ *
+ * If strip_cr is true, any trailing carriate return (as would be found on
+ * a file written on Windows) will be left out of the returned line.
+ *
+ * Throws EndOfFileException if the end of the file is encountered. If the
+ * file does not end in a newline, this could mean that the last line is
+ * never read.
+ */
+ StringPiece ReadLine(char delim = '\n', bool strip_cr = true);
+
+ /** Read a line of text from the file, or return false on EOF.
+ *
+ * This is like ReadLine, except it returns false where ReadLine throws
+ * EndOfFileException. Like ReadLine it may not read the last line in the
+ * file if the file does not end in a newline.
+ *
+ * If strip_cr is true, any trailing carriate return (as would be found on
+ * a file written on Windows) will be left out of the returned line.
+ */
+ bool ReadLineOrEOF(StringPiece &to, char delim = '\n', bool strip_cr = true);
float ReadFloat();
double ReadDouble();