| 109 | } |
| 110 | |
| 111 | Status ExpectText(const string& data, const string& expected_text, |
| 112 | int* offset) { |
| 113 | int new_offset; |
| 114 | TF_RETURN_IF_ERROR( |
| 115 | IncrementOffset(*offset, expected_text.size(), data.size(), &new_offset)); |
| 116 | const string found_text(data.begin() + *offset, data.begin() + new_offset); |
| 117 | if (found_text != expected_text) { |
| 118 | return errors::InvalidArgument("Header mismatch: Expected ", expected_text, |
| 119 | " but found ", found_text); |
| 120 | } |
| 121 | *offset = new_offset; |
| 122 | return Status::OK(); |
| 123 | } |
| 124 | |
| 125 | Status ReadString(const string& data, int expected_length, string* value, |
| 126 | int* offset) { |