Wednesday, April 28, 2010

Joining string collections

Problem: Join a collection of strings, with a given separator

Answer: Use stlsoft::string_concatenator()

Related Chapter: Extended STL, volume 1 chapter 40

Example:

  typedef std::string           string_t;
  typedef std::vector<string_t> strings_t;

  strings_t patterns;

  patterns.push_back("*.cpp");
  patterns.push_back("*.cxx");
  patterns.push_back("*.hpp");
  patterns.push_back("*.hxx");

  string_t result;

  std::copy(coll.begin(), coll.end()
          , stlsoft::string_concatenator(result, "|"));

  assert("*.cpp|*.cxx|*.hpp|*.hxx" == result);

Sunday, January 3, 2010

Extended STL (volume 1) Inventions: Introductions

As I've done for Imperfect C++, I'm going to enumerate the inventions (as opposed to techniques, or already established technologies) introduced in Extended STL (volume 1). Specifically, what are the (C++) programming components/techniques/technologies that I invented that are documented in the book.

I will make a series of posts covering the inventions, including:
  • element reference categories, including the By-Value Temporary Reference
  • Argument-dependent Return-type Variance (ARV)
  • External Iterator Invalidation
  • examination of the separation of Reversibilitty and Bidirectionality
  • UNIXSTL's glob_sequence
  • UNIXSTL's readdir_sequence
  • InetSTL's findfile_sequence
  • InetSTL's ftpdir_sequence
  • WinSTL's findfile_sequence
  • WinSTL's listbox_sequence and combobox_sequence
  • WinSTL's pid_sequence
  • WinSTL's process_module_sequence
  • MFCSTL's CArray_cadaptor
  • MFCSTL's CArray_iadaptor
  • WinSTL's child_window_sequence
  • WinSTL's zorder_iterator
  • PlatformSTL's environment_map
  • STLSoft's string_tokeniser
  • COMSTL's enumerator_sequence
  • COMSTL's collection_sequence
  • ACESTL's message_queue_sequence
  • STLSoft's ostream_iterator
  • STLSoft's cstring_concatenator_iterator
  • STLSoft's string_concatenator_iterator
  • STLSoft's member_selector_iterator
  • STLSoft's adapted_iterator_traits
  • STLSoft's filter_iterator
  • STLSoft's transform_iterator

Over time, I'll post short examples/explanations regarding each of these.