xref: /aosp_15_r20/external/libwebm/common/indent.cc (revision 103e46e4cd4b6efcf6001f23fa8665fb110abf8d)
1*103e46e4SHarish Mahendrakar /*
2*103e46e4SHarish Mahendrakar  *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3*103e46e4SHarish Mahendrakar  *
4*103e46e4SHarish Mahendrakar  *  Use of this source code is governed by a BSD-style license
5*103e46e4SHarish Mahendrakar  *  that can be found in the LICENSE file in the root of the source
6*103e46e4SHarish Mahendrakar  *  tree. An additional intellectual property rights grant can be found
7*103e46e4SHarish Mahendrakar  *  in the file PATENTS.  All contributing project authors may
8*103e46e4SHarish Mahendrakar  *  be found in the AUTHORS file in the root of the source tree.
9*103e46e4SHarish Mahendrakar  */
10*103e46e4SHarish Mahendrakar 
11*103e46e4SHarish Mahendrakar #include "common/indent.h"
12*103e46e4SHarish Mahendrakar 
13*103e46e4SHarish Mahendrakar #include <string>
14*103e46e4SHarish Mahendrakar 
15*103e46e4SHarish Mahendrakar namespace libwebm {
16*103e46e4SHarish Mahendrakar 
Indent(int indent)17*103e46e4SHarish Mahendrakar Indent::Indent(int indent) : indent_(indent), indent_str_() { Update(); }
18*103e46e4SHarish Mahendrakar 
Adjust(int indent)19*103e46e4SHarish Mahendrakar void Indent::Adjust(int indent) {
20*103e46e4SHarish Mahendrakar   indent_ += indent;
21*103e46e4SHarish Mahendrakar   if (indent_ < 0)
22*103e46e4SHarish Mahendrakar     indent_ = 0;
23*103e46e4SHarish Mahendrakar 
24*103e46e4SHarish Mahendrakar   Update();
25*103e46e4SHarish Mahendrakar }
26*103e46e4SHarish Mahendrakar 
Update()27*103e46e4SHarish Mahendrakar void Indent::Update() { indent_str_ = std::string(indent_, ' '); }
28*103e46e4SHarish Mahendrakar 
29*103e46e4SHarish Mahendrakar }  // namespace libwebm
30