stdio.h
Go to the documentation of this file.
00001 /** 00002 * @file basis/stdio.h 00003 * @brief Standard I/O functions. 00004 * 00005 * This module defines standard I/O functions for the input and output of 00006 * messages from STDIN or to STDOUT/STDERR, respectively. In particular, 00007 * it includes the cstdio header file of the standard C library as well 00008 * as the iostream header file of the standard C++ library. Besides these 00009 * common functions of the standard C/C++ libraries, it provides some 00010 * additional useful auxiliary functions. Therefore, this header file 00011 * may be included instead of cstdio, stdio.h, or iostream. 00012 * 00013 * Copyright (c) 2012 University of Pennsylvania. All rights reserved.<br /> 00014 * See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file. 00015 * 00016 * Contact: SBIA Group <sbia-software at uphs.upenn.edu> 00017 */ 00018 00019 #pragma once 00020 #ifndef _BASIS_STDIO_H 00021 #define _BASIS_STDIO_H 00022 00023 00024 #include <cstdio> // standard C I/O library 00025 #include <iostream> // standard C++ I/O library 00026 #include <string> // C++ string class 00027 00028 00029 namespace basis { 00030 00031 00032 /// @addtogroup BasisCxxUtilities 00033 /// @{ 00034 00035 00036 /** 00037 * @brief Get size of terminal window. 00038 * 00039 * @param [out] lines Maximum number of lines or 0 if it could not be determined. 00040 * @param [out] columns Maximum number of columns or 0 if it could not be determined. 00041 */ 00042 void get_terminal_size(int& lines, int& columns); 00043 00044 /** 00045 * @brief Get maximum number of lines of terminal window. 00046 * 00047 * @returns Maximum number of lines of terminal window. 00048 */ 00049 int get_terminal_lines(); 00050 00051 /** 00052 * @brief Get maximum number of columns of terminal window. 00053 * 00054 * @returns Maximum number of columns of terminal window. 00055 */ 00056 int get_terminal_columns(); 00057 00058 /** 00059 * @brief Print text, wrapped at a fixed maximum number of columns. 00060 * 00061 * This function is inspired by the TCLAP::StdOutput::spacePrint() 00062 * method written by Michael E. Smoot. 00063 * 00064 * @param [out] os Output stream. 00065 * @param [in] text Text to be printed. 00066 * @param [in] width Maximum width of each line. 00067 * Set to a value less or equal to disable automatic wrapping. 00068 * @param [in] indent Indent of text on each line. 00069 * @param [in] offset Additional indent of all lines except the first one. 00070 */ 00071 std::ostream& print_wrapped(std::ostream& os, 00072 const std::string& text, 00073 int width, 00074 int indent, 00075 int offset); 00076 00077 /// @} 00078 // Doxygen group 00079 00080 00081 } // namespace basis 00082 00083 00084 #endif // _BASIS_STDIO_H