blob: d14845315cc66525747a01b4b7f6cd5da38e2398 [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
15#include <sstream>
16
17#include "source.h"
18
19namespace tint {
20namespace {
21std::vector<std::string> split_lines(const std::string& str) {
22 std::stringstream stream(str);
23 std::string line;
24 std::vector<std::string> lines;
25 while (std::getline(stream, line, '\n')) {
26 lines.emplace_back(std::move(line));
27 }
28 return lines;
29}
30} // namespace
31
32Source::File::File(const std::string& file_path,
33 const std::string& file_content)
34 : path(file_path), content(file_content), lines(split_lines(content)) {}
35
36Source::File::~File() = default;
37
38} // namespace tint