VirtualBox

Changeset 95586 in vbox for trunk/include


Ignore:
Timestamp:
Jul 11, 2022 9:51:30 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152218
Message:

IPRT: Added RTStrmWrappedPrintf and RTStrmWrappedPrintfV for some simple output wrapping accoring to the terminal size (80 columns if not terminal).

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r94627 r95586  
    22902290# define RTStrmPrintf                                   RT_MANGLER(RTStrmPrintf)
    22912291# define RTStrmPrintfV                                  RT_MANGLER(RTStrmPrintfV)
     2292# define RTStrmWrappedPrintf                            RT_MANGLER(RTStrmWrappedPrintf)
     2293# define RTStrmWrappedPrintfV                           RT_MANGLER(RTStrmWrappedPrintfV)
    22922294# define RTStrmDumpPrintfV                              RT_MANGLER(RTStrmDumpPrintfV)
    22932295# define RTStrmPutCh                                    RT_MANGLER(RTStrmPutCh)
  • trunk/include/iprt/stream.h

    r93115 r95586  
    313313
    314314/**
     315 * Prints a formatted string to the specified stream, performing wrapping of
     316 * lines considered too long.
     317 *
     318 * If the stream is to a terminal, the terminal width is used as the max line
     319 * width.  Otherwise, the width is taken from @a fFlags
     320 * (RTSTRMWRAPPED_F_NON_TERMINAL_WIDTH_MASK /
     321 * RTSTRMWRAPPED_F_NON_TERMINAL_WIDTH_SHIFT), defaulting to 80 if zero.
     322 *
     323 * @returns Low 16 bits is the line offset, high 16 bits the number of lines
     324 *          outputted.  Apply RTSTRMWRAPPED_F_LINE_OFFSET_MASK to the value and
     325 *          it can be passed via @a fFlags to the next invocation (not necessary
     326 *          if all format strings ends with a newline).
     327 *          Negative values are IPRT error status codes.
     328 * @param   pStream         The stream to print to.
     329 * @param   fFlags          RTSTRMWRAPPED_F_XXX - flags, configuration and state.
     330 * @param   pszFormat       Runtime format string.
     331 * @param   ...             Arguments specified by pszFormat.
     332 * @sa      RTStrmWrappedPrintfV, RTStrmPrintf, RTStrmPrintfV
     333 */
     334RTDECL(int32_t) RTStrmWrappedPrintf(PRTSTREAM pStream, uint32_t fFlags, const char *pszFormat, ...)  RT_IPRT_FORMAT_ATTR(3, 4);
     335
     336/**
     337 * Prints a formatted string to the specified stream, performing wrapping of
     338 * lines considered too long.
     339 *
     340 * If the stream is to a terminal, the terminal width is used as the max line
     341 * width.  Otherwise, the width is taken from @a fFlags
     342 * (RTSTRMWRAPPED_F_NON_TERMINAL_WIDTH_MASK /
     343 * RTSTRMWRAPPED_F_NON_TERMINAL_WIDTH_SHIFT), defaulting to 80 if zero.
     344 *
     345 * @returns Low 16 bits is the line offset, high 16 bits the number of lines
     346 *          outputted.  Apply RTSTRMWRAPPED_F_LINE_OFFSET_MASK to the value and
     347 *          it can be passed via @a fFlags to the next invocation (not necessary
     348 *          if all format strings ends with a newline).
     349 *          Negative values are IPRT error status codes.
     350 * @param   pStream         The stream to print to.
     351 * @param   fFlags          RTSTRMWRAPPED_F_XXX - flags, configuration and state.
     352 * @param   pszFormat       Runtime format string.
     353 * @param   va              Arguments specified by pszFormat.
     354 * @sa      RTStrmWrappedPrintf, RTStrmPrintf, RTStrmPrintfV
     355 */
     356RTDECL(int32_t) RTStrmWrappedPrintfV(PRTSTREAM pStream, uint32_t fFlags, const char *pszFormat,
     357                                     va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
     358
     359/** @name RTSTRMWRAPPED_F_XXX - Flags for RTStrmWrappedPrintf &
     360 *        RTStrmWrappedPrintfV.
     361 * @{ */
     362/** The current line offset mask.
     363 * This should be used to passed the line off state from one call to the next
     364 * when printing incomplete lines.  If all format strings ends with a newline,
     365 * this is not necessary. */
     366#define RTSTRMWRAPPED_F_LINE_OFFSET_MASK            UINT32_C(0x00000fff)
     367/** The non-terminal width mask. Defaults to 80 if not specified (zero). */
     368#define RTSTRMWRAPPED_F_NON_TERMINAL_WIDTH_MASK     UINT32_C(0x000ff000)
     369/** The non-terminal width shift. */
     370#define RTSTRMWRAPPED_F_NON_TERMINAL_WIDTH_SHIFT    12
     371/** The hanging indent level mask - defaults to 4 if zero.
     372 * Used when RTSTRMWRAPPED_F_HANGING_INDENT is set. */
     373#define RTSTRMWRAPPED_F_HANGING_INDENT_MASK         UINT32_C(0x01f00000)
     374/** The hanging indent level shift. */
     375#define RTSTRMWRAPPED_F_HANGING_INDENT_SHIFT        20
     376/** Hanging indent.  Used for command synopsis and such. */
     377#define RTSTRMWRAPPED_F_HANGING_INDENT              UINT32_C(0x80000000)
     378/** @} */
     379
     380/**
    315381 * Dumper vprintf-like function outputting to a stream.
    316382 *
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette