Use <iostream> style formatting with AnsiString & TStrings

Index

A Library for using operator << to format to AnsiString and TStrings.
Copyright (c) 2003 Early Ehlinger

Overview

The VCL has two common string types that would truly benefit from the ability to use C++ <iostream>-style formatting: AnsiString and TStrings. This library provides two std::ostream derivatives; res_bcb::AnsiString_stream and res_bcb::TStrings_stream.

  • Example 1: Using res_bcb::AnsiString_stream

    #include <ResBCB/AnsiString_stream.h>
    
    /*.......*/
    {
    res_bcb::AnsiString_stream message;
    message 
      << "Hello There. Here's a number:" 
      << 32 
      << std::endl 
      << " and here's another:" 
      << 32 
      << std::endl;
    ShowMessage( message.str() ); 
    }

  • Example 2: Using res_bcb::TStrings_stream

    #include <ResBCB/TStrings_stream.h>
    
    /*.......*/
    {
    res_bcb::TStrings_stream memo
       ( Memo1->Lines 
       , true );
    /* The true in memo's constructor tells 
       TStrings_stream to do 
       Application->ProcessMessages() whenever 
       the stream flushes to the underlying 
       TStrings*. */
    
    memo 
      << "Hello There. Here's a number:" 
      << 32 
      << std::endl 
      << " and here's another:" 
      << 32 
      << std::endl;
    }

  • Download

    BCB_streams.zip

    Project Page

    Coming Soon