rationale.xml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
  3. "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
  4. <!-- Copyright (c) 2002-2006 Pavol Droba.
  5. Subject to the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <section id="string_algo.rationale" last-revision="$Date$">
  9. <title>Rationale</title>
  10. <using-namespace name="boost"/>
  11. <using-namespace name="boost::algorithm"/>
  12. <section it="string_algo.locale">
  13. <title>Locales</title>
  14. <para>
  15. Locales have a very close relation to string processing. They contain information about
  16. the character sets and are used, for example, to change the case of characters and
  17. to classify the characters.
  18. </para>
  19. <para>
  20. C++ allows to work with multiple different instances of locales at once. If an algorithm
  21. manipulates some data in a way that requires the usage of locales, there must be a way
  22. to specify them. However, one instance of locales is sufficient for most of the applications,
  23. and for a user it could be very tedious to specify which locales to use at every place
  24. where it is needed.
  25. </para>
  26. <para>
  27. Fortunately, the C++ standard allows to specify the <emphasis>global</emphasis> locales (using static member
  28. function <code>std:locale::global()</code>). When instantiating an
  29. <code>std::locale</code> class without explicit information, the instance will
  30. be initialized with the <emphasis>global</emphasis> locale. This implies, that if an algorithm needs a locale,
  31. it should have an <code>std::locale</code> parameter defaulting to <code>std::locale()</code>.
  32. If a user needs to specify locales explicitly, she can do so. Otherwise the <emphasis>global</emphasis>
  33. locales are used.
  34. </para>
  35. </section>
  36. <section id="string_algo.regex">
  37. <title>Regular Expressions</title>
  38. <para>
  39. Regular expressions are an essential part of text processing. For this reason, the library
  40. also provides regex variants of some algorithms. The library does not attempt to replace
  41. <libraryname>Boost.Regex</libraryname>; it merely wraps its functionality in a new interface.
  42. As a part of this library, regex algorithms integrate smoothly with other components, which
  43. brings additional value.
  44. </para>
  45. </section>
  46. </section>