10#ifndef TEUCHOS_FANCY_O_STREAM_DECL_HPP
11#define TEUCHOS_FANCY_O_STREAM_DECL_HPP
15#include "Teuchos_oblackholestream.hpp"
30template<
typename CharT,
typename Traits>
40 typedef typename traits_type::int_type
int_type;
42 typedef typename traits_type::pos_type
pos_type;
44 typedef typename traits_type::off_type
off_type;
48 const RCP<std::basic_ostream<char_type,traits_type> > &
oStream
49 ,
const std::basic_string<char_type,traits_type> &
tabIndentStr
59 const RCP<std::basic_ostream<char_type,traits_type> > &
oStream
60 ,
const std::basic_string<char_type,traits_type> &
tabIndentStr
75 const std::basic_string<char_type,traits_type>&
getTabIndentStr()
const;
164 const std::basic_string<char_type,traits_type> &
linePrefix
190#ifdef TEUCHOS_FANCY_OSTREAM_SHOW_ALL_CALLS
194 std::cerr <<
"\ncalled imbue()\n";
195 std::basic_streambuf<CharT,Traits>::imbue(
l);
201 std::cerr <<
"\ncalled setbuf()\n";
202 return std::basic_streambuf<CharT,Traits>::setbuf(
s,n);
206 seekoff(
off_type a, ios_base::seekdir b,ios_base::openmode c)
208 std::cerr <<
"\ncalled seekoff()\n";
209 return std::basic_streambuf<CharT,Traits>::seekoff(a,b,c);
213 seekpos(
pos_type a, ios_base::openmode b)
215 std::cerr <<
"\ncalled seekpos()\n";
216 return std::basic_streambuf<CharT,Traits>::seekpos(a,b);
222 std::cerr <<
"\ncalled sync()\n";
223 return std::basic_streambuf<CharT,Traits>::sync();
229 std::cerr <<
"\ncalled showmanyc()\n";
230 return std::basic_streambuf<CharT,Traits>::showmanyc();
236 std::cerr <<
"\ncalled xsgetn()\n";
237 return std::basic_streambuf<CharT,Traits>::xsgetn(s,n);
243 std::cerr <<
"\ncalled underflow()\n";
244 return std::basic_streambuf<CharT,Traits>::underflow();
250 std::cerr <<
"\ncalled uflow()\n";
251 return std::basic_streambuf<CharT,Traits>::uflow();
257 std::cerr <<
"\ncalled pbackfail()\n";
258 return std::basic_streambuf<CharT,Traits>::pbackfail(c);
270 typedef std::basic_string<char_type,traits_type> string_t;
271 typedef std::deque<int> tabIndentStack_t;
272 typedef std::deque<string_t> linePrefixStack_t;
277 RCP<std::basic_ostream<char_type,traits_type> > oStreamSet_;
278 RCP<std::basic_ostream<char_type,traits_type> > oStream_;
279 std::basic_string<char_type,traits_type> tabIndentStr_;
280 bool showLinePrefix_;
281 int maxLenLinePrefix_;
289 RCP<std::ostringstream> lineOut_;
292 tabIndentStack_t tabIndentStack_;
293 linePrefixStack_t linePrefixStack_;
294 int enableTabbingStack_;
303 void writeChars(
const char_type s[], std::streamsize n );
305 void writeFrontMatter();
310 basic_FancyOStream_buf<CharT,Traits> operator=(
311 const basic_FancyOStream_buf<CharT,Traits>&
348template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
371 typedef std::basic_ostream<char_type, traits_type>
ostream_t;
409 const RCP< std::basic_ostream<char_type,traits_type> > &
oStream
410 ,
const std::basic_string<char_type,traits_type> &
tabIndentStr =
" "
422 const RCP< std::basic_ostream<char_type,traits_type> > &
oStream
423 ,
const std::basic_string<char_type,traits_type> &
tabIndentStr =
" "
436 const std::basic_string<char_type,traits_type> &
tabIndentStr
440 const std::basic_string<char_type,traits_type>&
getTabIndentStr()
const;
565 const RCP< std::basic_ostream<char> >&
oStream,
584getFancyOStream(
const RCP<std::basic_ostream<char> > &out );
598template <
typename CharT,
typename Traits = std::
char_traits<CharT> >
609 ,
const std::basic_string<CharT,Traits>
linePrefix =
""
611 :fancyOStream_(fancyOStream)
619 const RCP<std::basic_ostream<CharT,Traits> > &
oStream
621 ,
const std::basic_string<CharT,Traits>
linePrefix =
""
623 :fancyOStream_(getFancyOStream(
oStream))
633 ,
const std::basic_string<CharT,Traits>
linePrefix =
""
635 :fancyOStream_(
rcp(&fancyOStream,
false))
643 std::basic_ostream<CharT,Traits> &
oStream
645 ,
const std::basic_string<CharT,Traits>
linePrefix =
""
655 :fancyOStream_(
osTab.fancyOStream_)
663 if(fancyOStream_.
get()) {
665 fancyOStream_->popDisableTabbing();
667 fancyOStream_->popTab();
668 if(linePrefix_.length()) fancyOStream_->popLinePrefix();
674 fancyOStream_ =
osTab.fancyOStream_;
683 if(fancyOStream_.
get()) {
684 fancyOStream_->popTab();
685 fancyOStream_->pushTab(tabs_);
692 return *fancyOStream_;
697 return fancyOStream_.
get();
704 std::basic_string<CharT,Traits> linePrefix_;
708 if(fancyOStream_.
get()) {
710 fancyOStream_->pushDisableTabbing();
712 fancyOStream_->pushTab(tabs_);
713 if(linePrefix_.length()) fancyOStream_->pushLinePrefix(linePrefix_);
735template <
typename CharT,
typename Traits>
736RCP<basic_FancyOStream<CharT,Traits> >
738 const RCP<basic_FancyOStream<CharT,Traits> > &out,
740 const std::basic_string<CharT,Traits> linePrefix =
""
759template <
typename CharT,
typename Traits>
760RCP<basic_FancyOStream<CharT,Traits> >
762 const RCP<std::basic_ostream<CharT,Traits> > &out
764 ,
const std::basic_string<CharT,Traits> linePrefix =
""
787#define TEUCHOS_OSTAB ::Teuchos::OSTab __localThisTab = this->getOSTab()
792#define TEUCHOS_OSTAB_DIFF( DIFF ) ::Teuchos::OSTab DIFF ## __localThisTab = this->getOSTab()
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Reference-counted pointer class and non-member templated function implementations.
Definition of Teuchos::as, for conversions between types.
Smart reference counting pointer class for automatic garbage collection.
RCP(ENull null_arg=null)
Initialize RCP<T> to NULL.
T * get() const
Get the raw C++ pointer to the underlying object.
Stream buffering class that performs the magic of indenting data sent to an std::ostream object.
int_type overflow(int_type c)
int getNumProcs() const
Get the number of processes in the communicator.
void popTab()
Pop the current tab.
void setShowProcRank(const bool showProcRank)
void setOutputToRootOnly(const int rootRank)
Set the stream to print only on the (MPI) process with the given rank.
int getMaxLenLinePrefix() const
RCP< std::basic_ostream< char_type, traits_type > > getOStream()
const std::basic_string< char_type, traits_type > & getTabIndentStr() const
void setTabIndentStr(const std::basic_string< char_type, traits_type > &tabIndentStr)
void setShowTabCount(const bool showTabCount)
int getNumCurrTabs() const
void pushLinePrefix(const std::basic_string< char_type, traits_type > &linePrefix)
void setProcRankAndSize(const int procRank, const int numProcs)
Set the (MPI) process rank and the number of processes in the communicator.
bool getShowProcRank() const
traits_type::pos_type pos_type
void pushDisableTabbing()
int getProcRank() const
Get the rank of the calling (MPI) process.
void setMaxLenLinePrefix(const int maxLenLinePrefix)
int getOutputToRootOnly() const
void pushTab(const int tabs)
Push one or more tabs.
bool getShowLinePrefix() const
traits_type::off_type off_type
traits_type::int_type int_type
const std::basic_string< char_type, traits_type > & getTopLinePrefix() const
void initialize(const RCP< std::basic_ostream< char_type, traits_type > > &oStream, const std::basic_string< char_type, traits_type > &tabIndentStr, const int startingTab, const bool showLinePrefix, const int maxLenLinePrefix, const bool showTabCount, const bool showProcRank)
void setShowLinePrefix(const bool showLinePrefix)
bool getShowTabCount() const
basic_FancyOStream_buf(const RCP< std::basic_ostream< char_type, traits_type > > &oStream, const std::basic_string< char_type, traits_type > &tabIndentStr, const int startingTab, const bool showLinePrefix, const int maxLenLinePrefix, const bool showTabCount, const bool showProcRank)
std::streamsize xsputn(const char_type *s, std::streamsize n)
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
traits_type::off_type off_type
void initialize(const RCP< std::basic_ostream< char_type, traits_type > > &oStream, const std::basic_string< char_type, traits_type > &tabIndentStr=" ", const int startingTab=0, const bool showLinePrefix=false, const int maxLenLinePrefix=10, const bool showTabCount=false, const bool showProcRank=false)
Initialize the output stream.
basic_FancyOStream & setTabIndentStr(const std::basic_string< char_type, traits_type > &tabIndentStr)
Set the tab indent string.
basic_FancyOStream & setShowAllFrontMatter(const bool showAllFrontMatter)
Control whether this stream prints "front matter.".
basic_FancyOStream & setProcRankAndSize(const int procRank, const int numProcs)
Set the (MPI) process rank and the number of processes in the communicator.
void popTab()
Pop the current tab.
traits_type::pos_type pos_type
int getNumCurrTabs() const
const std::basic_string< char_type, traits_type > & getTabIndentStr() const
Get the tab indent string.
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
Set the stream to print only on the (MPI) process with the given rank.
basic_FancyOStream & setMaxLenLinePrefix(const int maxLenLinePrefix)
std::basic_ostream< char_type, traits_type > ostream_t
traits_type::int_type int_type
void pushLinePrefix(const std::basic_string< char_type, traits_type > &linePrefix)
basic_FancyOStream & setShowLinePrefix(const bool showLinePrefix)
RCP< std::basic_ostream< char_type, traits_type > > getOStream()
Get the output stream this object wraps.
const std::basic_string< char_type, traits_type > & getTopLinePrefix() const
basic_FancyOStream_buf< CharT, Traits > streambuf_t
void copyAllOutputOptions(const basic_FancyOStream< CharT, Traits > &oStream)
int getOutputToRootOnly() const
basic_FancyOStream & setShowTabCount(const bool showTabCount)
void pushDisableTabbing()
basic_FancyOStream & setShowProcRank(const bool showProcRank)
void pushTab(const int tabs=1)
Push one or more tabs.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object.
basic_FancyOStream< CharT, Traits > * get() const
basic_OSTab(std::basic_ostream< CharT, Traits > &oStream, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
Warning: Only call this constructor for stack-based object.
static const int DISABLE_TABBING
basic_OSTab(basic_FancyOStream< CharT, Traits > &fancyOStream, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
Warning: Only call this constructor for stack-based object.
basic_OSTab< CharT, Traits > & operator=(const basic_OSTab &osTab)
basic_OSTab(const RCP< basic_FancyOStream< CharT, Traits > > &fancyOStream, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
basic_OSTab< CharT, Traits > & incrTab(const int tabs=1)
basic_FancyOStream< CharT, Traits > & o() const
basic_OSTab(const RCP< std::basic_ostream< CharT, Traits > > &oStream, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
basic_OSTab(const basic_OSTab &osTab)
basic_FancyOStream< char > FancyOStream
basic_OSTab< char > OSTab
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.