Ben Clayton | 5bee67f | 2020-10-30 20:44:53 +0000 | [diff] [blame] | 1 | // Copyright 2020 The Tint Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
dan sinclair | d5fd7e0 | 2020-11-03 16:26:09 +0000 | [diff] [blame] | 15 | #include "src/source.h" |
Ben Clayton | 5bee67f | 2020-10-30 20:44:53 +0000 | [diff] [blame] | 16 | |
dan sinclair | d5fd7e0 | 2020-11-03 16:26:09 +0000 | [diff] [blame] | 17 | #include <sstream> |
| 18 | #include <utility> |
Ben Clayton | 5bee67f | 2020-10-30 20:44:53 +0000 | [diff] [blame] | 19 | |
| 20 | namespace tint { |
| 21 | namespace { |
| 22 | std::vector<std::string> split_lines(const std::string& str) { |
| 23 | std::stringstream stream(str); |
| 24 | std::string line; |
| 25 | std::vector<std::string> lines; |
| 26 | while (std::getline(stream, line, '\n')) { |
| 27 | lines.emplace_back(std::move(line)); |
| 28 | } |
| 29 | return lines; |
| 30 | } |
| 31 | } // namespace |
| 32 | |
Ben Clayton | 1d98236 | 2021-02-18 21:40:19 +0000 | [diff] [blame] | 33 | Source::FileContent::FileContent(const std::string& body) |
| 34 | : data(body), lines(split_lines(body)) {} |
| 35 | |
| 36 | Source::FileContent::~FileContent() = default; |
Ben Clayton | 5bee67f | 2020-10-30 20:44:53 +0000 | [diff] [blame] | 37 | |
| 38 | Source::File::~File() = default; |
| 39 | |
| 40 | } // namespace tint |