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 #ifndef LIBWEBM_COMMON_INDENT_H_ 12*103e46e4SHarish Mahendrakar #define LIBWEBM_COMMON_INDENT_H_ 13*103e46e4SHarish Mahendrakar 14*103e46e4SHarish Mahendrakar #include <string> 15*103e46e4SHarish Mahendrakar 16*103e46e4SHarish Mahendrakar #include "mkvmuxer/mkvmuxertypes.h" 17*103e46e4SHarish Mahendrakar 18*103e46e4SHarish Mahendrakar namespace libwebm { 19*103e46e4SHarish Mahendrakar 20*103e46e4SHarish Mahendrakar const int kIncreaseIndent = 2; 21*103e46e4SHarish Mahendrakar const int kDecreaseIndent = -2; 22*103e46e4SHarish Mahendrakar 23*103e46e4SHarish Mahendrakar // Used for formatting output so objects only have to keep track of spacing 24*103e46e4SHarish Mahendrakar // within their scope. 25*103e46e4SHarish Mahendrakar class Indent { 26*103e46e4SHarish Mahendrakar public: 27*103e46e4SHarish Mahendrakar explicit Indent(int indent); 28*103e46e4SHarish Mahendrakar 29*103e46e4SHarish Mahendrakar // Changes the number of spaces output. The value adjusted is relative to 30*103e46e4SHarish Mahendrakar // |indent_|. 31*103e46e4SHarish Mahendrakar void Adjust(int indent); 32*103e46e4SHarish Mahendrakar indent_str()33*103e46e4SHarish Mahendrakar std::string indent_str() const { return indent_str_; } 34*103e46e4SHarish Mahendrakar 35*103e46e4SHarish Mahendrakar private: 36*103e46e4SHarish Mahendrakar // Called after |indent_| is changed. This will set |indent_str_| to the 37*103e46e4SHarish Mahendrakar // proper number of spaces. 38*103e46e4SHarish Mahendrakar void Update(); 39*103e46e4SHarish Mahendrakar 40*103e46e4SHarish Mahendrakar int indent_; 41*103e46e4SHarish Mahendrakar std::string indent_str_; 42*103e46e4SHarish Mahendrakar 43*103e46e4SHarish Mahendrakar LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Indent); 44*103e46e4SHarish Mahendrakar }; 45*103e46e4SHarish Mahendrakar 46*103e46e4SHarish Mahendrakar } // namespace libwebm 47*103e46e4SHarish Mahendrakar 48*103e46e4SHarish Mahendrakar #endif // LIBWEBM_COMMON_INDENT_H_ 49