A faster sscanf

namespace BIscan, defined in file BIscan.h, introduces a collection of text conversion tools that run about 3X the time speed of sscanf when dealing with integers and which take advantage of C++ template techniques and the iostream style to make scanning of in-memory buffers easy.

For example:

  #include <BIscan/BIscan.h>

  ...

  int i1, i2;

  std::string s1;

  char buffer[40];

  if( BIscan::stream("1 2 string moreString") >> i1 >> i2 >> s1 >> buffer )
  {
    // scan successful
  }

Compare the above example with the sscanf variant:

  #include <portable_io.h>

  ...

  int i1, i2;

  std::string s1;  // can't use this!

  char buffer[40];

  char s1_contents[40]; 

  if( 4 == sscanf("1 2 string moreString", &i1, &k2, s1_contents, buffer) )
  {
    // scan successful

    s1 = s1_content;
  }

See BIscan for the list of free functions that perform various string conversions.

Note:
In the above example, BIscan::stream is a function returning a BIscan::Stream.
See also:
BIscan::stream, BIscan::Hex, BIscan::convertInteger
Generated on Wed Feb 29 22:51:48 2012 for CXXUtilities by  doxygen 1.6.3