hotspot/src/share/vm/utilities/ostream.hpp
changeset 24424 2658d7834c6e
parent 23517 27c4307d6cda
child 25350 6423a57e5451
equal deleted inserted replaced
24358:8528b67f6562 24424:2658d7834c6e
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    51 
    51 
    52    void update_position(const char* s, size_t len);
    52    void update_position(const char* s, size_t len);
    53    static const char* do_vsnprintf(char* buffer, size_t buflen,
    53    static const char* do_vsnprintf(char* buffer, size_t buflen,
    54                                    const char* format, va_list ap,
    54                                    const char* format, va_list ap,
    55                                    bool add_cr,
    55                                    bool add_cr,
    56                                    size_t& result_len);
    56                                    size_t& result_len)  ATTRIBUTE_PRINTF(3, 0);
    57 
    57 
    58  public:
    58  public:
    59    // creation
    59    // creation
    60    outputStream(int width = 80);
    60    outputStream(int width = 80);
    61    outputStream(int width, bool has_time_stamps);
    61    outputStream(int width, bool has_time_stamps);
    78    julong count() const { return _precount + _position; }
    78    julong count() const { return _precount + _position; }
    79    void set_count(julong count) { _precount = count - _position; }
    79    void set_count(julong count) { _precount = count - _position; }
    80    void set_position(int pos)   { _position = pos; }
    80    void set_position(int pos)   { _position = pos; }
    81 
    81 
    82    // printing
    82    // printing
    83    void print(const char* format, ...);
    83    void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
    84    void print_cr(const char* format, ...);
    84    void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
    85    void vprint(const char *format, va_list argptr);
    85    void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
    86    void vprint_cr(const char* format, va_list argptr);
    86    void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
    87    void print_raw(const char* str)            { write(str, strlen(str)); }
    87    void print_raw(const char* str)            { write(str, strlen(str)); }
    88    void print_raw(const char* str, int len)   { write(str,         len); }
    88    void print_raw(const char* str, int len)   { write(str,         len); }
    89    void print_raw_cr(const char* str)         { write(str, strlen(str)); cr(); }
    89    void print_raw_cr(const char* str)         { write(str, strlen(str)); cr(); }
    90    void print_raw_cr(const char* str, int len){ write(str,         len); cr(); }
    90    void print_raw_cr(const char* str, int len){ write(str,         len); cr(); }
    91    void print_data(void* data, size_t len, bool with_ascii);
    91    void print_data(void* data, size_t len, bool with_ascii);
   272   staticBufferStream(char* buffer, size_t buflen,
   272   staticBufferStream(char* buffer, size_t buflen,
   273                      outputStream *outer_stream);
   273                      outputStream *outer_stream);
   274   ~staticBufferStream() {};
   274   ~staticBufferStream() {};
   275   virtual void write(const char* c, size_t len);
   275   virtual void write(const char* c, size_t len);
   276   void flush();
   276   void flush();
   277   void print(const char* format, ...);
   277   void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
   278   void print_cr(const char* format, ...);
   278   void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
   279   void vprint(const char *format, va_list argptr);
   279   void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
   280   void vprint_cr(const char* format, va_list argptr);
   280   void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0);
   281 };
   281 };
   282 
   282 
   283 // In the non-fixed buffer case an underlying buffer will be created and
   283 // In the non-fixed buffer case an underlying buffer will be created and
   284 // managed in C heap. Not MT-safe.
   284 // managed in C heap. Not MT-safe.
   285 class bufferedStream : public outputStream {
   285 class bufferedStream : public outputStream {