47 namespace MatrixMarket {
55 const size_t lineNumber,
57 const bool maybeBannerLine)
65 std::ostringstream os;
66 os <<
"Line " << lineNumber <<
" contains no characters";
67 throw std::invalid_argument (os.str());
72 start = line.find_first_not_of (
" \t");
73 if (start == std::string::npos) {
80 std::ostringstream os;
81 os <<
"Line " << lineNumber <<
" contains only whitespace";
82 throw std::invalid_argument (os.str());
89 const size_t commentPos = line.find_first_of(
"%#", start);
90 if (commentPos == std::string::npos) {
94 size = std::string::npos;
97 else if (commentPos == start) {
102 if (maybeBannerLine) {
103 const size_t bannerStart =
104 line.substr (commentPos).find (
"%%MatrixMarket");
105 if (bannerStart != std::string::npos) {
106 size = line.size() - commentPos;
125 size = commentPos - start;
bool checkCommentLine(const std::string &line, size_t &start, size_t &size, const size_t lineNumber, const bool tolerant, const bool maybeBannerLine)
True if the line is a comment line, false otherwise.
int maxLineLength()
Maximum line length for a Matrix Market file.