2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "pp/LinearDocument.h"
24 void LinearDocument::indent(void) { _indent.increase(); }
25 void LinearDocument::unindent(void) { _indent.decrease(); }
27 void LinearDocument::append(void)
29 // NOTE Do NOT indent empty lines
30 _lines.emplace_back("");
33 void LinearDocument::append(const std::string &line)
41 // Append indentation space(s), and insert the update string to lines
42 _lines.emplace_back(_indent.build(line));
45 void LinearDocument::append(const LinearDocument &doc)
47 for (uint32_t n = 0; n < doc.lines(); ++n)
49 // NOTE Do NOT update _lines here and use append method
54 const std::string &LinearDocument::line(uint32_t n) const
58 case Direction::Forward:
62 case Direction::Reverse:
64 return _lines.at(lines() - n - 1);
67 throw std::runtime_error{"Not supported Direction"};