mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-29 20:17:17 +02:00
Documentation update
[SVN r23559]
This commit is contained in:
@ -5,39 +5,9 @@
|
||||
<title>Rationale</title>
|
||||
|
||||
<using-namespace name="boost"/>
|
||||
<using-namespace name="boost::string_algo"/>
|
||||
<using-namespace name="boost::algorithm"/>
|
||||
|
||||
<section id="string_algo.structure">
|
||||
<title>Library structure</title>
|
||||
|
||||
<para>
|
||||
When designing a library it is always a problem to find a balance between generalization
|
||||
and usability. A generic utility can have a wider range of usage with more options for extensibility,
|
||||
but it can also bring unwanted complexity for everyday usage.
|
||||
</para>
|
||||
<para>
|
||||
Imagine a library for drawing geometric objects. It can contain one generic function <code>draw()</code>
|
||||
with many parameters specifying what to draw, like size, number of edges, shape etc.
|
||||
This would allow you to draw almost anything, but usually a user only needs to draw
|
||||
only a triangle or a square and she will have to specify this simple request in a
|
||||
very complicated way.For this purpose two functions, <code>draw_triangle()</code> and
|
||||
<code>draw_square()</code>, would suit much better then a generic <code>draw()</code> function.
|
||||
</para>
|
||||
<para>
|
||||
The String Algorithm Library solves this problem by dividing the interface into two layers.
|
||||
The first layer (defined in the namespace boost) contains ready to use algorithms specialized
|
||||
for common tasks. They are provided in multiple variants to better suit specific needs.
|
||||
The second layer (defined in the namespace <code>boost::string_algo</code>), provides generic interfaces with
|
||||
more options for extending and tunning.
|
||||
<para>
|
||||
</para>
|
||||
For instance, a <functionname>boost::trim()</functionname> algorithm trims spaces from
|
||||
an input string. When there is a need to trim something else, there is
|
||||
<functionname>boost::string_algo::trim()</functionname> which interface allows one to specify a
|
||||
predicate which selects the characters to be removed.
|
||||
</para>
|
||||
</section>
|
||||
<section it="string_algo.locale">
|
||||
<section it="string_algo.locale">
|
||||
<title>Locales</title>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user