blob: f4a72365adb4b6bedccbfa2392b907a17663e233 [file] [log] [blame]
Ben Clayton5bee67f2020-10-30 20:44:53 +00001// 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 sinclaird5fd7e02020-11-03 16:26:09 +000015#include "src/source.h"
Ben Clayton5bee67f2020-10-30 20:44:53 +000016
dan sinclaird5fd7e02020-11-03 16:26:09 +000017#include <sstream>
18#include <utility>
Ben Clayton5bee67f2020-10-30 20:44:53 +000019
20namespace tint {
21namespace {
22std::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 Clayton1d982362021-02-18 21:40:19 +000033Source::FileContent::FileContent(const std::string& body)
34 : data(body), lines(split_lines(body)) {}
35
36Source::FileContent::~FileContent() = default;
Ben Clayton5bee67f2020-10-30 20:44:53 +000037
38Source::File::~File() = default;
39
40} // namespace tint