forked from siddharthsonii/Hack-Fest-22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_example.html
174 lines (144 loc) · 21.2 KB
/
email_example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!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>// supress 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>