| 169 | } |
| 170 | |
| 171 | bool cmProcess::Buffer::GetLine(std::string& line) |
| 172 | { |
| 173 | // Scan for the next newline. |
| 174 | for (size_type sz = this->size(); this->Last != sz; ++this->Last) { |
| 175 | if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') { |
| 176 | // Extract the range first..last as a line. |
| 177 | char const* text = this->data() + this->First; |
| 178 | size_type length = this->Last - this->First; |
| 179 | while (length && text[length - 1] == '\r') { |
| 180 | length--; |
| 181 | } |
| 182 | line.assign(text, length); |
| 183 | |
| 184 | // Start a new range for the next line. |
| 185 | ++this->Last; |
| 186 | this->First = this->Last; |
| 187 | |
| 188 | // Return the line extracted. |
| 189 | return true; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // Available data have been exhausted without a newline. |
| 194 | if (this->First != 0) { |
| 195 | // Move the partial line to the beginning of the buffer. |
| 196 | this->erase(this->begin(), this->begin() + this->First); |
| 197 | this->First = 0; |
| 198 | this->Last = this->size(); |
| 199 | } |
| 200 | return false; |
| 201 | } |
| 202 | |
| 203 | bool cmProcess::Buffer::GetLast(std::string& line) |
| 204 | { |
no test coverage detected