175 lines
21 KiB
HTML
175 lines
21 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>Boost.Assignment Documentation </title>
|
|
<link rel="stylesheet" href="style.css" type="text/css">
|
|
</head>
|
|
|
|
<body>
|
|
<pre>
|
|
<span class=comment>// Boost.Assign library
|
|
//
|
|
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
|
// distribution is subject to the Boost Software License, Version
|
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
// For more information, see http://www.boost.org/libs/assign/
|
|
//
|
|
|
|
</span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>detail</span><span class=special>/</span><span class=identifier>workaround</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>>
|
|
</span>
|
|
<span class=preprocessor>#if </span><span class=identifier>BOOST_WORKAROUND</span><span class=special>(</span><span class=identifier>__BORLANDC__</span><span class=special>, </span><span class=identifier>BOOST_TESTED_AT</span><span class=special>(</span><span class=number>0</span><span class=identifier>x564</span><span class=special>))</span>
|
|
###<span class=identifier>pragma </span><span class=identifier>warn </span><span class=special>-</span><span class=number>8091 </span><span class=comment>// suppress warning in Boost.Test</span>
|
|
###<span class=identifier>pragma </span><span class=identifier>warn </span><span class=special>-</span><span class=number>8057 </span><span class=comment>// unused argument argc/argv in Boost.Test</span>
|
|
<span class=preprocessor>#endif
|
|
</span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>assign</span><span class=special>/</span><span class=identifier>list_inserter</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>test</span><span class=special>/</span><span class=identifier>unit_test</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>test</span><span class=special>/</span><span class=identifier>test_tools</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>function</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>bind</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>vector</span><span class=special>></span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>map</span><span class=special>>
|
|
</span>
|
|
<span class=keyword>namespace </span><span class=identifier>ba </span><span class=special>= </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>assign</span><span class=special>;
|
|
</span>
|
|
<span class=keyword>class </span><span class=identifier>email</span>
|
|
<span class=special>{</span>
|
|
<span class=keyword>public</span><span class=special>:
|
|
</span><span class=keyword>enum </span><span class=identifier>address_option
|
|
</span><span class=special>{
|
|
</span><span class=identifier>check_addr_book</span><span class=special>,
|
|
</span><span class=identifier>dont_check_addr_book
|
|
</span><span class=special>};
|
|
|
|
</span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span><span class=identifier>address_option</span><span class=special>> </span><span class=identifier>bcc_type</span><span class=special>;
|
|
</span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>< </span><span class=identifier>bcc_type </span><span class=special>> </span><span class=identifier>bcc_map</span><span class=special>;
|
|
</span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>map</span><span class=special><</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>,</span><span class=identifier>address_option</span><span class=special>> </span><span class=identifier>address_map</span><span class=special>;
|
|
|
|
</span>
|
|
<span class=keyword>private</span><span class=special>:
|
|
|
|
</span><span class=keyword>mutable </span><span class=identifier>address_map </span><span class=identifier>cc_list</span><span class=special>;
|
|
</span><span class=keyword>mutable </span><span class=identifier>address_map </span><span class=identifier>to_list</span><span class=special>;
|
|
</span><span class=identifier>bcc_map </span><span class=identifier>bcc_list</span><span class=special>;
|
|
|
|
</span><span class=keyword>struct </span><span class=identifier>add_to_map
|
|
</span><span class=special>{
|
|
</span><span class=identifier>address_map</span><span class=special>& </span><span class=identifier>m</span><span class=special>;
|
|
|
|
</span><span class=identifier>add_to_map</span><span class=special>( </span><span class=identifier>address_map</span><span class=special>& </span><span class=identifier>m </span><span class=special>) </span><span class=special>: </span><span class=identifier>m</span><span class=special>(</span><span class=identifier>m</span><span class=special>)
|
|
</span><span class=special>{}
|
|
|
|
</span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()( </span><span class=keyword>const </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>name</span><span class=special>, </span><span class=identifier>address_option </span><span class=identifier>ao </span><span class=special>)
|
|
</span><span class=special>{
|
|
</span><span class=identifier>m</span><span class=special>[ </span><span class=identifier>name </span><span class=special>] </span><span class=special>= </span><span class=identifier>ao</span><span class=special>;
|
|
</span><span class=special>}
|
|
|
|
</span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()( </span><span class=keyword>const </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>name </span><span class=special>)
|
|
</span><span class=special>{
|
|
</span><span class=identifier>m</span><span class=special>[ </span><span class=identifier>name </span><span class=special>] </span><span class=special>= </span><span class=identifier>check_addr_book</span><span class=special>;
|
|
</span><span class=special>}
|
|
</span><span class=special>};
|
|
|
|
</span><span class=keyword>struct </span><span class=identifier>add_to_vector
|
|
</span><span class=special>{
|
|
</span><span class=identifier>bcc_map</span><span class=special>& </span><span class=identifier>m</span><span class=special>;
|
|
|
|
</span><span class=identifier>add_to_vector</span><span class=special>( </span><span class=identifier>bcc_map</span><span class=special>& </span><span class=identifier>m </span><span class=special>) </span><span class=special>: </span><span class=identifier>m</span><span class=special>(</span><span class=identifier>m</span><span class=special>)
|
|
</span><span class=special>{}
|
|
|
|
</span><span class=keyword>void </span><span class=keyword>operator</span><span class=special>()( </span><span class=keyword>const </span><span class=identifier>bcc_type</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
|
</span><span class=special>{
|
|
</span><span class=identifier>m</span><span class=special>.</span><span class=identifier>push_back</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
|
|
</span><span class=special>}
|
|
</span><span class=special>};
|
|
</span>
|
|
<span class=keyword>public</span><span class=special>:
|
|
|
|
</span><span class=identifier>ba</span><span class=special>::</span><span class=identifier>list_inserter</span><span class=special>< </span><span class=identifier>add_to_map </span><span class=special>>
|
|
</span><span class=identifier>add_cc</span><span class=special>( </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>name</span><span class=special>, </span><span class=identifier>address_option </span><span class=identifier>ao </span><span class=special>)
|
|
</span><span class=special>{
|
|
</span><span class=keyword>return </span><span class=identifier>ba</span><span class=special>::</span><span class=identifier>make_list_inserter</span><span class=special>( </span><span class=identifier>add_to_map</span><span class=special>( </span><span class=identifier>cc_list </span><span class=special>) </span><span class=special>)( </span><span class=identifier>name</span><span class=special>, </span><span class=identifier>ao </span><span class=special>);
|
|
</span><span class=special>}
|
|
|
|
</span><span class=identifier>ba</span><span class=special>::</span><span class=identifier>list_inserter</span><span class=special>< </span><span class=identifier>add_to_map </span><span class=special>>
|
|
</span><span class=identifier>add_to</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>name </span><span class=special>)
|
|
</span><span class=special>{
|
|
</span><span class=keyword>return </span><span class=identifier>ba</span><span class=special>::</span><span class=identifier>make_list_inserter</span><span class=special>( </span><span class=identifier>add_to_map</span><span class=special>( </span><span class=identifier>to_list </span><span class=special>) </span><span class=special>)( </span><span class=identifier>name </span><span class=special>);
|
|
</span><span class=special>}
|
|
|
|
</span><span class=identifier>ba</span><span class=special>::</span><span class=identifier>list_inserter</span><span class=special>< </span><span class=identifier>add_to_vector</span><span class=special>, </span><span class=identifier>bcc_type </span><span class=special>>
|
|
</span><span class=identifier>add_bcc</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>bcc_type</span><span class=special>& </span><span class=identifier>bcc </span><span class=special>)
|
|
</span><span class=special>{
|
|
</span><span class=keyword>return </span><span class=identifier>ba</span><span class=special>::</span><span class=identifier>make_list_inserter</span><span class=special>( </span><span class=identifier>add_to_vector</span><span class=special>( </span><span class=identifier>bcc_list </span><span class=special>) </span><span class=special>)( </span><span class=identifier>bcc </span><span class=special>);
|
|
</span><span class=special>}
|
|
|
|
</span><span class=identifier>address_option
|
|
</span><span class=identifier>cc_at</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>name </span><span class=special>) </span><span class=keyword>const
|
|
</span><span class=special>{
|
|
</span><span class=keyword>return </span><span class=identifier>cc_list</span><span class=special>[ </span><span class=identifier>name </span><span class=special>];
|
|
</span><span class=special>}
|
|
|
|
</span><span class=identifier>address_option
|
|
</span><span class=identifier>to_at</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string</span><span class=special>& </span><span class=identifier>name </span><span class=special>) </span><span class=keyword>const
|
|
</span><span class=special>{
|
|
</span><span class=keyword>return </span><span class=identifier>to_list</span><span class=special>[ </span><span class=identifier>name </span><span class=special>];
|
|
</span><span class=special>}
|
|
|
|
</span><span class=identifier>address_option
|
|
</span><span class=identifier>bcc_at</span><span class=special>( </span><span class=keyword>unsigned </span><span class=identifier>index </span><span class=special>) </span><span class=keyword>const
|
|
</span><span class=special>{
|
|
</span><span class=keyword>return </span><span class=identifier>bcc_list</span><span class=special>.</span><span class=identifier>at</span><span class=special>( </span><span class=identifier>index </span><span class=special>).</span><span class=identifier>second</span><span class=special>;
|
|
</span><span class=special>}</span>
|
|
<span class=special>};
|
|
|
|
|
|
</span>
|
|
<span class=keyword>void </span><span class=identifier>check_list_inserter</span><span class=special>()</span>
|
|
<span class=special>{
|
|
</span><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>assign</span><span class=special>;
|
|
|
|
</span><span class=identifier>email </span><span class=identifier>e</span><span class=special>;
|
|
</span><span class=identifier>e</span><span class=special>.</span><span class=identifier>add_cc</span><span class=special>( </span><span class=string>"franz"</span><span class=special>, </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>dont_check_addr_book </span><span class=special>)
|
|
</span><span class=special>( </span><span class=string>"hanz"</span><span class=special>, </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>check_addr_book </span><span class=special>)
|
|
</span><span class=special>( </span><span class=string>"betty"</span><span class=special>, </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>dont_check_addr_book </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>cc_at</span><span class=special>( </span><span class=string>"franz" </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>dont_check_addr_book </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>cc_at</span><span class=special>( </span><span class=string>"hanz" </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>check_addr_book </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>cc_at</span><span class=special>( </span><span class=string>"betty" </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>dont_check_addr_book </span><span class=special>);
|
|
|
|
</span><span class=identifier>e</span><span class=special>.</span><span class=identifier>add_to</span><span class=special>( </span><span class=string>"betsy" </span><span class=special>)( </span><span class=string>"peter" </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>cc_at</span><span class=special>( </span><span class=string>"betsy" </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>check_addr_book </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>cc_at</span><span class=special>( </span><span class=string>"peter" </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>check_addr_book </span><span class=special>);
|
|
|
|
</span><span class=identifier>e</span><span class=special>.</span><span class=identifier>add_bcc</span><span class=special>( </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>bcc_type</span><span class=special>( </span><span class=string>"Mr. Foo"</span><span class=special>, </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>check_addr_book </span><span class=special>) </span><span class=special>)
|
|
</span><span class=special>( </span><span class=string>"Mr. Bar"</span><span class=special>, </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>dont_check_addr_book </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>bcc_at</span><span class=special>( </span><span class=number>0 </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>check_addr_book </span><span class=special>);
|
|
</span><span class=identifier>BOOST_CHECK_EQUAL</span><span class=special>( </span><span class=identifier>e</span><span class=special>.</span><span class=identifier>bcc_at</span><span class=special>( </span><span class=number>1 </span><span class=special>), </span><span class=identifier>email</span><span class=special>::</span><span class=identifier>dont_check_addr_book </span><span class=special>);
|
|
</span>
|
|
<span class=special>}
|
|
|
|
|
|
</span>
|
|
<span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>test</span><span class=special>/</span><span class=identifier>included</span><span class=special>/</span><span class=identifier>unit_test_framework</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>>
|
|
</span>
|
|
<span class=keyword>using </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>unit_test_framework</span><span class=special>::</span><span class=identifier>test_suite</span><span class=special>;
|
|
</span>
|
|
<span class=identifier>test_suite</span><span class=special>* </span><span class=identifier>init_unit_test_suite</span><span class=special>( </span><span class=keyword>int </span><span class=identifier>argc</span><span class=special>, </span><span class=keyword>char</span><span class=special>* </span><span class=identifier>argv</span><span class=special>[] </span><span class=special>)</span>
|
|
<span class=special>{
|
|
</span><span class=identifier>test_suite</span><span class=special>* </span><span class=identifier>test </span><span class=special>= </span><span class=identifier>BOOST_TEST_SUITE</span><span class=special>( </span><span class=string>"List Test Suite" </span><span class=special>);
|
|
|
|
</span><span class=identifier>test</span><span class=special>-></span><span class=identifier>add</span><span class=special>( </span><span class=identifier>BOOST_TEST_CASE</span><span class=special>( </span><span class=special>&</span><span class=identifier>check_list_inserter </span><span class=special>) </span><span class=special>);
|
|
|
|
</span><span class=keyword>return </span><span class=identifier>test</span><span class=special>;</span>
|
|
<span class=special>}
|
|
|
|
</span>
|
|
|
|
</pre>
|
|
</body>
|
|
</html>
|