@@ -46,9 +46,10 @@ DEBUG_ONLY(class ResourceMark;)
46
46
class outputStream : public CHeapObjBase {
47
47
private:
48
48
NONCOPYABLE (outputStream);
49
+ int _indentation; // current indentation
50
+ bool _autoindent; // if true, every line starts with indentation
49
51
50
52
protected:
51
- int _indentation; // current indentation
52
53
int _position; // visual position on the current line
53
54
uint64_t _precount; // number of chars output, less than _position
54
55
TimeStamp _stamp; // for time stamps
@@ -90,8 +91,7 @@ class outputStream : public CHeapObjBase {
90
91
class TestSupport ; // Unit test support
91
92
92
93
// creation
93
- outputStream ();
94
- outputStream (bool has_time_stamps);
94
+ outputStream (bool has_time_stamps = false );
95
95
96
96
// indentation
97
97
outputStream& indent ();
@@ -104,6 +104,13 @@ class outputStream : public CHeapObjBase {
104
104
void fill_to (int col);
105
105
void move_to (int col, int slop = 6 , int min_space = 2 );
106
106
107
+ // Automatic indentation:
108
+ // If autoindent mode is on, the following APIs will automatically indent
109
+ // line starts depending on the current indentation level:
110
+ // print(), print_cr(), print_raw(), print_raw_cr()
111
+ // Other APIs are unaffected
112
+ void set_autoindent (bool value) { _autoindent = value; }
113
+
107
114
// sizing
108
115
int position () const { return _position; }
109
116
julong count () const { return _precount + _position; }
@@ -119,10 +126,10 @@ class outputStream : public CHeapObjBase {
119
126
void print_cr (const char * format, ...) ATTRIBUTE_PRINTF (2 , 3 );
120
127
void vprint (const char *format, va_list argptr) ATTRIBUTE_PRINTF (2 , 0 );
121
128
void vprint_cr (const char * format, va_list argptr) ATTRIBUTE_PRINTF (2 , 0 );
122
- void print_raw (const char * str) { write (str, strlen (str)); }
123
- void print_raw (const char * str, size_t len) { write (str, len); }
124
- void print_raw_cr (const char * str) { write (str, strlen (str) ); cr (); }
125
- void print_raw_cr (const char * str, size_t len){ write (str, len); cr (); }
129
+ void print_raw (const char * str) { print_raw (str, strlen (str)); }
130
+ void print_raw (const char * str, size_t len);
131
+ void print_raw_cr (const char * str) { print_raw (str); cr (); }
132
+ void print_raw_cr (const char * str, size_t len) { print_raw (str, len); cr (); }
126
133
void print_data (void * data, size_t len, bool with_ascii, bool rel_addr=true );
127
134
void put (char ch);
128
135
void sp (int count = 1 );
0 commit comments