• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef LIBWEBM_COMMON_INDENT_H_
12 #define LIBWEBM_COMMON_INDENT_H_
13 
14 #include <string>
15 
16 #include "mkvmuxer/mkvmuxertypes.h"
17 
18 namespace libwebm {
19 
20 const int kIncreaseIndent = 2;
21 const int kDecreaseIndent = -2;
22 
23 // Used for formatting output so objects only have to keep track of spacing
24 // within their scope.
25 class Indent {
26  public:
27   explicit Indent(int indent);
28 
29   // Changes the number of spaces output. The value adjusted is relative to
30   // |indent_|.
31   void Adjust(int indent);
32 
indent_str()33   std::string indent_str() const { return indent_str_; }
34 
35  private:
36   // Called after |indent_| is changed. This will set |indent_str_| to the
37   // proper number of spaces.
38   void Update();
39 
40   int indent_;
41   std::string indent_str_;
42 
43   LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Indent);
44 };
45 
46 }  // namespace libwebm
47 
48 #endif  // LIBWEBM_COMMON_INDENT_H_
49