Browse Source

Importation du code depuis GitHub

gasc 2 years ago
commit
5be92a39b2

+ 674
- 0
LICENSE View File

@@ -0,0 +1,674 @@
1
+                    GNU GENERAL PUBLIC LICENSE
2
+                       Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+                            Preamble
9
+
10
+  The GNU General Public License is a free, copyleft license for
11
+software and other kinds of works.
12
+
13
+  The licenses for most software and other practical works are designed
14
+to take away your freedom to share and change the works.  By contrast,
15
+the GNU General Public License is intended to guarantee your freedom to
16
+share and change all versions of a program--to make sure it remains free
17
+software for all its users.  We, the Free Software Foundation, use the
18
+GNU General Public License for most of our software; it applies also to
19
+any other work released this way by its authors.  You can apply it to
20
+your programs, too.
21
+
22
+  When we speak of free software, we are referring to freedom, not
23
+price.  Our General Public Licenses are designed to make sure that you
24
+have the freedom to distribute copies of free software (and charge for
25
+them if you wish), that you receive source code or can get it if you
26
+want it, that you can change the software or use pieces of it in new
27
+free programs, and that you know you can do these things.
28
+
29
+  To protect your rights, we need to prevent others from denying you
30
+these rights or asking you to surrender the rights.  Therefore, you have
31
+certain responsibilities if you distribute copies of the software, or if
32
+you modify it: responsibilities to respect the freedom of others.
33
+
34
+  For example, if you distribute copies of such a program, whether
35
+gratis or for a fee, you must pass on to the recipients the same
36
+freedoms that you received.  You must make sure that they, too, receive
37
+or can get the source code.  And you must show them these terms so they
38
+know their rights.
39
+
40
+  Developers that use the GNU GPL protect your rights with two steps:
41
+(1) assert copyright on the software, and (2) offer you this License
42
+giving you legal permission to copy, distribute and/or modify it.
43
+
44
+  For the developers' and authors' protection, the GPL clearly explains
45
+that there is no warranty for this free software.  For both users' and
46
+authors' sake, the GPL requires that modified versions be marked as
47
+changed, so that their problems will not be attributed erroneously to
48
+authors of previous versions.
49
+
50
+  Some devices are designed to deny users access to install or run
51
+modified versions of the software inside them, although the manufacturer
52
+can do so.  This is fundamentally incompatible with the aim of
53
+protecting users' freedom to change the software.  The systematic
54
+pattern of such abuse occurs in the area of products for individuals to
55
+use, which is precisely where it is most unacceptable.  Therefore, we
56
+have designed this version of the GPL to prohibit the practice for those
57
+products.  If such problems arise substantially in other domains, we
58
+stand ready to extend this provision to those domains in future versions
59
+of the GPL, as needed to protect the freedom of users.
60
+
61
+  Finally, every program is threatened constantly by software patents.
62
+States should not allow patents to restrict development and use of
63
+software on general-purpose computers, but in those that do, we wish to
64
+avoid the special danger that patents applied to a free program could
65
+make it effectively proprietary.  To prevent this, the GPL assures that
66
+patents cannot be used to render the program non-free.
67
+
68
+  The precise terms and conditions for copying, distribution and
69
+modification follow.
70
+
71
+                       TERMS AND CONDITIONS
72
+
73
+  0. Definitions.
74
+
75
+  "This License" refers to version 3 of the GNU General Public License.
76
+
77
+  "Copyright" also means copyright-like laws that apply to other kinds of
78
+works, such as semiconductor masks.
79
+
80
+  "The Program" refers to any copyrightable work licensed under this
81
+License.  Each licensee is addressed as "you".  "Licensees" and
82
+"recipients" may be individuals or organizations.
83
+
84
+  To "modify" a work means to copy from or adapt all or part of the work
85
+in a fashion requiring copyright permission, other than the making of an
86
+exact copy.  The resulting work is called a "modified version" of the
87
+earlier work or a work "based on" the earlier work.
88
+
89
+  A "covered work" means either the unmodified Program or a work based
90
+on the Program.
91
+
92
+  To "propagate" a work means to do anything with it that, without
93
+permission, would make you directly or secondarily liable for
94
+infringement under applicable copyright law, except executing it on a
95
+computer or modifying a private copy.  Propagation includes copying,
96
+distribution (with or without modification), making available to the
97
+public, and in some countries other activities as well.
98
+
99
+  To "convey" a work means any kind of propagation that enables other
100
+parties to make or receive copies.  Mere interaction with a user through
101
+a computer network, with no transfer of a copy, is not conveying.
102
+
103
+  An interactive user interface displays "Appropriate Legal Notices"
104
+to the extent that it includes a convenient and prominently visible
105
+feature that (1) displays an appropriate copyright notice, and (2)
106
+tells the user that there is no warranty for the work (except to the
107
+extent that warranties are provided), that licensees may convey the
108
+work under this License, and how to view a copy of this License.  If
109
+the interface presents a list of user commands or options, such as a
110
+menu, a prominent item in the list meets this criterion.
111
+
112
+  1. Source Code.
113
+
114
+  The "source code" for a work means the preferred form of the work
115
+for making modifications to it.  "Object code" means any non-source
116
+form of a work.
117
+
118
+  A "Standard Interface" means an interface that either is an official
119
+standard defined by a recognized standards body, or, in the case of
120
+interfaces specified for a particular programming language, one that
121
+is widely used among developers working in that language.
122
+
123
+  The "System Libraries" of an executable work include anything, other
124
+than the work as a whole, that (a) is included in the normal form of
125
+packaging a Major Component, but which is not part of that Major
126
+Component, and (b) serves only to enable use of the work with that
127
+Major Component, or to implement a Standard Interface for which an
128
+implementation is available to the public in source code form.  A
129
+"Major Component", in this context, means a major essential component
130
+(kernel, window system, and so on) of the specific operating system
131
+(if any) on which the executable work runs, or a compiler used to
132
+produce the work, or an object code interpreter used to run it.
133
+
134
+  The "Corresponding Source" for a work in object code form means all
135
+the source code needed to generate, install, and (for an executable
136
+work) run the object code and to modify the work, including scripts to
137
+control those activities.  However, it does not include the work's
138
+System Libraries, or general-purpose tools or generally available free
139
+programs which are used unmodified in performing those activities but
140
+which are not part of the work.  For example, Corresponding Source
141
+includes interface definition files associated with source files for
142
+the work, and the source code for shared libraries and dynamically
143
+linked subprograms that the work is specifically designed to require,
144
+such as by intimate data communication or control flow between those
145
+subprograms and other parts of the work.
146
+
147
+  The Corresponding Source need not include anything that users
148
+can regenerate automatically from other parts of the Corresponding
149
+Source.
150
+
151
+  The Corresponding Source for a work in source code form is that
152
+same work.
153
+
154
+  2. Basic Permissions.
155
+
156
+  All rights granted under this License are granted for the term of
157
+copyright on the Program, and are irrevocable provided the stated
158
+conditions are met.  This License explicitly affirms your unlimited
159
+permission to run the unmodified Program.  The output from running a
160
+covered work is covered by this License only if the output, given its
161
+content, constitutes a covered work.  This License acknowledges your
162
+rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+  You may make, run and propagate covered works that you do not
165
+convey, without conditions so long as your license otherwise remains
166
+in force.  You may convey covered works to others for the sole purpose
167
+of having them make modifications exclusively for you, or provide you
168
+with facilities for running those works, provided that you comply with
169
+the terms of this License in conveying all material for which you do
170
+not control copyright.  Those thus making or running the covered works
171
+for you must do so exclusively on your behalf, under your direction
172
+and control, on terms that prohibit them from making any copies of
173
+your copyrighted material outside their relationship with you.
174
+
175
+  Conveying under any other circumstances is permitted solely under
176
+the conditions stated below.  Sublicensing is not allowed; section 10
177
+makes it unnecessary.
178
+
179
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+  No covered work shall be deemed part of an effective technological
182
+measure under any applicable law fulfilling obligations under article
183
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+similar laws prohibiting or restricting circumvention of such
185
+measures.
186
+
187
+  When you convey a covered work, you waive any legal power to forbid
188
+circumvention of technological measures to the extent such circumvention
189
+is effected by exercising rights under this License with respect to
190
+the covered work, and you disclaim any intention to limit operation or
191
+modification of the work as a means of enforcing, against the work's
192
+users, your or third parties' legal rights to forbid circumvention of
193
+technological measures.
194
+
195
+  4. Conveying Verbatim Copies.
196
+
197
+  You may convey verbatim copies of the Program's source code as you
198
+receive it, in any medium, provided that you conspicuously and
199
+appropriately publish on each copy an appropriate copyright notice;
200
+keep intact all notices stating that this License and any
201
+non-permissive terms added in accord with section 7 apply to the code;
202
+keep intact all notices of the absence of any warranty; and give all
203
+recipients a copy of this License along with the Program.
204
+
205
+  You may charge any price or no price for each copy that you convey,
206
+and you may offer support or warranty protection for a fee.
207
+
208
+  5. Conveying Modified Source Versions.
209
+
210
+  You may convey a work based on the Program, or the modifications to
211
+produce it from the Program, in the form of source code under the
212
+terms of section 4, provided that you also meet all of these conditions:
213
+
214
+    a) The work must carry prominent notices stating that you modified
215
+    it, and giving a relevant date.
216
+
217
+    b) The work must carry prominent notices stating that it is
218
+    released under this License and any conditions added under section
219
+    7.  This requirement modifies the requirement in section 4 to
220
+    "keep intact all notices".
221
+
222
+    c) You must license the entire work, as a whole, under this
223
+    License to anyone who comes into possession of a copy.  This
224
+    License will therefore apply, along with any applicable section 7
225
+    additional terms, to the whole of the work, and all its parts,
226
+    regardless of how they are packaged.  This License gives no
227
+    permission to license the work in any other way, but it does not
228
+    invalidate such permission if you have separately received it.
229
+
230
+    d) If the work has interactive user interfaces, each must display
231
+    Appropriate Legal Notices; however, if the Program has interactive
232
+    interfaces that do not display Appropriate Legal Notices, your
233
+    work need not make them do so.
234
+
235
+  A compilation of a covered work with other separate and independent
236
+works, which are not by their nature extensions of the covered work,
237
+and which are not combined with it such as to form a larger program,
238
+in or on a volume of a storage or distribution medium, is called an
239
+"aggregate" if the compilation and its resulting copyright are not
240
+used to limit the access or legal rights of the compilation's users
241
+beyond what the individual works permit.  Inclusion of a covered work
242
+in an aggregate does not cause this License to apply to the other
243
+parts of the aggregate.
244
+
245
+  6. Conveying Non-Source Forms.
246
+
247
+  You may convey a covered work in object code form under the terms
248
+of sections 4 and 5, provided that you also convey the
249
+machine-readable Corresponding Source under the terms of this License,
250
+in one of these ways:
251
+
252
+    a) Convey the object code in, or embodied in, a physical product
253
+    (including a physical distribution medium), accompanied by the
254
+    Corresponding Source fixed on a durable physical medium
255
+    customarily used for software interchange.
256
+
257
+    b) Convey the object code in, or embodied in, a physical product
258
+    (including a physical distribution medium), accompanied by a
259
+    written offer, valid for at least three years and valid for as
260
+    long as you offer spare parts or customer support for that product
261
+    model, to give anyone who possesses the object code either (1) a
262
+    copy of the Corresponding Source for all the software in the
263
+    product that is covered by this License, on a durable physical
264
+    medium customarily used for software interchange, for a price no
265
+    more than your reasonable cost of physically performing this
266
+    conveying of source, or (2) access to copy the
267
+    Corresponding Source from a network server at no charge.
268
+
269
+    c) Convey individual copies of the object code with a copy of the
270
+    written offer to provide the Corresponding Source.  This
271
+    alternative is allowed only occasionally and noncommercially, and
272
+    only if you received the object code with such an offer, in accord
273
+    with subsection 6b.
274
+
275
+    d) Convey the object code by offering access from a designated
276
+    place (gratis or for a charge), and offer equivalent access to the
277
+    Corresponding Source in the same way through the same place at no
278
+    further charge.  You need not require recipients to copy the
279
+    Corresponding Source along with the object code.  If the place to
280
+    copy the object code is a network server, the Corresponding Source
281
+    may be on a different server (operated by you or a third party)
282
+    that supports equivalent copying facilities, provided you maintain
283
+    clear directions next to the object code saying where to find the
284
+    Corresponding Source.  Regardless of what server hosts the
285
+    Corresponding Source, you remain obligated to ensure that it is
286
+    available for as long as needed to satisfy these requirements.
287
+
288
+    e) Convey the object code using peer-to-peer transmission, provided
289
+    you inform other peers where the object code and Corresponding
290
+    Source of the work are being offered to the general public at no
291
+    charge under subsection 6d.
292
+
293
+  A separable portion of the object code, whose source code is excluded
294
+from the Corresponding Source as a System Library, need not be
295
+included in conveying the object code work.
296
+
297
+  A "User Product" is either (1) a "consumer product", which means any
298
+tangible personal property which is normally used for personal, family,
299
+or household purposes, or (2) anything designed or sold for incorporation
300
+into a dwelling.  In determining whether a product is a consumer product,
301
+doubtful cases shall be resolved in favor of coverage.  For a particular
302
+product received by a particular user, "normally used" refers to a
303
+typical or common use of that class of product, regardless of the status
304
+of the particular user or of the way in which the particular user
305
+actually uses, or expects or is expected to use, the product.  A product
306
+is a consumer product regardless of whether the product has substantial
307
+commercial, industrial or non-consumer uses, unless such uses represent
308
+the only significant mode of use of the product.
309
+
310
+  "Installation Information" for a User Product means any methods,
311
+procedures, authorization keys, or other information required to install
312
+and execute modified versions of a covered work in that User Product from
313
+a modified version of its Corresponding Source.  The information must
314
+suffice to ensure that the continued functioning of the modified object
315
+code is in no case prevented or interfered with solely because
316
+modification has been made.
317
+
318
+  If you convey an object code work under this section in, or with, or
319
+specifically for use in, a User Product, and the conveying occurs as
320
+part of a transaction in which the right of possession and use of the
321
+User Product is transferred to the recipient in perpetuity or for a
322
+fixed term (regardless of how the transaction is characterized), the
323
+Corresponding Source conveyed under this section must be accompanied
324
+by the Installation Information.  But this requirement does not apply
325
+if neither you nor any third party retains the ability to install
326
+modified object code on the User Product (for example, the work has
327
+been installed in ROM).
328
+
329
+  The requirement to provide Installation Information does not include a
330
+requirement to continue to provide support service, warranty, or updates
331
+for a work that has been modified or installed by the recipient, or for
332
+the User Product in which it has been modified or installed.  Access to a
333
+network may be denied when the modification itself materially and
334
+adversely affects the operation of the network or violates the rules and
335
+protocols for communication across the network.
336
+
337
+  Corresponding Source conveyed, and Installation Information provided,
338
+in accord with this section must be in a format that is publicly
339
+documented (and with an implementation available to the public in
340
+source code form), and must require no special password or key for
341
+unpacking, reading or copying.
342
+
343
+  7. Additional Terms.
344
+
345
+  "Additional permissions" are terms that supplement the terms of this
346
+License by making exceptions from one or more of its conditions.
347
+Additional permissions that are applicable to the entire Program shall
348
+be treated as though they were included in this License, to the extent
349
+that they are valid under applicable law.  If additional permissions
350
+apply only to part of the Program, that part may be used separately
351
+under those permissions, but the entire Program remains governed by
352
+this License without regard to the additional permissions.
353
+
354
+  When you convey a copy of a covered work, you may at your option
355
+remove any additional permissions from that copy, or from any part of
356
+it.  (Additional permissions may be written to require their own
357
+removal in certain cases when you modify the work.)  You may place
358
+additional permissions on material, added by you to a covered work,
359
+for which you have or can give appropriate copyright permission.
360
+
361
+  Notwithstanding any other provision of this License, for material you
362
+add to a covered work, you may (if authorized by the copyright holders of
363
+that material) supplement the terms of this License with terms:
364
+
365
+    a) Disclaiming warranty or limiting liability differently from the
366
+    terms of sections 15 and 16 of this License; or
367
+
368
+    b) Requiring preservation of specified reasonable legal notices or
369
+    author attributions in that material or in the Appropriate Legal
370
+    Notices displayed by works containing it; or
371
+
372
+    c) Prohibiting misrepresentation of the origin of that material, or
373
+    requiring that modified versions of such material be marked in
374
+    reasonable ways as different from the original version; or
375
+
376
+    d) Limiting the use for publicity purposes of names of licensors or
377
+    authors of the material; or
378
+
379
+    e) Declining to grant rights under trademark law for use of some
380
+    trade names, trademarks, or service marks; or
381
+
382
+    f) Requiring indemnification of licensors and authors of that
383
+    material by anyone who conveys the material (or modified versions of
384
+    it) with contractual assumptions of liability to the recipient, for
385
+    any liability that these contractual assumptions directly impose on
386
+    those licensors and authors.
387
+
388
+  All other non-permissive additional terms are considered "further
389
+restrictions" within the meaning of section 10.  If the Program as you
390
+received it, or any part of it, contains a notice stating that it is
391
+governed by this License along with a term that is a further
392
+restriction, you may remove that term.  If a license document contains
393
+a further restriction but permits relicensing or conveying under this
394
+License, you may add to a covered work material governed by the terms
395
+of that license document, provided that the further restriction does
396
+not survive such relicensing or conveying.
397
+
398
+  If you add terms to a covered work in accord with this section, you
399
+must place, in the relevant source files, a statement of the
400
+additional terms that apply to those files, or a notice indicating
401
+where to find the applicable terms.
402
+
403
+  Additional terms, permissive or non-permissive, may be stated in the
404
+form of a separately written license, or stated as exceptions;
405
+the above requirements apply either way.
406
+
407
+  8. Termination.
408
+
409
+  You may not propagate or modify a covered work except as expressly
410
+provided under this License.  Any attempt otherwise to propagate or
411
+modify it is void, and will automatically terminate your rights under
412
+this License (including any patent licenses granted under the third
413
+paragraph of section 11).
414
+
415
+  However, if you cease all violation of this License, then your
416
+license from a particular copyright holder is reinstated (a)
417
+provisionally, unless and until the copyright holder explicitly and
418
+finally terminates your license, and (b) permanently, if the copyright
419
+holder fails to notify you of the violation by some reasonable means
420
+prior to 60 days after the cessation.
421
+
422
+  Moreover, your license from a particular copyright holder is
423
+reinstated permanently if the copyright holder notifies you of the
424
+violation by some reasonable means, this is the first time you have
425
+received notice of violation of this License (for any work) from that
426
+copyright holder, and you cure the violation prior to 30 days after
427
+your receipt of the notice.
428
+
429
+  Termination of your rights under this section does not terminate the
430
+licenses of parties who have received copies or rights from you under
431
+this License.  If your rights have been terminated and not permanently
432
+reinstated, you do not qualify to receive new licenses for the same
433
+material under section 10.
434
+
435
+  9. Acceptance Not Required for Having Copies.
436
+
437
+  You are not required to accept this License in order to receive or
438
+run a copy of the Program.  Ancillary propagation of a covered work
439
+occurring solely as a consequence of using peer-to-peer transmission
440
+to receive a copy likewise does not require acceptance.  However,
441
+nothing other than this License grants you permission to propagate or
442
+modify any covered work.  These actions infringe copyright if you do
443
+not accept this License.  Therefore, by modifying or propagating a
444
+covered work, you indicate your acceptance of this License to do so.
445
+
446
+  10. Automatic Licensing of Downstream Recipients.
447
+
448
+  Each time you convey a covered work, the recipient automatically
449
+receives a license from the original licensors, to run, modify and
450
+propagate that work, subject to this License.  You are not responsible
451
+for enforcing compliance by third parties with this License.
452
+
453
+  An "entity transaction" is a transaction transferring control of an
454
+organization, or substantially all assets of one, or subdividing an
455
+organization, or merging organizations.  If propagation of a covered
456
+work results from an entity transaction, each party to that
457
+transaction who receives a copy of the work also receives whatever
458
+licenses to the work the party's predecessor in interest had or could
459
+give under the previous paragraph, plus a right to possession of the
460
+Corresponding Source of the work from the predecessor in interest, if
461
+the predecessor has it or can get it with reasonable efforts.
462
+
463
+  You may not impose any further restrictions on the exercise of the
464
+rights granted or affirmed under this License.  For example, you may
465
+not impose a license fee, royalty, or other charge for exercise of
466
+rights granted under this License, and you may not initiate litigation
467
+(including a cross-claim or counterclaim in a lawsuit) alleging that
468
+any patent claim is infringed by making, using, selling, offering for
469
+sale, or importing the Program or any portion of it.
470
+
471
+  11. Patents.
472
+
473
+  A "contributor" is a copyright holder who authorizes use under this
474
+License of the Program or a work on which the Program is based.  The
475
+work thus licensed is called the contributor's "contributor version".
476
+
477
+  A contributor's "essential patent claims" are all patent claims
478
+owned or controlled by the contributor, whether already acquired or
479
+hereafter acquired, that would be infringed by some manner, permitted
480
+by this License, of making, using, or selling its contributor version,
481
+but do not include claims that would be infringed only as a
482
+consequence of further modification of the contributor version.  For
483
+purposes of this definition, "control" includes the right to grant
484
+patent sublicenses in a manner consistent with the requirements of
485
+this License.
486
+
487
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+patent license under the contributor's essential patent claims, to
489
+make, use, sell, offer for sale, import and otherwise run, modify and
490
+propagate the contents of its contributor version.
491
+
492
+  In the following three paragraphs, a "patent license" is any express
493
+agreement or commitment, however denominated, not to enforce a patent
494
+(such as an express permission to practice a patent or covenant not to
495
+sue for patent infringement).  To "grant" such a patent license to a
496
+party means to make such an agreement or commitment not to enforce a
497
+patent against the party.
498
+
499
+  If you convey a covered work, knowingly relying on a patent license,
500
+and the Corresponding Source of the work is not available for anyone
501
+to copy, free of charge and under the terms of this License, through a
502
+publicly available network server or other readily accessible means,
503
+then you must either (1) cause the Corresponding Source to be so
504
+available, or (2) arrange to deprive yourself of the benefit of the
505
+patent license for this particular work, or (3) arrange, in a manner
506
+consistent with the requirements of this License, to extend the patent
507
+license to downstream recipients.  "Knowingly relying" means you have
508
+actual knowledge that, but for the patent license, your conveying the
509
+covered work in a country, or your recipient's use of the covered work
510
+in a country, would infringe one or more identifiable patents in that
511
+country that you have reason to believe are valid.
512
+
513
+  If, pursuant to or in connection with a single transaction or
514
+arrangement, you convey, or propagate by procuring conveyance of, a
515
+covered work, and grant a patent license to some of the parties
516
+receiving the covered work authorizing them to use, propagate, modify
517
+or convey a specific copy of the covered work, then the patent license
518
+you grant is automatically extended to all recipients of the covered
519
+work and works based on it.
520
+
521
+  A patent license is "discriminatory" if it does not include within
522
+the scope of its coverage, prohibits the exercise of, or is
523
+conditioned on the non-exercise of one or more of the rights that are
524
+specifically granted under this License.  You may not convey a covered
525
+work if you are a party to an arrangement with a third party that is
526
+in the business of distributing software, under which you make payment
527
+to the third party based on the extent of your activity of conveying
528
+the work, and under which the third party grants, to any of the
529
+parties who would receive the covered work from you, a discriminatory
530
+patent license (a) in connection with copies of the covered work
531
+conveyed by you (or copies made from those copies), or (b) primarily
532
+for and in connection with specific products or compilations that
533
+contain the covered work, unless you entered into that arrangement,
534
+or that patent license was granted, prior to 28 March 2007.
535
+
536
+  Nothing in this License shall be construed as excluding or limiting
537
+any implied license or other defenses to infringement that may
538
+otherwise be available to you under applicable patent law.
539
+
540
+  12. No Surrender of Others' Freedom.
541
+
542
+  If conditions are imposed on you (whether by court order, agreement or
543
+otherwise) that contradict the conditions of this License, they do not
544
+excuse you from the conditions of this License.  If you cannot convey a
545
+covered work so as to satisfy simultaneously your obligations under this
546
+License and any other pertinent obligations, then as a consequence you may
547
+not convey it at all.  For example, if you agree to terms that obligate you
548
+to collect a royalty for further conveying from those to whom you convey
549
+the Program, the only way you could satisfy both those terms and this
550
+License would be to refrain entirely from conveying the Program.
551
+
552
+  13. Use with the GNU Affero General Public License.
553
+
554
+  Notwithstanding any other provision of this License, you have
555
+permission to link or combine any covered work with a work licensed
556
+under version 3 of the GNU Affero General Public License into a single
557
+combined work, and to convey the resulting work.  The terms of this
558
+License will continue to apply to the part which is the covered work,
559
+but the special requirements of the GNU Affero General Public License,
560
+section 13, concerning interaction through a network will apply to the
561
+combination as such.
562
+
563
+  14. Revised Versions of this License.
564
+
565
+  The Free Software Foundation may publish revised and/or new versions of
566
+the GNU General Public License from time to time.  Such new versions will
567
+be similar in spirit to the present version, but may differ in detail to
568
+address new problems or concerns.
569
+
570
+  Each version is given a distinguishing version number.  If the
571
+Program specifies that a certain numbered version of the GNU General
572
+Public License "or any later version" applies to it, you have the
573
+option of following the terms and conditions either of that numbered
574
+version or of any later version published by the Free Software
575
+Foundation.  If the Program does not specify a version number of the
576
+GNU General Public License, you may choose any version ever published
577
+by the Free Software Foundation.
578
+
579
+  If the Program specifies that a proxy can decide which future
580
+versions of the GNU General Public License can be used, that proxy's
581
+public statement of acceptance of a version permanently authorizes you
582
+to choose that version for the Program.
583
+
584
+  Later license versions may give you additional or different
585
+permissions.  However, no additional obligations are imposed on any
586
+author or copyright holder as a result of your choosing to follow a
587
+later version.
588
+
589
+  15. Disclaimer of Warranty.
590
+
591
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+  16. Limitation of Liability.
601
+
602
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+SUCH DAMAGES.
611
+
612
+  17. Interpretation of Sections 15 and 16.
613
+
614
+  If the disclaimer of warranty and limitation of liability provided
615
+above cannot be given local legal effect according to their terms,
616
+reviewing courts shall apply local law that most closely approximates
617
+an absolute waiver of all civil liability in connection with the
618
+Program, unless a warranty or assumption of liability accompanies a
619
+copy of the Program in return for a fee.
620
+
621
+                     END OF TERMS AND CONDITIONS
622
+
623
+            How to Apply These Terms to Your New Programs
624
+
625
+  If you develop a new program, and you want it to be of the greatest
626
+possible use to the public, the best way to achieve this is to make it
627
+free software which everyone can redistribute and change under these terms.
628
+
629
+  To do so, attach the following notices to the program.  It is safest
630
+to attach them to the start of each source file to most effectively
631
+state the exclusion of warranty; and each file should have at least
632
+the "copyright" line and a pointer to where the full notice is found.
633
+
634
+    <one line to give the program's name and a brief idea of what it does.>
635
+    Copyright (C) <year>  <name of author>
636
+
637
+    This program is free software: you can redistribute it and/or modify
638
+    it under the terms of the GNU General Public License as published by
639
+    the Free Software Foundation, either version 3 of the License, or
640
+    (at your option) any later version.
641
+
642
+    This program is distributed in the hope that it will be useful,
643
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
645
+    GNU General Public License for more details.
646
+
647
+    You should have received a copy of the GNU General Public License
648
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
649
+
650
+Also add information on how to contact you by electronic and paper mail.
651
+
652
+  If the program does terminal interaction, make it output a short
653
+notice like this when it starts in an interactive mode:
654
+
655
+    <program>  Copyright (C) <year>  <name of author>
656
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+    This is free software, and you are welcome to redistribute it
658
+    under certain conditions; type `show c' for details.
659
+
660
+The hypothetical commands `show w' and `show c' should show the appropriate
661
+parts of the General Public License.  Of course, your program's commands
662
+might be different; for a GUI interface, you would use an "about box".
663
+
664
+  You should also get your employer (if you work as a programmer) or school,
665
+if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+For more information on this, and how to apply and follow the GNU GPL, see
667
+<https://www.gnu.org/licenses/>.
668
+
669
+  The GNU General Public License does not permit incorporating your program
670
+into proprietary programs.  If your program is a subroutine library, you
671
+may consider it more useful to permit linking proprietary applications with
672
+the library.  If this is what you want to do, use the GNU Lesser General
673
+Public License instead of this License.  But first, please read
674
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 6
- 0
README.md View File

@@ -0,0 +1,6 @@
1
+# TDDE18CppCourse
2
+Sharing of my labs carried out during the TDDE18 course at Linköping University. Some scripts to compile and then run the programs are also available in some folders.
3
+
4
+## Debugging
5
+In order to compile test programs, you will need the [Catch 2 debugging framework](https://github.com/catchorg/Catch2). Place the *catch.hpp* file in the lab2 folder and now you can build all programs.
6
+

+ 29
- 0
lab1/build_and_run.sh View File

@@ -0,0 +1,29 @@
1
+#!/bin/bash
2
+
3
+if test $# -ne 1
4
+then
5
+	echo "One argument expected : source file."
6
+	exit 1
7
+elif test ! -f $1
8
+then
9
+	echo "The specified file doesn't exist."
10
+	exit 1
11
+fi
12
+
13
+echo "Starting building..."
14
+g++ -Wall -Wextra -Wpedantic -std=c++17 $1 -o $1.out
15
+
16
+if test $? -eq 0
17
+then
18
+	echo "Build finished. Running..."
19
+	echo ""
20
+	./$1.out
21
+	echo ""
22
+	echo "Done. Cleaning..."
23
+	rm $1.out
24
+	echo "Done."
25
+else
26
+	echo "Build failed."
27
+fi
28
+
29
+exit 0

+ 5
- 0
lab1/data.txt View File

@@ -0,0 +1,5 @@
1
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer dictum volutpat lacus, at congue turpis volutpat at. Sed scelerisque porttitor nunc. Phasellus dui ligula, tincidunt id laoreet ac, tincidunt vel sem. Quisque eleifend at massa fringilla ultricies. Phasellus ultrices turpis non risus sodales maximus. Aenean sed accumsan dui. Donec sagittis, mi eget dignissim auctor, erat massa tempor sapien, nec pellentesque risus ipsum in nunc. In euismod lacinia ex et pellentesque. Morbi non nibh viverra, sodales ipsum at, condimentum nisl. Aenean elementum lectus vel mauris aliquam gravida. Sed eu neque non ligula bibendum elementum. Proin fermentum non magna eget fermentum. Morbi et quam mattis metus tincidunt tempor non at tortor. Phasellus vel velit ultricies, fermentum magna id, condimentum nibh. Proin turpis velit, finibus maximus iaculis eget, tempus et est.
2
+
3
+Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Vivamus ultricies est eu orci ultrices, a rhoncus arcu commodo. Donec eu nibh rutrum, imperdiet mauris non, hendrerit ante. Ut id tristique urna. Sed bibendum odio in ante pellentesque, ac feugiat nibh ultrices. Cras a commodo ex, vitae scelerisque massa. In ac dui erat. Ut nulla massa, tincidunt et nibh vitae, porttitor mattis turpis. Donec enim libero, ullamcorper et luctus quis, tempus vel dui. Nulla sagittis dignissim lectus, non bibendum dui efficitur pretium. Vestibulum laoreet nisi sed ullamcorper eleifend. Fusce placerat rhoncus finibus. Morbi ut tempor lectus. Aliquam aliquam maximus vestibulum. Vivamus pulvinar est ac tincidunt dictum.
4
+
5
+Suspendisse fermentum id magna sed rutrum. In nunc ligula, malesuada et tincidunt eu, euismod id velit. Etiam tempus non lorem et venenatis. Nunc sagittis viverra nulla, et pharetra velit eleifend eget. Nunc tincidunt diam sed facilisis placerat. Nunc pretium nisl a massa pharetra, a tincidunt magna fringilla. Nunc luctus vel tellus sed rutrum. Mauris imperdiet, purus ut laoreet efficitur, nisi mi varius. 

+ 77
- 0
lab1/file_and_streams.cc View File

@@ -0,0 +1,77 @@
1
+/* 
2
+Lab 1 - File and streams
3
+Last modification : 2020-09-04
4
+*/
5
+
6
+#include <iostream>
7
+#include <fstream>
8
+#include <string>
9
+
10
+using namespace std;
11
+
12
+/*TODO:
13
+1-1 --> done
14
+5-5 --> done
15
+
16
+Try to avoid comments on the same line as code
17
+--> done
18
+*/
19
+
20
+int main() {
21
+    ifstream myFile("./data.txt");
22
+
23
+    // If the file has been correctly opened
24
+    if (myFile) { 
25
+       
26
+        // variable declaration 
27
+        string word{};
28
+        string longest_word{};
29
+        string shortest_word{};
30
+        int word_count{};
31
+        int lw_size{};
32
+        int sw_size{100};
33
+        int length_sum{};
34
+        double aver_length{};
35
+
36
+        /*
37
+        In this while loop, we will go through the whole file in order to draw statistics.
38
+        We count each word, each character (to get the average word length at the end of the algorithm)
39
+        and for each word we check if it is the longest or the shortest word encountered so far.
40
+        */
41
+        while (myFile >> word){
42
+            // We count the number of words.
43
+            word_count++;
44
+            // We count the number of characters (only word characters).
45
+            length_sum += word.length();
46
+
47
+            // We check if the actual word is the longest met so far.
48
+            if ((int)word.length() > lw_size) {
49
+                longest_word = word;
50
+                lw_size = word.length();
51
+            }
52
+            // We check if the actual word is the shortest met so far.
53
+            else if ((int)word.length() < sw_size) {
54
+                shortest_word = word;
55
+                sw_size = word.length();
56
+            }
57
+        }
58
+
59
+        // If our file is NOT empty
60
+        if (word_count > 0) {
61
+            // We calculate the average length of a word with the formula: 
62
+            // total number of characters / number of words
63
+            aver_length = static_cast <double> (length_sum) / static_cast <double> (word_count);
64
+
65
+            cout << "There are " << word_count << " words in the file." << endl;
66
+            cout << "The shortest word was \"" << shortest_word << "\" with " << sw_size << " character(s)." << endl;
67
+            cout << "The longest word was \"" << longest_word << "\" with " << lw_size << " character(s)." << endl;
68
+            cout << "The average length was " << aver_length << " character(s)." << endl;
69
+        }
70
+        else {
71
+            cerr << "ERROR : Empty file." << endl;
72
+        }
73
+    }
74
+    else {cerr << "ERROR: Could not open file for reading.";}
75
+
76
+    return 0;
77
+}

+ 115
- 0
lab1/in_out.cc View File

@@ -0,0 +1,115 @@
1
+/* 
2
+Lab 1 - TDDE18 - Basic I/O
3
+Last modification : 2020-09-02
4
+*/
5
+
6
+#include <iostream>
7
+#include <iomanip>
8
+#include <string>
9
+
10
+using namespace std;
11
+
12
+/*Comment:
13
+Really good looking code. Well written and consistant syntax
14
+Try to avoid comments on the same line as code and only use if it's
15
+not obvious what that code is doing.
16
+
17
+--> done: Removal of unnecessary comments, separation of code lines and comment lines.
18
+*/
19
+
20
+// A function to clean cin input
21
+void clean() {
22
+    cin.ignore(1000,'\n');
23
+}
24
+
25
+int main() {
26
+    // List of authorized variables
27
+    int integer{};
28
+    char character{};
29
+    double real{};
30
+    string str{""};
31
+
32
+
33
+    cout << "Enter one integer: ";
34
+    cin >> integer;
35
+    cout << "You entered the number: " << integer << "\n" <<endl;
36
+    // Cleaning the buffer in case of the user gave more than 1 integer
37
+    clean();
38
+
39
+    cout << "Enter four integers: ";
40
+    cin  >> integer;
41
+    cout << "You entered the numbers: " << integer << " ";
42
+    cin  >> integer;
43
+    cout << integer << " ";
44
+    cin  >> integer;
45
+    cout << integer << " ";
46
+    cin  >> integer;
47
+    cout << integer << "\n" << endl;
48
+    clean();
49
+
50
+    cout << "Enter one integer and one real number: ";
51
+    cin >> integer;
52
+    cin >> real;
53
+    // Here, we use setw() to force the width and setprecision() to force the number of decimals
54
+    cout << "The real is: " << setw(10)
55
+        << fixed << setprecision(3)
56
+        << real << endl;
57
+    cout << "The integer is: " << setw(7) << integer << "\n" << endl;
58
+    clean();
59
+
60
+    cout << "Enter one real and one integer number: ";
61
+    cin >> real;
62
+    cin >> integer;
63
+    cout << "The real is: " << setw(10) << setfill('.') << fixed << setprecision(3) << real << endl;
64
+    cout << "The integer is: " << setw(7) << setfill('.')
65
+        << integer << "\n" << endl;
66
+    clean();
67
+
68
+    cout << "Enter a character: ";
69
+    cin >> character;
70
+    cout << "You entered: " << character << "\n" << endl;
71
+    clean();
72
+
73
+    cout << "Enter a word: ";
74
+    cin >> str;
75
+    cout << "The word '" << str << "' has " << str.length() << " character(s)." << "\n" << endl;
76
+    clean();
77
+
78
+    cout << "Enter an integer and a word: ";
79
+    cin >> integer;
80
+    cin >> str;
81
+    cout << "You entered ’"<< integer <<"’ and ’" << str << "’." << "\n" << endl;
82
+    clean();
83
+
84
+    cout << "Enter an character and a word: ";
85
+    cin >> character;
86
+    cin >> str;
87
+    cout << "You entered the string \"" << str << "\" and the character ’" << character << "’." << "\n" << endl;
88
+    clean();
89
+
90
+    cout << "Enter a word and a real number: ";
91
+    cin >> str;
92
+    cin >> real;
93
+    cout << "You entered \"" << str << "\" and \"" << real << "\"." << "\n" << endl;
94
+    clean();
95
+
96
+    cout << "Enter a text-line: ";
97
+    // Read the entire line (stop when it finds a \n)
98
+    getline (cin, str);
99
+    cout << "You entered: \"" << str << "\"\n" << endl;
100
+
101
+    cout << "Enter a second line of text: ";
102
+    getline (cin, str);
103
+    cout << "You entered: \"" << str << "\"\n" << endl;
104
+
105
+    cout << "Enter three words: ";
106
+    cin  >> str;
107
+    cout << "You entered: '" << str << " ";
108
+    cin  >> str;
109
+    cout << str << " ";
110
+    cin  >> str;
111
+    cout << str << "'" << endl;
112
+    clean();
113
+
114
+    return 0;
115
+}

+ 131
- 0
lab1/select_and_rep.cc View File

@@ -0,0 +1,131 @@
1
+/* 
2
+Lab 1 - TDDE18 - Selection and repetition
3
+Last modification : 2020-09-03
4
+*/
5
+
6
+#include <iostream>
7
+#include <iomanip>
8
+
9
+/*
10
+1-1 --> done
11
+
12
+Try to avoid comments on the same line as code
13
+--> done
14
+
15
+Statements should have it's own block declared underneath
16
+it so its easier to read.
17
+    Ex  if()
18
+        {
19
+--> done
20
+
21
+use std:setw() and std::setfill(-) instead of a for loop to write
22
+--> done
23
+
24
+Use the give information to calculate the steps and then use a for loop
25
+instead of while() and adding the stride.
26
+Adding floats will eventually end up in errors because a float isn't precise
27
+which you avoid by using doubles, but worth noting.
28
+By calculating the amount of steps its guaranteed no errors will occur
29
+--> done: change the final while loop to a for loop
30
+*/
31
+
32
+using namespace std;
33
+
34
+int main() 
35
+{
36
+    double first_price{};
37
+    double last_price{};
38
+    double stride{};
39
+    double tax{};
40
+    bool is_ok{false};
41
+
42
+    // I/O begin
43
+    cout << "INPUT PART" << endl;
44
+    cout << "==========" << endl;
45
+
46
+    // For each value, we check the consistency of the given value
47
+    while (!is_ok) 
48
+    {
49
+        cout << "Enter first price: ";
50
+        cin >> first_price;
51
+
52
+        if (first_price >= 0) 
53
+        {
54
+            is_ok = true;
55
+        }
56
+        else 
57
+        {
58
+            cout << "ERROR: First price must be at least 0 (zero) SEK" << endl;
59
+        }
60
+    }
61
+    
62
+    is_ok = false;
63
+    while (!is_ok) {
64
+        cout << "Enter last price: ";
65
+        cin >> last_price;
66
+
67
+        if (last_price >= first_price) 
68
+        {
69
+            is_ok = true;
70
+        }
71
+        else 
72
+        {
73
+            cout << "ERROR: The last price must be greater than or equal to the first price (" 
74
+                << first_price << " SEK)" << endl;
75
+        }
76
+    }
77
+
78
+    is_ok = false;
79
+    while (!is_ok) {
80
+        cout << "Enter stride     : ";
81
+        cin >> stride;
82
+
83
+        if (stride >= 0.01) 
84
+        {
85
+            is_ok = true;
86
+        }
87
+        else 
88
+        {
89
+            cout << "ERROR: Stride must be at least 0.01" << endl;
90
+        }
91
+    }
92
+    
93
+    is_ok = false;
94
+    while (!is_ok) {
95
+        cout << "Enter tax percent: ";
96
+        cin >> tax;
97
+
98
+        if (0 <= tax && tax <= 100) 
99
+        {
100
+            is_ok = true;
101
+        }
102
+        else 
103
+        {
104
+            cout << "ERROR: The tax value cannot be negative or greater than 100%" << endl;
105
+        }
106
+    }
107
+    cout << endl;
108
+
109
+    // Percent correction
110
+    tax = tax * 0.01;
111
+
112
+    cout << "TAX TABLE" << endl;
113
+    cout << "=========" << endl;
114
+    cout << setw(12) << "Price" << setw(12) << "Tax" << setw(20) << "Price with tax" << endl;
115
+    cout << setfill('-') << setw(45) << " " << setfill(' ') << endl;
116
+
117
+    // We calculate the necessary number of iteration 
118
+    int number_of_interation = static_cast <int> (last_price - first_price)/stride;
119
+
120
+    double price = first_price;
121
+    for (int i = 0; i <= number_of_interation; i++)
122
+    {
123
+        cout << fixed << setprecision(2) << setw(12) 
124
+            << price << setw(12) 
125
+            << price*tax << setw(20) 
126
+            << price + price*tax << endl;
127
+        price += stride;
128
+    }
129
+
130
+    return 0;
131
+}

+ 0
- 0
lab1/void.txt View File


+ 19
- 0
lab2/build_and_run.sh View File

@@ -0,0 +1,19 @@
1
+#!/bin/bash
2
+
3
+echo "Starting building..."
4
+g++ -Wall -Wextra -Wpedantic -std=c++17 *.cc *.h -o out.o
5
+
6
+if test $? -eq 0
7
+then
8
+	echo "Build finished. Running..."
9
+	echo ""
10
+	./out.o -s
11
+	echo ""
12
+	echo "Done. Cleaning..."
13
+	rm out.o
14
+	echo "Done."
15
+else
16
+	echo "Build failed."
17
+fi
18
+
19
+exit 0

+ 136
- 0
lab2/test_main.cc View File

@@ -0,0 +1,136 @@
1
+#define CATCH_CONFIG_MAIN
2
+#include "catch.hpp"
3
+
4
+#include <iostream>
5
+#include <string>
6
+
7
+#include "time.h"
8
+
9
+using namespace std;
10
+
11
+TEST_CASE("Testing declaration and basic functions"){
12
+    Time t{};
13
+    Time t1{15, 45, 56};
14
+    
15
+    REQUIRE(to_string(t, false) == "00:00:00");
16
+    REQUIRE(to_string(t1, true) == "03:45:56 pm");
17
+}
18
+
19
+TEST_CASE("Testing is_am()"){
20
+    Time t1{5, 45, 56};
21
+    Time t2{18, 34, 51};
22
+    
23
+    REQUIRE(is_am(t1));
24
+    REQUIRE_FALSE(is_am(t2));
25
+}
26
+
27
+TEST_CASE("Testing is_valid()"){
28
+    Time t1{5, 45, 56};
29
+    Time t2{65, 34, 51};
30
+    Time t3{3, -34, 51};
31
+
32
+    REQUIRE(is_valid(t1));
33
+    REQUIRE_FALSE(is_valid(t2));
34
+    REQUIRE_FALSE(is_valid(t3));
35
+}
36
+
37
+TEST_CASE("Testing equality operator == and != "){
38
+    Time t1{04, 42, 06};
39
+    Time t2{18, 34, 01};
40
+    Time t3{18, 34, 1};
41
+
42
+    REQUIRE(t1 == t1);
43
+    REQUIRE(t2 == t3);
44
+    REQUIRE_FALSE(t1 == t2);
45
+
46
+    REQUIRE(t1 != t2);
47
+    REQUIRE_FALSE(t2 != t3);
48
+}
49
+
50
+/*************** Complementary work ***************/
51
+/* TODO: You also need to test if the objects passed to operator+ has
52
+ * been modified or not*/
53
+//  --> done
54
+/**************************************************/
55
+
56
+// Not required for this lab
57
+TEST_CASE("Testing + and - operators (between Time)"){
58
+    Time t1{5, 45, 56};
59
+    Time t1_copy{5, 45, 56};
60
+    Time t3{11, 31, 52};
61
+    Time t4{00, 01, 01};
62
+    Time t5{11, 32, 53};
63
+
64
+    REQUIRE(t1 + t1 == t3);
65
+    REQUIRE(t1 == t1_copy);
66
+    REQUIRE(t3 + t4 == t5);
67
+}
68
+
69
+TEST_CASE("Testing + and - operators (between Time and int)"){
70
+    Time t1{5, 45, 56};
71
+    Time t1_copy{5, 45, 56};
72
+    Time t3{6, 45, 57};
73
+
74
+    REQUIRE(t1 + 0 == t1);
75
+    REQUIRE(t1 + 3601 == t3);
76
+    REQUIRE(t1 == t1_copy);
77
+    REQUIRE(t1 + 86400 == t1);
78
+}
79
+
80
+TEST_CASE("Testing incrementation, ++ and -- operators"){
81
+    Time t1{5, 45, 56};
82
+    Time t2{5, 45, 57};
83
+    Time t1_copy{5, 45, 56};
84
+
85
+    CHECK(t1++ == t1_copy);
86
+    CHECK(t1 == t2);
87
+    t2++;
88
+    CHECK(++t1 == t2);
89
+    CHECK(t1 == t2);
90
+
91
+    CHECK(t2-- == t1);
92
+    CHECK(t2 == --t1);
93
+}
94
+
95
+TEST_CASE("Testing comparison operators: >, <, >=, <="){
96
+    Time t1{11, 31, 52};
97
+    Time t2{11, 31, 52};
98
+    Time t3{6, 45, 57};
99
+
100
+    REQUIRE(t3 < t2);
101
+    REQUIRE_FALSE(t1 < t2);
102
+
103
+    REQUIRE(t1 <= t1);
104
+    REQUIRE(t1 >= t1);
105
+    REQUIRE(t3 <= t1);
106
+    REQUIRE(t1 >= t3);
107
+    REQUIRE_FALSE(t1 <= t3);
108
+}
109
+
110
+TEST_CASE("Testing stream operators << and >>"){
111
+    Time t{6, 45, 57};
112
+    Time t_check{12, 34, 23};
113
+
114
+    ostringstream oss{};
115
+    oss << t;
116
+    REQUIRE(oss.str() == to_string(t));
117
+
118
+    istringstream iss{to_string(t_check)};
119
+    iss >> t;
120
+    REQUIRE(t == t_check);
121
+    REQUIRE(iss.eof());
122
+
123
+/*************** Complementary work ***************/
124
+/* TODO: You also need to check if the time object has been modified
125
+ * or not, add this after fixing the issue in time.cc*/
126
+//  --> done
127
+/**************************************************/
128
+
129
+    t_check = t;
130
+    istringstream iss_fail{"16:-3:18"};
131
+    iss_fail >> t;
132
+
133
+    REQUIRE(iss_fail.fail());
134
+    REQUIRE(t == t_check);
135
+    iss_fail.clear();
136
+}

+ 218
- 0
lab2/time.cc View File

@@ -0,0 +1,218 @@
1
+#include "time.h"
2
+
3
+/*************** Complementary work ***************/
4
+/* TODO: A better way to implement this function is to just return the
5
+ * boolean condition in the if statement right away since it will have
6
+ * the same affect and increase readability. The same way you did in
7
+ * the "is_am" function*/
8
+//  --> done
9
+/**************************************************/
10
+
11
+bool is_valid(Time const& t) {
12
+    return (t.hours >= 0 && t.minutes >= 0 && t.secondes >= 0 
13
+        && t.hours < 24 && t.minutes < 60 && t.secondes < 60);
14
+}
15
+
16
+bool is_am(Time const& t) {
17
+    return (t.hours % 12 == t.hours);
18
+}
19
+
20
+// A function which convert a int into a 2-digits formated string 
21
+std::string formated_int_to_string(int i){
22
+    std::string str = std::to_string(i);
23
+    if (str.length() < 2){
24
+        str = "0" + str;
25
+    }
26
+    return str;
27
+}
28
+
29
+/***************** Comment *****************/
30
+/* A better way to convert the Time object to a string is to use a
31
+ * stringstream. A stringstream is just like the ostream that you are
32
+ * used to, the same iomanip manipulators works on it and once your
33
+ * done you can convert its contents to a string by using its .str() function*/
34
+//  --> done
35
+/*******************************************/
36
+std::string to_string(Time const& t,bool format) {
37
+    std::stringstream string_stream{};
38
+    string_stream << std::setfill('0');
39
+    if (format){
40
+        string_stream << std::setw(2) << t.hours % 12;
41
+    }
42
+    else {
43
+        string_stream << std::setw(2) << t.hours;
44
+    }
45
+    string_stream << ":" << std::setw(2) << t.minutes 
46
+                << ":" << std::setw(2) << t.secondes;
47
+    if (format) {
48
+        if (is_am(t)){
49
+            string_stream << " am";
50
+        }
51
+        else {
52
+            string_stream << " pm";
53
+        }
54
+    }
55
+    return string_stream.str();
56
+}
57
+
58
+// Deprecated to_string function
59
+std::string old_to_string(Time const& t,bool format) {
60
+    std::string time_string{};
61
+
62
+    if (format){
63
+        time_string = formated_int_to_string(t.hours % 12) + ":" + formated_int_to_string(t.minutes) + ":"
64
+            + formated_int_to_string(t.secondes);
65
+        if (is_am(t)) {
66
+            time_string += " am";
67
+        }
68
+        else {
69
+            time_string += " pm";
70
+        }
71
+    }
72
+    else {
73
+        time_string = formated_int_to_string(t.hours) + ":" + formated_int_to_string(t.minutes) + ":"
74
+            + formated_int_to_string(t.secondes);
75
+    }
76
+    return time_string;
77
+}
78
+
79
+Time operator+(Time const& t1, Time const& t2){
80
+    return Time{(t1.hours + t2.hours + (t1.minutes+t2.minutes + (t1.secondes+t2.secondes)/60)/60) % 24,
81
+                (t1.minutes + t2.minutes + (t1.secondes+t2.secondes)/60) % 60,
82
+                (t1.secondes + t2.secondes) % 60};
83
+}
84
+
85
+Time operator-(Time const& t1, Time const& t2){
86
+    Time diff{(t1.hours - t2.hours + (t1.minutes-t2.minutes + (t1.secondes-t2.secondes)/60)/60) % 24,
87
+                (t1.minutes - t2.minutes + (t1.secondes-t2.secondes)/60) % 60,
88
+                (t1.secondes - t2.secondes) % 60};
89
+
90
+    if (diff.hours < 0){
91
+        diff.hours = 24 + diff.hours;
92
+    }
93
+    if (diff.minutes < 0){
94
+        diff.minutes = 60 + diff.minutes; 
95
+        diff.hours--;
96
+    }
97
+    if (diff.secondes < 0){
98
+        diff.secondes = 60 + diff.secondes; 
99
+        diff.minutes--;
100
+    }
101
+    return diff;
102
+}
103
+
104
+Time operator+(Time const& t, int x){
105
+    return t + Time{0, 0, x};
106
+}
107
+
108
+Time operator-(Time const& t, int x){
109
+    return t - Time{0, 0, x};
110
+}
111
+
112
+/*************** Complementary work ***************/
113
+/* TODO: Code duplication, you can use the operator+ here to make the
114
+ * function a lot shorter. The same goes for operator--*/
115
+//  --> done
116
+//  --> 2nd complementary work done: Use of the operator implemented above.
117
+//      Fixing operator--. 
118
+/**************************************************/
119
+Time& operator++(Time& t){
120
+    t = t + 1;
121
+    return t;
122
+}
123
+
124
+Time operator++(Time& t, int){
125
+    Time tmp{t};
126
+    ++t;
127
+    return tmp;
128
+}
129
+
130
+Time& operator--(Time& t){
131
+    t = t - 1;
132
+    return t;
133
+}
134
+
135
+Time operator--(Time& t, int){
136
+    Time tmp = t;
137
+    --t;
138
+    return tmp;
139
+}
140
+
141
+bool operator<(Time const& t1, Time const& t2){
142
+    if (t1.hours < t2.hours){
143
+        return true;
144
+    }
145
+    else if (t1.hours > t2.hours){
146
+        return false;
147
+    }
148
+    else {
149
+        if (t1.minutes < t2.minutes){
150
+            return true;
151
+        }
152
+        else if (t1.minutes > t2.minutes){
153
+            return false;
154
+        }
155
+        else {
156
+            if (t1.secondes < t2.secondes){
157
+                return true;
158
+            }
159
+            else {
160
+                return false;
161
+            }
162
+        }
163
+    }
164
+
165
+}
166
+
167
+bool operator>(Time const& t1, Time const& t2){
168
+    return t2 < t1;
169
+}
170
+
171
+bool operator==(Time const& t1, Time const& t2){
172
+    return t1.hours == t2.hours && t1.minutes == t2.minutes && t1.secondes == t2.secondes;
173
+}
174
+
175
+bool operator!=(Time const& t1, Time const& t2){
176
+    return !(t1 == t2);
177
+}
178
+
179
+bool operator<=(Time const& t1, Time const& t2){
180
+    return t1 < t2 || t1 == t2;
181
+}
182
+
183
+bool operator>=(Time const& t1, Time const& t2){
184
+    return t1 > t2 || t1 == t2;
185
+}
186
+
187
+std::ostream& operator<<(std::ostream& os, Time const& t){
188
+    os << to_string(t, false);
189
+    return os;
190
+}
191
+
192
+std::istream& operator>>(std::istream& is, Time& t){
193
+
194
+/*************** Complementary work ***************/
195
+/* TODO: It is not ok to modify the given Time object before knowing
196
+ * if the input is good or not. First check if the input is fine then
197
+ * modify the object, refrain from modifying the object if the input is bad.*/
198
+//  --> done
199
+/**************************************************/    
200
+    
201
+    char c{};
202
+    Time tmp{};
203
+    
204
+    is >> tmp.hours;
205
+    is >> c;
206
+    is >> tmp.minutes;
207
+    is >> c;
208
+    is >> tmp.secondes;
209
+
210
+    if (!is_valid(tmp)){
211
+        is.setstate(std::ios_base::failbit);
212
+    }
213
+    else {
214
+        t = tmp;
215
+    }
216
+
217
+    return is;
218
+}

+ 97
- 0
lab2/time.h View File

@@ -0,0 +1,97 @@
1
+#ifndef TIME_H
2
+#define TIME_H
3
+#include <string>
4
+#include <iostream>
5
+#include <iomanip>
6
+
7
+/***************** Comment *****************/
8
+/* Nice looking header file, well done!*/
9
+/*******************************************/
10
+
11
+/* 
12
+Lab 2 - TDDE18 - Time lab
13
+Last modification : 2020-09-16
14
+*/
15
+
16
+
17
+/// Structure time 
18
+struct Time
19
+{
20
+    int hours{};
21
+    int minutes{};
22
+    int secondes{}; 
23
+};
24
+
25
+/*************** Complementary work ***************/
26
+/* TODO: You must take time as a const reference in order to save
27
+ * performance and in order to promise the user that the given Time
28
+ * object will not be modified. This is true for the thtree following
29
+ * functions*/
30
+//  --> done
31
+/**************************************************/
32
+
33
+/// A function which check if a time is valid.
34
+bool is_valid(Time const& t);
35
+
36
+/// A function which check a time is after noon.
37
+bool is_am(Time const& t);
38
+
39
+/// A function which convert a time to a string. You can specify the time format.
40
+std::string to_string(Time const& t, bool format = false);
41
+
42
+/***************** Comment *****************/
43
+/* Well done with the declarations of the +/- operators! */
44
+/*******************************************/
45
+
46
+/////////////////
47
+/// Operators ///
48
+/////////////////
49
+
50
+/// Time + Time (not asked for lab 2)
51
+Time operator+(Time const& t1, Time const& t2);
52
+
53
+/// Time - Time (not asked for lab 2)
54
+Time operator-(Time const& t1, Time const& t2); 
55
+
56
+/// Time + integer
57
+Time operator+(Time const& t, int x);
58
+
59
+/// Time - integer
60
+Time operator-(Time const& t, int x);
61
+
62
+/// Time++
63
+Time& operator++(Time& t);      // prefix
64
+Time operator++(Time& t, int);  // postfix
65
+
66
+/// Time--
67
+Time& operator--(Time& t);      // prefix
68
+Time operator--(Time& t, int);  // postfix
69
+
70
+
71
+/// Time < Time comparison
72
+bool operator<(Time const& t1, Time const& t2);
73
+
74
+/// Time > Time comparison
75
+bool operator>(Time const& t1, Time const& t2);
76
+
77
+/// Time == Time comparison
78
+bool operator==(Time const& t1, Time const& t2);
79
+
80
+/// Time != Time comparison
81
+bool operator!=(Time const& t1, Time const& t2);
82
+
83
+/// Time <= Time comparison
84
+bool operator<=(Time const& t1, Time const& t2);
85
+
86
+/// Time >= Time comparison
87
+bool operator>=(Time const& t1, Time const& t2);
88
+
89
+
90
+/// Stream operators overloading <<
91
+std::ostream& operator<<(std::ostream& os, Time const& t);
92
+
93
+/// Operator <<
94
+/// The entry must be be in the format HH:SS:MM.
95
+std::istream& operator>>(std::istream& is, Time& t);
96
+
97
+#endif

+ 38
- 0
lab3/build_and_run.sh View File

@@ -0,0 +1,38 @@
1
+#!/bin/bash
2
+# TDDE18 - Lab 3
3
+
4
+echo "Compilation, execution and debugging script for TDDE18 C ++ labs."
5
+echo "Pass the \"-v\" argument to run Valgrind and \"-q\" for synthetic output."
6
+echo ""
7
+
8
+echo "Starting building..."
9
+if [ "$1" = "-q" ]
10
+	then g++ -Wall -Wextra -Wpedantic -std=c++17 *.cc *.h -o out.o
11
+	else time g++ -v -Wall -Wextra -Wpedantic -std=c++17 *.cc *.h -o out.o
12
+fi
13
+
14
+if test $? -eq 0
15
+then
16
+	echo "Build finished. Running..."
17
+	echo ""
18
+	if [ "$1" = "-q" ]
19
+		then ./out.o
20
+		else ./out.o -s
21
+	fi
22
+	echo ""
23
+	if [ "$1" = "-v" ]
24
+	then
25
+		echo "Done. Launching valgrind..."
26
+		echo ""
27
+		valgrind --tool=memcheck --leak-check=yes ./out.o
28
+		echo ""
29
+	fi
30
+	echo "Done. Cleaning..."
31
+	rm out.o
32
+	echo "Done."
33
+else
34
+	echo "Build failed."
35
+	exit 1
36
+fi
37
+
38
+exit 0

+ 175
- 0
lab3/sorted_list.cc View File

@@ -0,0 +1,175 @@
1
+#include "sorted_list.h"
2
+#include <stdexcept>
3
+#include <iostream>
4
+
5
+/* Lab 3 - TDDE18 - Sorted list lab - Source file */
6
+
7
+
8
+////////////////////////////////
9
+/// Special member functions ///
10
+////////////////////////////////
11
+
12
+/// Default constructor
13
+Sorted_List::Sorted_List(): first{nullptr}
14
+{
15
+}
16
+
17
+/// Copy constructor
18
+Sorted_List::Sorted_List(Sorted_List const& other) {
19
+    Node* current = other.first;
20
+
21
+    while (current) {
22
+        insert(current->value);
23
+        current = current->next;
24
+    }
25
+}
26
+
27
+/// "Nice" constructor
28
+Sorted_List::Sorted_List(std::initializer_list<int> list) {
29
+    for (int i : list) {
30
+        insert(i);
31
+    }
32
+}
33
+
34
+/// Move constructor
35
+Sorted_List::Sorted_List(Sorted_List&& other) : first{other.first} {
36
+    other.first = nullptr;
37
+}
38
+
39
+/// Move assignment
40
+Sorted_List& Sorted_List::operator=(Sorted_List&& other) {
41
+    Sorted_List tmp{};
42
+    std::swap(tmp.first, first);
43
+    std::swap(first, other.first);
44
+    return *this;
45
+}
46
+
47
+/// Destructor
48
+Sorted_List::~Sorted_List() {
49
+    Node* tmp{first};
50
+
51
+    // We browse the list and delete nodes one by one
52
+    while (tmp){
53
+        Node* next{tmp->next};
54
+        delete tmp;
55
+        tmp = next;
56
+    }
57
+}
58
+
59
+/// Copy assignment operator
60
+Sorted_List& Sorted_List::operator=(Sorted_List const& other){
61
+    Sorted_List tmp(other);
62
+    std::swap(tmp.first, this->first);
63
+    return *this;
64
+}
65
+
66
+
67
+///////////////
68
+/// Methods ///
69
+///////////////
70
+
71
+/*  Public insert function calling the private one
72
+    We have created two list to be able to have a
73
+    recursive insert function. */
74
+void Sorted_List::insert(int val) {
75
+    insert(first, val);
76
+}
77
+
78
+/*  Private insert function, taking a reference to a
79
+    pointer and the value to insert. */
80
+void Sorted_List::insert(Node*& first, int val) {
81
+    // If the list is empty
82
+    if (!first){
83
+        first = new Node{val, nullptr};
84
+    }
85
+    // Else if the next node is greater than the value
86
+    // i.e. we have to insert between two nodes
87
+    else if (first->value > val) {
88
+        first = new Node{val, first};
89
+    }
90
+    // Else if we are at the end of the list
91
+    else if (!first->next) {
92
+        first->next = new Node{val, nullptr};
93
+    }
94
+    // Else we must insert later in the list
95
+    else {
96
+        insert(first->next, val);
97
+    }
98
+}
99
+
100
+/// Iterative remove function
101
+void Sorted_List::remove(int val) {
102
+    /* Keeping in memory the current
103
+       node and its predecessor. */
104
+    Node* current = first;
105
+    Node* previous = first;
106
+
107
+    // We browse the list
108
+    while (current) {
109
+        // If the node has the sought value
110
+        if (current->value == val) {
111
+            // If it is the first one we must do otherwise to avoid memory leaks
112
+            if (current == first){
113
+                Node* tmp{first};
114
+                first = current->next;
115
+                delete tmp;
116
+                return;
117
+            }
118
+            else {
119
+                previous->next = current->next;
120
+                delete current;
121
+                return;
122
+            }
123
+        }
124
+        /* If we find a value greater than the sought value, that's
125
+           means that the value isn't in the list. We stop here. */
126
+        else if (current->value > val)
127
+        {
128
+            break;
129
+        }
130
+        previous = current;
131
+        current = current->next;
132
+    }
133
+    // If we exit the loop with no value found, we raise a error.
134
+    throw std::logic_error{"Remove(): The searched item is not in the list."};
135
+}
136
+
137
+bool Sorted_List::is_empty() const {
138
+    return first == nullptr;
139
+}
140
+
141
+int Sorted_List::size() const {
142
+    int count{0};
143
+    Node* current = first;
144
+
145
+    while (current){
146
+        count++;
147
+        current = current->next;
148
+    }
149
+    return count;
150
+}
151
+
152
+int Sorted_List::at(int pos) const {
153
+    if (is_empty()) {
154
+        throw std::logic_error{"At(): The given list is empty."};
155
+    }
156
+    Node* tmp{first};
157
+    while (pos > 0){
158
+        if (! tmp->next) { 
159
+            throw std::logic_error{"At(): The given index value is too large."};
160
+        }
161
+        --pos;
162
+        tmp = tmp->next;
163
+    }
164
+    return tmp->value;
165
+}
166
+
167
+std::string Sorted_List::to_string() const {
168
+    std::string str{"[ "};
169
+    Node* tmp{first};
170
+    while (tmp){
171
+        str += std::to_string(tmp->value) + " ";
172
+        tmp = tmp->next;
173
+    }
174
+    return str + "]";
175
+}

+ 74
- 0
lab3/sorted_list.h View File

@@ -0,0 +1,74 @@
1
+#ifndef SORTED_LIST_H
2
+#define SORTED_LIST_H
3
+
4
+#include <string>
5
+
6
+/*
7
+Lab 3 - TDDE18 - Sorted list lab - Header file
8
+Last modification : 2020-09-30
9
+*/
10
+
11
+// Note: The other TODO remarks are in the test_list.cc file
12
+
13
+//TODO: Complementary work needed, 8-8: The link class and any functions pertaining it
14
+// should be stashed away and inaccessible to user. --> done (by moving Node struct declaration
15
+// in Sorted_List private part).
16
+//TODO: Complementary work needed, 8-8: Should have a function at() which should get
17
+// a value from place n in list. --> done (by implementing at() function and creating tests).
18
+
19
+//COMMENT: Good job with no memory leaks!
20
+
21
+
22
+/// A structure representing a list node 
23
+/*
24
+struct Node {
25
+    int value;
26
+    Node* next;
27
+};*/
28
+
29
+/// A class representing a sorted list
30
+/// The list is sorted from smallest to largest value
31
+class Sorted_List{
32
+public:
33
+
34
+    /// Constructors
35
+    // Default constructor
36
+    Sorted_List();
37
+    // Copy constructor
38
+    Sorted_List(Sorted_List const& other);
39
+    // "Nice" constructor (actually, no idea how to name it)
40
+    Sorted_List(std::initializer_list<int> list);
41
+    // Move constructor
42
+    Sorted_List(Sorted_List&& other);
43
+
44
+    /// Destructor
45
+    ~Sorted_List();
46
+
47
+    // Copy assignment operator
48
+    Sorted_List& operator=(Sorted_List const& other);
49
+    // Move assignment operator
50
+    Sorted_List& operator=(Sorted_List&& other);
51
+
52
+    // Insert a value in the list
53
+    void insert(int val);
54
+    // Remove a value of the list, raise error if the value does not exist
55
+    void remove(int val);
56
+    // Check if a list is empty
57
+    bool is_empty() const;
58
+    // Return the size of a list
59
+    int size() const;
60
+    // Return the value at a given position
61
+    int at(int pos) const;
62
+    // Convert a list to string
63
+    std::string to_string() const;
64
+
65
+private:
66
+    struct Node {
67
+        int value;
68
+        Node* next;
69
+    };
70
+    Node* first{};
71
+    void insert(Node*& first, int val);
72
+};
73
+
74
+#endif

+ 197
- 0
lab3/test_list.cc View File

@@ -0,0 +1,197 @@
1
+#define CATCH_CONFIG_MAIN
2
+#include "../lab2/catch.hpp"
3
+#include "sorted_list.h"
4
+
5
+/*
6
+    Lab 3 - TDDE18 - Sorted list lab - Test file
7
+    Using catch.hpp framework, documentation :
8
+    https://github.com/philsquared/Catch/blob/master/docs/tutorial.md
9
+*/
10
+
11
+// Note: The other TODO remarks are in the sorted_list.h file
12
+
13
+//TODO: Complementary work needed, 8-8: Test cases are insufficient, what if a list is
14
+//empty? --> done (addition of test in most TEST_CASES where these tests were not 
15
+//carried out).
16
+//TODO: Complementary work needed, 8-8: Test cases insufficient, you should test
17
+//all functionality for copy, such as remove values in the copied list and if this
18
+//affects the original. --> done (adding tests to check that a modification of the 
19
+//original does not affect the copy and vice versa).
20
+
21
+
22
+using namespace std;
23
+
24
+//=======================================================================
25
+// Test cases
26
+//=======================================================================
27
+
28
+TEST_CASE("Testing basic functions on empty list") {
29
+  Sorted_List l{};
30
+
31
+  REQUIRE(l.size() == 0);
32
+  REQUIRE(l.is_empty());
33
+  REQUIRE(l.to_string() == "[ ]");
34
+}
35
+
36
+TEST_CASE("Insertion in a list") {
37
+  Sorted_List l{};
38
+
39
+  l.insert(1);
40
+  l.insert(8);
41
+  l.insert(5);
42
+  l.insert(8);
43
+  l.insert(-1);
44
+
45
+  REQUIRE_FALSE(l.is_empty());
46
+  REQUIRE(l.size() == 5);
47
+  REQUIRE(l.to_string() == "[ -1 1 5 8 8 ]");
48
+}
49
+
50
+TEST_CASE("Removal tests") {
51
+  Sorted_List l{};
52
+  Sorted_List void_l{};
53
+
54
+  l.insert(1);
55
+  l.insert(8);
56
+  l.insert(5);
57
+  l.insert(8);
58
+  l.insert(-1);
59
+
60
+  REQUIRE_NOTHROW(l.remove(-1));
61
+  REQUIRE(l.size() == 4);
62
+  REQUIRE_NOTHROW(l.remove(8));
63
+  REQUIRE(l.size() == 3);
64
+  REQUIRE_NOTHROW(l.remove(8));
65
+  REQUIRE(l.size() == 2);
66
+  REQUIRE(l.to_string() == "[ 1 5 ]");
67
+
68
+  REQUIRE_THROWS(l.remove(4));
69
+  REQUIRE_THROWS(void_l.remove(0));
70
+}
71
+
72
+TEST_CASE("Testing the 'nice' constructor") {
73
+  Sorted_List l{1,-2, 7};
74
+  Sorted_List l2{};
75
+  REQUIRE(l.to_string() == "[ -2 1 7 ]");
76
+  REQUIRE(l2.to_string() == "[ ]");
77
+}
78
+
79
+TEST_CASE("Testing copy constructor") {
80
+  Sorted_List l{1, 8, 5};
81
+  Sorted_List l_copy{l};
82
+  Sorted_List l_void{};
83
+  Sorted_List void_copy{l_void};
84
+
85
+  REQUIRE_FALSE(l_copy.is_empty());
86
+  REQUIRE(l.to_string() == "[ 1 5 8 ]");
87
+  REQUIRE(l_copy.to_string() == "[ 1 5 8 ]");
88
+  REQUIRE(void_copy.is_empty());
89
+  REQUIRE(void_copy.to_string() == l_void.to_string());
90
+
91
+  // We check that the copy is not affected
92
+  l.remove(8);
93
+  REQUIRE_FALSE(l_copy.is_empty());
94
+  REQUIRE(l_copy.to_string() == "[ 1 5 8 ]");
95
+  l_void.insert(5);
96
+  REQUIRE(void_copy.is_empty());
97
+  l_void.remove(5);
98
+
99
+  // We check that the original is also not affected
100
+  l_copy.remove(5);
101
+  REQUIRE(l_copy.to_string() == "[ 1 8 ]");
102
+  REQUIRE(l.to_string() == "[ 1 5 ]");
103
+  void_copy.insert(7);
104
+  REQUIRE(l_void.is_empty());
105
+}
106
+
107
+TEST_CASE("Testing copy assignment operator") {
108
+  Sorted_List l{1, 8, 5};
109
+  Sorted_List l2{};
110
+  Sorted_List l_copy = l;
111
+  Sorted_List l2_copy = l2;
112
+
113
+  REQUIRE(l.to_string() == "[ 1 5 8 ]");
114
+  REQUIRE(l_copy.to_string() == "[ 1 5 8 ]");
115
+
116
+  // We check that the copy is not affected by original and vice versa
117
+  l.remove(8);
118
+  REQUIRE(l.to_string() == "[ 1 5 ]");
119
+  REQUIRE(l_copy.to_string() == "[ 1 5 8 ]");
120
+  l.insert(8);
121
+  l_copy.remove(5);
122
+  REQUIRE(l.to_string() == "[ 1 5 8 ]");
123
+  REQUIRE(l_copy.to_string() == "[ 1 8 ]");
124
+
125
+  l = l2;
126
+  REQUIRE(l.is_empty());
127
+  REQUIRE(l_copy.to_string() == "[ 1 8 ]");
128
+
129
+  // Same on empty lists
130
+  REQUIRE(l2.to_string() == "[ ]");
131
+  REQUIRE(l2_copy.to_string() == "[ ]");
132
+
133
+  l2.insert(7);
134
+  REQUIRE(l2.to_string() == "[ 7 ]");
135
+  REQUIRE(l2_copy.to_string() == "[ ]");
136
+  l2_copy.insert(76);
137
+  REQUIRE(l2.to_string() == "[ 7 ]");
138
+  REQUIRE(l2_copy.to_string() == "[ 76 ]");
139
+}
140
+
141
+TEST_CASE("Testing move constructor") {
142
+  Sorted_List l{1, 8, 5};
143
+  Sorted_List l2{};
144
+  Sorted_List m{std::move(l)};
145
+  Sorted_List m2{std::move(l2)};
146
+
147
+  REQUIRE(m.to_string() == "[ 1 5 8 ]");
148
+  REQUIRE(l.is_empty());
149
+  REQUIRE(m2.to_string() == "[ ]");
150
+  REQUIRE(l2.is_empty());
151
+
152
+  // Checking for interferences
153
+  m.remove(5);
154
+  l.insert(9);
155
+  m2.insert(3);
156
+  REQUIRE(m.to_string() == "[ 1 8 ]");
157
+  REQUIRE(l.to_string() == "[ 9 ]");
158
+  REQUIRE(m2.to_string() == "[ 3 ]");
159
+  REQUIRE(l2.is_empty());
160
+}
161
+
162
+TEST_CASE("Testing move assignment") {
163
+  Sorted_List l{1, 8, 5};
164
+  Sorted_List l2{};
165
+  Sorted_List m{};
166
+  Sorted_List m2{};
167
+
168
+  m = std::move(l);
169
+  REQUIRE(m.to_string() == "[ 1 5 8 ]");
170
+  REQUIRE(l.is_empty());
171
+  m2 = std::move(l2);
172
+  REQUIRE(m2.is_empty());
173
+  REQUIRE(l2.is_empty());
174
+
175
+  // Checking for interferences
176
+  m.remove(5);
177
+  l.insert(9);
178
+  m2.insert(3);
179
+  REQUIRE(m.to_string() == "[ 1 8 ]");
180
+  REQUIRE(l.to_string() == "[ 9 ]");
181
+  REQUIRE(m2.to_string() == "[ 3 ]");
182
+  REQUIRE(l2.is_empty());
183
+}
184
+
185
+TEST_CASE("Testing the at() function") {
186
+  Sorted_List l{1, 8, 5, 0, 5};
187
+  Sorted_List l2{};
188
+  Sorted_List l3{2};
189
+
190
+  REQUIRE(l.at(0) == 0);
191
+  REQUIRE(l.at(2) == 5);
192
+  REQUIRE(l.at(4) == 8);
193
+  REQUIRE(l3.at(0) == 2);
194
+
195
+  REQUIRE_THROWS(l.at(5));
196
+  REQUIRE_THROWS(l2.at(0));
197
+}

+ 62
- 0
lab4/build_and_run.sh View File

@@ -0,0 +1,62 @@
1
+#!/bin/bash
2
+# TDDE18 - Lab 4
3
+
4
+red='\e[0;31m'
5
+green='\e[0;32m'
6
+orange='\e[0;33m'
7
+neutral='\e[0;m'
8
+
9
+printout() {
10
+	echo -e "[${green}INFO${neutral}] $@"
11
+}
12
+
13
+printhelp() {
14
+	echo -e "[${orange}HELP${neutral}] $@"
15
+}
16
+
17
+printerr() {
18
+	echo -e "[${red}ERROR${neutral}] $@"
19
+}
20
+
21
+valgrd() {
22
+	echo ""
23
+	valgrind --tool=memcheck --leak-check=yes ./out.o $1 $2 $3 $4 $5
24
+	echo ""
25
+}
26
+
27
+printhelp "Compilation, execution and debugging script for TDDE18 C ++ labs."
28
+printhelp "Pass the \"-v\" argument to run Valgrind."
29
+
30
+printout "Starting building..."
31
+/usr/bin/time --quiet --output=data.tmp -f "Time elasped: %E (%P cpu)" g++ -Wall -Wextra -Wpedantic -std=c++17 *.cc -o out.o
32
+
33
+if test $? -eq 0
34
+then
35
+	printout "Build finished."
36
+
37
+	printout `cat data.tmp`
38
+	rm data.tmp
39
+
40
+	if [ "$1" = "-v" ] 
41
+	then
42
+		printout "Running with valgrind..."
43
+		valgrd $2 $3 $4 $5 $6
44
+	else
45
+		printout "Running..."
46
+		echo ""
47
+		./out.o $1 $2 $3 $4 $5
48
+		echo "" 
49
+	fi
50
+
51
+	printout "Done. Cleaning..."
52
+	rm out.o
53
+	printout "Done."
54
+else
55
+	printerr "Build failed."
56
+	printout `cat data.tmp`
57
+	rm data.tmp
58
+	exit 1
59
+fi
60
+
61
+echo ""
62
+exit 0

+ 78
- 0
lab4/components.cc View File

@@ -0,0 +1,78 @@
1
+#include "components.h"
2
+
3
+/// Link functions
4
+Link::Link(): charge{} 
5
+{}
6
+
7
+Link::~Link() 
8
+{}
9
+
10
+/// Component functions
11
+Component::Component(std::string const _name, Link& _a, Link& _b): 
12
+    name{_name}, a{_a}, b{_b} 
13
+{}
14
+
15
+double Component::voltage() const
16
+{
17
+    return a.charge-b.charge;
18
+}
19
+
20
+std::string Component::get_name() const {
21
+    return name;
22
+}
23
+
24
+/// Resistor functions
25
+Resistor::Resistor(std::string const _name, Link& _a, Link& _b, double const _resistance):
26
+    Component::Component{_name, _a, _b}, resistance{_resistance}
27
+{}
28
+
29
+void Resistor::simulate(double const _dt) 
30
+{
31
+    double charge_motion = (voltage() * _dt) / resistance;
32
+    a.charge -= charge_motion;
33
+    b.charge += charge_motion;
34
+}
35
+
36
+double Resistor::current() const
37
+{
38
+    return Resistor::voltage()/resistance;
39
+}
40
+
41
+/// Capacitor function
42
+Capacitor::Capacitor(std::string const _name, Link& _a, Link& _b, double const _farad):
43
+    Component::Component{_name, _a, _b}, farad{_farad}, charge{0}
44
+{}
45
+
46
+void Capacitor::simulate(double const _dt) 
47
+{
48
+    double charge_motion{(voltage() - charge) * farad * _dt};
49
+    a.charge -= charge_motion;
50
+    b.charge += charge_motion;
51
+    charge += charge_motion;
52
+}
53
+
54
+double Capacitor::current() const
55
+{
56
+    return farad * (voltage() - charge);
57
+}
58
+
59
+/// Battery function
60
+Battery::Battery(std::string const _name, Link& _a, Link& _b, double const _potential):
61
+    Component::Component{_name, _a, _b}, potential{_potential}
62
+{}
63
+
64
+void Battery::simulate(double const) 
65
+{
66
+    a.charge = potential;
67
+    b.charge = 0;
68
+}
69
+
70
+double Battery::voltage() const
71
+{
72
+    return potential;
73
+}
74
+
75
+double Battery::current() const
76
+{
77
+    return 0;
78
+}

+ 75
- 0
lab4/components.h View File

@@ -0,0 +1,75 @@
1
+#ifndef COMPONENTS
2
+#define COMPONENTS
3
+
4
+#include <string>
5
+
6
+/* 
7
+Lab 4 - TDDE18 - Components - Header file
8
+*/
9
+
10
+/// Link class, represents a node between different components
11
+class Link {
12
+public:
13
+    Link();
14
+    ~Link();
15
+    double charge;
16
+};
17
+
18
+/// Base component class
19
+class Component {
20
+public:
21
+    Component(std::string const _name, Link& _a, Link& _b);
22
+    virtual ~Component() = default;
23
+
24
+    std::string get_name() const;
25
+    virtual void simulate(double const _dt) = 0;
26
+    virtual double voltage() const;
27
+    virtual double current() const = 0;
28
+
29
+protected:
30
+    std::string name{};
31
+    Link& a;
32
+    Link& b;
33
+};
34
+
35
+/// Derived (from component) class resistor 
36
+class Resistor : public Component {
37
+public:
38
+    Resistor(std::string const _name, Link& _a, Link& _b, double const _resistance);
39
+
40
+    virtual void simulate(double const _dt) override;
41
+    using Component::voltage;
42
+    virtual double current() const override;
43
+
44
+private:
45
+    double resistance;
46
+};
47
+
48
+/// Derived (from component) class capacitor
49
+class Capacitor : public Component {
50
+public:
51
+    Capacitor(std::string const _name, Link& _a, Link& _b, double const _farad);
52
+
53
+    virtual void simulate(double const _dt) override;
54
+    using Component::voltage;
55
+    virtual double current() const override;
56
+
57
+private:
58
+    double farad;
59
+    double charge;
60
+};
61
+
62
+/// Derived (from component) class battery
63
+class Battery : public Component {
64
+public:
65
+    Battery(std::string const _name, Link& _a, Link& _b, double const _potential);
66
+
67
+    virtual void simulate(double const) override;
68
+    virtual double voltage() const override;
69
+    virtual double current() const override;
70
+
71
+private:
72
+    double potential;
73
+};
74
+
75
+#endif

+ 206
- 0
lab4/main.cc View File

@@ -0,0 +1,206 @@
1
+#include <iostream>
2
+#include <iomanip>
3
+#include <vector>
4
+#include <string>
5
+#include "components.h"
6
+
7
+
8
+/* Lab 4 - TDDE18 - Simulator lab - Main file
9
+    Usage: 
10
+        $ ./a.out [ITERATIONS] [NB_OUTPUT] [TIME_STEP] [BATTERY_VOLTAGE]
11
+    If you are using our build script (available on our private Github), you can do:
12
+        $ ./build_and_run.sh -v [ITERATIONS] [NB_OUTPUT] [TIME_STEP] [BATTERY_VOLTAGE]
13
+    to run the binary in valgrind.
14
+
15
+    Note: Compilation warning dues to unused parameter is normal (seen with lab assistant).
16
+
17
+    New circuits can be created in the /// Simulations setup /// section (line 90) by
18
+    following existing functions patterns. Add also a line at the end of the program 
19
+    to execute simulation.
20
+ */
21
+
22
+
23
+using namespace std;
24
+
25
+
26
+/////////////////////////
27
+/// Utility functions ///
28
+/////////////////////////
29
+
30
+/// Function that print output's header
31
+void print_header(vector <Component*> circuit) {
32
+    for (Component* element : circuit) {
33
+        cout << setw(15) << element->get_name();
34
+    }
35
+    cout << endl;
36
+    for (long unsigned int i = 0; i < circuit.size(); ++i) {
37
+        cout << setw(8) << "Volt" << setw(7) << "Curr";
38
+    }
39
+    cout << endl;
40
+}
41
+
42
+
43
+/// Function that print circuit status at a given step
44
+void print_status(vector <Component*> circuit) {
45
+    for (Component* element : circuit)
46
+    {
47
+        cout << fixed << setprecision(2) << setw(8) << element->voltage() << setw(7) << element->current();
48
+    }
49
+    cout << endl;
50
+}
51
+
52
+
53
+/// Simulates the circuit's charges motion
54
+void simulate(vector <Component*> circuit, int const iterations, int const nb_output, double const dt) {
55
+    int output_step = iterations / nb_output;
56
+    print_header(circuit);
57
+
58
+    for (int step = 1; step <= iterations; ++step){
59
+        // Simulate each component
60
+        for (Component* element : circuit)
61
+        {
62
+            element->simulate(dt);
63
+        }
64
+        // Print info every output_step
65
+        if (step % output_step == 0){
66
+            print_status(circuit);
67
+        }
68
+    }
69
+    cout << endl;
70
+}
71
+
72
+
73
+/// Delete components to avoid memory leaks
74
+void clean(vector <Component*> circuit) {
75
+    for (Component* element : circuit)
76
+    {
77
+        delete element;
78
+    }
79
+}
80
+
81
+
82
+void invalid_arguments() {
83
+    cout << "Invalid arguments, usage: " << endl;
84
+    cout << "./bin [ITERATIONS] [NB_OUTPUT] [TIME_STEP] [BATTERY_VOLTAGE]" << endl;
85
+    cout << "Example: ./bin 200000 10 0.01 24" << endl;
86
+}
87
+
88
+
89
+/////////////////////////
90
+/// Simulations setup ///
91
+/////////////////////////
92
+
93
+// A very basic simulation, to test resistance simulation.
94
+void simulation0(int iterations, int nb_output, double dt, double battery_voltage) {
95
+    Link P, N, r12;
96
+    vector<Component*> circuit;
97
+
98
+    circuit.push_back(new Battery("Bat", P, N, battery_voltage));
99
+    circuit.push_back(new Resistor("R1", P, r12, 6.0));
100
+    circuit.push_back(new Resistor("R2", r12, N, 8.0));
101
+
102
+    simulate(circuit, iterations, nb_output, dt);
103
+    clean(circuit);
104
+}
105
+
106
+// Corresponds to the first (top) circuit in the lab PDF (figure 1).
107
+void simulation1(int iterations, int nb_output, double dt, double battery_voltage) {
108
+    Link P, N, r124, r23;
109
+    vector<Component*> circuit;
110
+
111
+    circuit.push_back(new Battery("Bat", P, N, battery_voltage));
112
+    circuit.push_back(new Resistor("R1", P, r124, 6.0));
113
+    circuit.push_back(new Resistor("R2", r124, r23, 4.0));
114
+    circuit.push_back(new Resistor("R3", r23, N, 8.0));
115
+    circuit.push_back(new Resistor("R4", r124, N, 12.0));
116
+
117
+    simulate(circuit, iterations, nb_output, dt);
118
+    clean(circuit);
119
+}
120
+
121
+// Corresponds to the second (middle) circuit in the lab PDF (figure 1).
122
+void simulation2(int iterations, int nb_output, double dt, double battery_voltage) {
123
+    Link P, N, L, R;
124
+    vector<Component*> circuit;
125
+
126
+    circuit.push_back(new Battery("Bat", P, N, battery_voltage));
127
+    circuit.push_back(new Resistor("R1", P, L, 150.0));
128
+    circuit.push_back(new Resistor("R2", P, R, 50.0));
129
+    circuit.push_back(new Resistor("R3", R, L, 100.0));
130
+    circuit.push_back(new Resistor("R4", L, N, 300.0));
131
+    circuit.push_back(new Resistor("R5", R, N, 250.0));
132
+
133
+    simulate(circuit, iterations, nb_output, dt);
134
+    clean(circuit);
135
+}
136
+
137
+// Corresponds to the third (bottom) circuit in the lab PDF (figure 1).
138
+void simulation3(int iterations, int nb_output, double dt, double battery_voltage) {
139
+    Link P, N, L, R;
140
+    vector<Component*> circuit;
141
+
142
+    circuit.push_back(new Battery("Bat", P, N, battery_voltage));
143
+    circuit.push_back(new Resistor("R1", P, L, 150.0));
144
+    circuit.push_back(new Resistor("R2", P, R, 50.0));
145
+    circuit.push_back(new Capacitor("C3", R, L, 1.0));
146
+    circuit.push_back(new Resistor("R4", L, N, 300.0));
147
+    circuit.push_back(new Capacitor("C5", R, N, 0.75));
148
+
149
+    simulate(circuit, iterations, nb_output, dt);
150
+    clean(circuit);
151
+}
152
+
153
+
154
+/////////////////////////////////////
155
+/// Main function & args. parsing ///
156
+/////////////////////////////////////
157
+
158
+int main(int argc, char* argv[]){
159
+    int iterations{};
160
+    int nb_output{};
161
+    double dt{};
162
+    double battery_voltage{};
163
+
164
+    // Arguments parsing
165
+    if (argc == 5)
166
+    {
167
+        try 
168
+        {
169
+            vector<string> args {argv, argv + argc};
170
+            iterations = std::stoi(args[1]);
171
+            nb_output = std::stoi(args[2]);
172
+            dt = std::stod(args[3]);
173
+            battery_voltage = std::stod(args[4]);
174
+            if (iterations <= 0) {
175
+                throw std::logic_error{"Negative iterations"};
176
+            }
177
+            else if (nb_output > iterations) {
178
+                throw std::logic_error{"Too many output for given iterations"};
179
+            }
180
+            else if (dt <= 0) {
181
+                throw std::logic_error{"Time step must be strictly positive"};
182
+            }
183
+        }
184
+        catch (std::exception& e)
185
+        {
186
+            cerr << "ERROR (" << e.what() << ")." << endl;
187
+            invalid_arguments();
188
+            return 1;
189
+        }
190
+    }
191
+    else 
192
+    {
193
+        cerr << "ERROR (no enough arguments)." << endl;
194
+        invalid_arguments();
195
+        return 1;
196
+    }
197
+
198
+    // Running simulations
199
+    simulation0(iterations, nb_output, dt, battery_voltage);
200
+    simulation1(iterations, nb_output, dt, battery_voltage);
201
+    simulation2(iterations, nb_output, dt, battery_voltage);
202
+    simulation3(iterations, nb_output, dt, battery_voltage);
203
+    
204
+
205
+    return 0;
206
+}

+ 115
- 0
lab4/notes.md View File

@@ -0,0 +1,115 @@
1
+# Course note 
2
+*TDDE18 2020-11-03*
3
+
4
+## std::vector
5
+```C++
6
+#include <vector>
7
+
8
+std::vector<int> v {5, 3, 1, 2};
9
+
10
+v.at(1) = 4; // OR
11
+v[1] = 4     // seg. fault possible
12
+             // (index start at 0)
13
+
14
+v.push_back(3);
15
+v.back() = 6;
16
+v.pop_back();
17
+
18
+v.front()
19
+v.size()
20
+
21
+vector<string> words {...};
22
+
23
+// Following instruction are near equivalent
24
+// use last one
25
+for(int i{0}; i < words.size(); ++i)
26
+for(string word : words)
27
+for(string const& word : words)
28
+{
29
+    cout << words.at(i) << endl;
30
+}
31
+```
32
+
33
+## Inheritance
34
+```C++
35
+class Base {
36
+public:
37
+    //...
38
+protected:
39
+    // Only accessible by the "family"
40
+};
41
+
42
+class Derived : public Base {
43
+public:
44
+    Derived(int dev) : Base{}, init{dev}
45
+    {}
46
+
47
+    //...
48
+private:
49
+    //...
50
+};
51
+```
52
+
53
+## Polymorphism
54
+```C++
55
+class Shape{
56
+public:
57
+    //...
58
+    virtual double area() const
59
+    {
60
+        return 0;
61
+    }
62
+    //...
63
+};
64
+
65
+class Rectangle : public Shape{
66
+public:
67
+    //...
68
+    double area()const{
69
+        return width * height;
70
+    }
71
+    //...
72
+};
73
+
74
+int main () {
75
+    Rectangle r {10, 15};
76
+    cout << print_area(r) << endl; //prints150
77
+}
78
+```
79
+```C++
80
+Shape s{};
81
+Rectangle r{10, 15};
82
+Triangle  t{3, 4};
83
+
84
+Shape* ptr {&s};
85
+ptr->area(); //returns 0 
86
+
87
+ptr = &r;
88
+ptr->area(); //returns 150 
89
+
90
+ptr = &t;
91
+ptr->area(); //returns 6
92
+```
93
+
94
+*Always use pointers or references when dealing with polymorphic objects!*
95
+
96
+Sometimes, we have to make the destructor virtual:
97
+```C++
98
+class Shape{
99
+public:
100
+    //...
101
+    virtual ~Shape() = default;
102
+    //...
103
+};
104
+```
105
+*Always declare the destructor of a polymorphic base class as virtual!*
106
+
107
+When a function must override another, we can add `override` term to force the compiler to check that we actually override a function:
108
+```C++
109
+double area() const override {}
110
+```
111
+To force a function to be override in the parent function, we can use:
112
+```C++
113
+// Pure virtual function
114
+virtual double area() const = 0;
115
+```

+ 62
- 0
lab5/build_and_run.sh View File

@@ -0,0 +1,62 @@
1
+#!/bin/bash
2
+# TDDE18 - Lab 5 - Build script
3
+
4
+red='\e[0;31m'
5
+green='\e[0;32m'
6
+orange='\e[0;33m'
7
+neutral='\e[0;m'
8
+
9
+printout() {
10
+	echo -e "[${green}INFO${neutral}] $@"
11
+}
12
+
13
+printhelp() {
14
+	echo -e "[${orange}HELP${neutral}] $@"
15
+}
16
+
17
+printerr() {
18
+	echo -e "[${red}ERROR${neutral}] $@"
19
+}
20
+
21
+valgrd() {
22
+	echo ""
23
+	valgrind --tool=memcheck --leak-check=yes ./out.o $1 $2 $3 $4 $5
24
+	echo ""
25
+}
26
+
27
+printhelp "Compilation, execution and debugging script for TDDE18 C ++ labs."
28
+
29
+printout "Starting building..."
30
+/usr/bin/time --quiet --output=data.tmp -f "Time elasped: %E (%P cpu)" g++ -Wall -Wextra -Wpedantic -std=c++17 *.cc -o out.o
31
+
32
+if test $? -eq 0
33
+then
34
+	printout "Build finished."
35
+
36
+	printout `cat data.tmp`
37
+	rm data.tmp
38
+	printout "Running..."
39
+
40
+	if [[ $1 == "" ]]
41
+	then 
42
+		printhelp "No arguments provided, using default example.html -a."
43
+		echo ""
44
+		./out.o samples/example.html -a
45
+	else
46
+		echo ""
47
+		./out.o $1 $2 $3 $4 $5
48
+	fi
49
+
50
+	echo "" 
51
+	printout "Done. Cleaning..."
52
+	rm out.o
53
+	printout "Done."
54
+else
55
+	printerr "Build failed."
56
+	printout `cat data.tmp`
57
+	rm data.tmp
58
+	exit 1
59
+fi
60
+
61
+echo ""
62
+exit 0

+ 23
- 0
lab5/demo.sh View File

@@ -0,0 +1,23 @@
1
+#!/bin/bash
2
+# TDDE18 - Lab 5 - Demo script
3
+
4
+g++ -Wall -Wextra -Wpedantic -std=c++17 *.cc -o out.o
5
+
6
+echo '[+] Executing: "a.out example.html -a"'
7
+./out.o samples/example.html -a
8
+echo ""
9
+
10
+echo '[+] Executing: "a.out example.html -f"'
11
+./out.o samples/example.html -f
12
+echo ""
13
+
14
+echo '[+] Executing: "a.out example.html -o 14"'
15
+./out.o samples/example.html -o 14
16
+echo ""
17
+
18
+echo '[+] Executing: "a.out example.html -o 9"'
19
+./out.o samples/example.html -o 9
20
+echo ""
21
+
22
+rm out.o -f
23
+echo "Done."

+ 243
- 0
lab5/main.cc View File

@@ -0,0 +1,243 @@
1
+#include <iostream>
2
+#include <fstream>
3
+#include <iomanip>
4
+#include <algorithm>
5
+#include <iterator>
6
+#include <vector>
7
+#include <map>
8
+#include <cctype>
9
+
10
+
11
+/* 
12
+    Lab 5 - TDDE18
13
+    Wordlists lab - Main file
14
+*/
15
+
16
+using namespace std;
17
+
18
+//////////////////////////////////
19
+/// User interaction functions ///
20
+//////////////////////////////////
21
+
22
+//TODO: Non fundamental types taken as parameters should not be copied
23
+//as they might be large. Parameters which are not changed should also
24
+//be const. --> done.
25
+
26
+// Help function
27
+void print_err(const string & str){
28
+    cerr << "Error: " << str << endl;
29
+    cerr << "Usage: ./a.out FILE [-a] [-f] [-o N]" << endl;
30
+}
31
+
32
+// Print final wordlist
33
+/// For alphabetic ordering
34
+void print_a(const std::vector<std::pair<string,int>> & wl, int max_length) {
35
+    for_each(wl.begin(), wl.end(), [max_length](std::pair<string,int> & pair){
36
+        cout << left << setw(max_length + 1) 
37
+            << pair.first << pair.second << endl;
38
+    });
39
+}
40
+
41
+/// For frequency ordering
42
+void print_f(const std::vector<std::pair<string,int>> & wl, int max_length) {
43
+    for_each(wl.begin(), wl.end(), [max_length](std::pair<string,int> & pair){
44
+        cout << setw(max_length) << pair.first << "  " << pair.second << endl;
45
+    });
46
+}
47
+
48
+/// For -o argument
49
+void print_o(const std::vector<string> & list, int limit) {
50
+    string line{};
51
+    for_each(list.begin(), list.end(), [&line, limit](string word){
52
+        if (int(line.length() + word.length()) >= limit - 1){
53
+            cout << line << endl;
54
+            line = word;
55
+        }
56
+        else {
57
+            if (line == ""){
58
+                line =  word;
59
+            }
60
+            else {
61
+                line += " " + word;
62
+            }
63
+        }
64
+    });
65
+    cout << line << endl;
66
+}
67
+
68
+
69
+/////////////////////////
70
+/// Utility functions ///
71
+/////////////////////////
72
+
73
+//TODO: This function does too much. Divide the tasks into more
74
+//functions which clearly state what they handle. For example:
75
+//remove_trash, is_valid, etc. --> done.
76
+
77
+//TODO: Enumerating the entire alphabet should be avoided since
78
+//missing a character is easy. Use the library cctype for this
79
+//instead. --> done.
80
+
81
+// Check if a given word is valid
82
+bool is_valid(const string & word) {
83
+    return !(!std::all_of(word.begin(), word.end(), [](const char c){
84
+                return isalpha(c) || c == '-';
85
+            }) 
86
+        || word.at(0) == '-' || word.at(word.length()-1) == '-'
87
+        || int(word.length()) < 3
88
+        || word.find("--") != std::string::npos);
89
+}
90
+
91
+
92
+bool cmp_length(const string & a, const string & b){
93
+    return a.length() < b.length();
94
+}
95
+
96
+//Comment: Why unsigned long int? find_first.. will return an index in
97
+//the string. This index will not be too large for a regular int to
98
+//handle. --> Because it is the return type of these functions, else
99
+//GCC will do a strange convertion and put a warning at compilation:
100
+//
101
+//main.cc:103:15: warning: comparison of integer expressions of different signedness: 
102
+//      ‘int’ and ‘const size_type’ {aka ‘const long unsigned int’} [-Wsign-compare]
103
+//103 |     if (begin != std::string::npos && end != std::string::npos && begin < end){
104
+//
105
+
106
+string remove_trash(string & word){
107
+    // Here we remove head and tail junk. Lot of the complexity
108
+    // is dues to weird cases like "(?!)" or ")?!("
109
+    const long unsigned int begin = word.find_first_not_of("(\"\'");
110
+    const long unsigned int end =  word.find_last_not_of("!?;,:.\"\')");
111
+    if (begin != std::string::npos && end != std::string::npos && begin < end){
112
+        word.erase(0, begin);
113
+        word.erase(word.find_last_not_of("!?;,:.\"\')") + 1);
114
+    }
115
+    // Manage the 's tail trash
116
+    if (*(word.end()-2) == '\'' && *(word.end()-1) == 's')
117
+        word.erase(word.end()-2, word.end());
118
+    // Lowering case
119
+    std::transform(word.begin(), word.end(), word.begin(), ::tolower);
120
+    return word;
121
+}
122
+
123
+
124
+//TODO: See lab instructions for correct error message in case of
125
+//invalid input. --> done. Note : In some cases, the PDF does not 
126
+//specify what should be displayed, in this case we have displayed 
127
+//the message that suits us the most suitable
128
+
129
+int main(int argc, char* argv[]) {
130
+
131
+    ////////////////////////////
132
+    /// Arguments management ///
133
+    ////////////////////////////
134
+
135
+    /// Args parsing
136
+    // Basic checks
137
+    if (argc <= 1 ){
138
+        print_err("No arguments given.");
139
+        return 1;
140
+    }
141
+    else if (argc == 2){
142
+        print_err("Second argument missing or invalid.");
143
+        return 2;
144
+    }
145
+
146
+    // Checking file
147
+    vector<string> args {argv, argv + argc};
148
+    string file_name{args[1]};
149
+    
150
+    ifstream file{};
151
+    file.open(file_name);
152
+
153
+    if (! file.is_open()){
154
+        print_err("Second argument missing or invalid.");
155
+        return 3;
156
+    }
157
+
158
+    // Checking command
159
+    string param{args[2][1]};
160
+    int line_length{};
161
+
162
+    if (args[2][0] != '-' || (param != "a" && param != "f" && param != "o")){
163
+        print_err("Third argument invalid.");
164
+        return 4;
165
+    }
166
+    else if (param == "o"){
167
+        if (argc != 4) {
168
+            print_err("You must specify a N value.");
169
+            return 6;
170
+        }
171
+        try {
172
+            line_length = stoi(args[3]);
173
+        }
174
+        catch (std::exception& e){
175
+            print_err("Invalid N value. (" + string(e.what()) + ")");
176
+            return 5;
177
+        }
178
+    }
179
+
180
+    /////////////////////
181
+    /// File analysis ///
182
+    /////////////////////
183
+
184
+    int max_length{0};
185
+    istream_iterator<string> iis {file};
186
+    istream_iterator<string> eof;
187
+    std::vector<string> dirty_words{iis, eof};
188
+    std::vector<string> all(dirty_words.size());
189
+    std::map<string, int> collection;
190
+
191
+
192
+    //TODO: Here you use for_each to emulate a for-loop. This is not
193
+    //an appropriate algorithm for this task. What you want to do is
194
+    //transform each element in dirty_words. Hint: Check out the
195
+    //transform algorithm. See TODO about dividing the purifier
196
+    //function before fixing this TODO. --> done.
197
+
198
+    //TODO: This algorithm does too much. Break it down into more
199
+    //appropriate algorithms. For example, use std::max_element to
200
+    //find the largest element, etc. --> done.
201
+
202
+    std::transform(dirty_words.begin(), dirty_words.end(), dirty_words.begin(), remove_trash);
203
+    std::copy_if(dirty_words.begin(), dirty_words.end(), all.begin(), is_valid);
204
+    max_length = (*std::max_element(all.begin(), all.end(), cmp_length)).length();
205
+
206
+    // Counting word in a std::map
207
+    std::for_each(all.begin(), all.end(), [&collection](string word) {
208
+        if (word != "")
209
+            collection[word]++; 
210
+    });
211
+
212
+
213
+    // Converting map collection into vector wordlist to allow sorting
214
+    std::vector<std::pair<string,int>> wordlist; 
215
+    for_each(collection.begin(), collection.end(), [&wordlist](auto pair){
216
+        wordlist.push_back(pair);
217
+    });
218
+
219
+
220
+    // Output selection and sorting (if needed)
221
+    if (param == "f"){
222
+        std::sort(wordlist.begin(), wordlist.end(), 
223
+            [](std::pair<string,int> const & a, std::pair<string,int> const & b)
224
+        {
225
+            return a.second > b.second;
226
+        });
227
+        print_f(wordlist, max_length);
228
+    }
229
+    else if (param == "a"){
230
+        std::sort(wordlist.begin(), wordlist.end(), 
231
+            [](std::pair<string,int> const & a, std::pair<string,int> const & b)
232
+        {
233
+            return a.first < b.first;
234
+        });
235
+        print_a(wordlist, max_length);
236
+    }
237
+    else {
238
+        print_o(all, line_length);
239
+    }
240
+    
241
+
242
+    return 0;
243
+}

+ 16
- 0
lab5/samples/better_example.txt View File

@@ -0,0 +1,16 @@
1
+.Passing.words:
2
+okay
3
+okej-good,
4
+okej-good-nice
5
+'okay'.
6
+"good":
7
+"("okay-good's;
8
+'("(okay-good's?)")'!
9
+.Not.passing.words:
10
+"(wrong's's)"   // double.possession/gentive
11
+wrong--no      // double.hyphens
12
+wrong-no--nono // double.hyphens.after.passed.single.hyphen
13
+(wrong()no)    // trash.in.middle.of.word
14
+"(((no)!?"    // too.few.letters
15
+"("wrongno)#   // invalid.word.end
16
+!(wrong-no)!   // invalid.word.start

+ 10
- 0
lab5/samples/example.html View File

@@ -0,0 +1,10 @@
1
+<html>
2
+    <head>
3
+        <title> The page title! </title>
4
+    </head>
5
+
6
+    <body id="body">
7
+        <h1>The Page: </h1>
8
+        <p>This is the page body. (!?) </p>
9
+    </body>
10
+</html>

+ 125
- 0
lab5/samples/lab_pdf.txt View File

@@ -0,0 +1,125 @@
1
+Linköping University
2
+Department of Computer and Information Science (IDA)
3
+The UPP group
4
+2015-10-01
5
+Standard Template Library
6
+Aim
7
+In this assignment you will learn how to use the standard template library.
8
+Reading instructions
9
+- String features (std::string, at(), substr(), insert(), erase(), <cctype>)
10
+- STL containers (std::vector, std::list, std::map)
11
+- STL iterators (::iterator, ::const_iterator)
12
+- STL algorithms (sort(), find(), copy(), for_each())
13
+- Passing functions as arguments
14
+- Function pointers (the C way)
15
+- Function objects (::operator(), the C++98 way)
16
+- Lambda functions (the C++11 way)
17
+- Regular expressions, voluntary, may require gcc version >= 4.9,
18
+(std::regex, std::regex_match, std::regex_replace, std::regex_search)
19
+Word list background
20
+A few years back, before smartphones, mobile phones tried to predict what you were trying to write
21
+by using a word list. Sometimes successfully, and sometimes yielding a good story to tell your friends
22
+(after the initial awkwardness and apologizing to the recipient of your message). Does it sound
23
+familiar?
24
+A less known fact is how the word list used by your phone was created. This story 1 may thus come
25
+as a revelation. It starts in a beautiful far away country. The labor is both good and cheap. An ideal
26
+place for a phone company to locate the word list department. In this department they developed
27
+a program to crawl the web and collect words and word statistics from all popular web pages. To
28
+determine the language of the words they simply looked at the top domain where a page occurred.
29
+With this collection of words and their usage frequency the word list department could compile word
30
+lists which were able to provide good (or at least funny) predictions.
31
+A few native far-away-countrymen also did their best at excluding words that were not proper (unless
32
+they could make for funny misunderstandings of course).
33
+1
34
+If there’s any truth to the story it’s purely coincidental.Standard Template Library
35
+2015-10-01
36
+Word collection and washing
37
+Some emerging markets still use the older phones for their increased battery time and coverage. They
38
+need a new word collecting program. You will write it for them now. The program should scan a text
39
+file for potential words. All potential words are separated by at least one blank character. A potential
40
+word may happen to include some “junk” normally occurring in written text, for example opening
41
+and closing parentheses, citations, commas, dots and other characters that may end a sentence. We
42
+separate this in junk that may occur just before the actual word, and junk that may occur just after.
43
+Possible junk are specified as follow:
44
+- Junk characters to remove from the beginning of potential words are quotation marks and opening
45
+parentheses. We call this leading junk for short: "'(
46
+- Junk characters to remove from the end of potential words are punctuation characters, quotation
47
+characters, apostrophes and closing parentheses. We call this trailing junk for short: !?;,:."')
48
+- Remaining after trailing junk removal may also occur one single 's (possession/genitive) that
49
+should be removed if present.
50
+- Note that junk characters inside the word are left in place, since they’re neither leading nor
51
+trailing.
52
+Your program will strip away only leading and trailing junk from each potential word. This will
53
+produce a cleaned word. Cleaned words are then determined to be either valid or invalid. A valid
54
+word have the following properties:
55
+- The word contains only letters (lower case or upper case) and hyphens.
56
+- Hyphens occur only inside the word (not first or last) and non-consecutive.
57
+- The word contains at least three characters (shorter words are not worthwhile to predict).
58
+Once a word is determined as valid, it is converted to lower case and added to the word list and
59
+statistics. Invalid words are simply ignored.Standard Template Library
60
+2015-10-01
61
+Program input and output
62
+A non-functional requirement (that’s still a requirement) is to use STL containers and algorithms
63
+wherever possible (rather overdo it than miss out on a learning opportunity, e.g. no for/while’s).
64
+Your program should work on a plain text file (any text file). Interesting test cases include the source
65
+code of the program itself and any HTML file you can find. The file is specified by the user on the
66
+command line (check for errors) and read by the program according to the word collection and washing
67
+section. A second command line parameter (after the file name) specify the final output (see later
68
+examples):
69
+-a All valid words are printed in alphabetic increasing order followed by the frequency of that word
70
+(how many times that word occurred). This list should be formatted clearly with the first letter
71
+of each word and the last digit of each number in straight columns. You have to adapt to the
72
+longest word and largest number.
73
+-f All valid words are printed in decreasing frequency. The list is printed as before, but with the
74
+last letter of each word aligned in a straight column instead of the first (right alignment). You
75
+will probably have to copy the words to another container before sorting.
76
+-o Print all valid words in the same order they appear in the original file. 2 Insert line breaks to
77
+keep all lines as long as possible, but strictly below N characters 3 excluding only the line break
78
+character. N is specified by the user last on the command line (just after -o). Specifically, this
79
+should be solved by using the for_each algorithm. You will need a function object or a lambda
80
+function (why not try both ways).
81
+Next page provide a small example of how the program is intended. You will of course have to create
82
+more elaborate test cases yourself if none are given. It is your responsibility to prove that your program
83
+is correct.
84
+2
85
+3
86
+This is for the quality assurance team to easier read the file content of for example a HTML file.
87
+Words longer than N characters will be printed on its own line, ignoring the limit.Standard Template Library
88
+2015-10-01
89
+An example HTML file
90
+<html>
91
+<head>
92
+<title> The page title! </title>
93
+</head>
94
+<body id="my-body"><h1>The Page: </h1><p>This is the page body. </p></body>
95
+</html>
96
+Running the program with the example file
97
+$ a.out
98
+Error: No arguments given.
99
+Usage: a.out FILE [-a] [-f] [-o N]
100
+$ ./a.out example.html
101
+Error: Second argument missing or invalid.
102
+Usage: ./a.out FILE [-a] [-f] [-o N]
103
+$ a.out example.html -a
104
+body
105
+1
106
+page
107
+3
108
+the
109
+2
110
+title 1
111
+$ a.out example.html -f
112
+page 3
113
+the 2
114
+body 1
115
+title 1
116
+$ a.out example.html -o 14
117
+the page
118
+title page
119
+the page body
120
+$ a.out example.html -o 9
121
+the page
122
+title
123
+page the
124
+page
125
+body

+ 199
- 0
lab5/samples/lorem.txt View File

@@ -0,0 +1,199 @@
1
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec cursus tellus vel quam venenatis, quis facilisis magna euismod. Aliquam dignissim nec sapien fringilla vestibulum. Integer luctus ac nibh eu ultricies. Curabitur sagittis vel metus quis fringilla. Aliquam ut maximus nisi, sed pretium metus. Aenean lacinia lacus tempus, cursus nunc eget, posuere tellus. Maecenas in imperdiet nibh. Ut et mi quis turpis efficitur porttitor id vel lorem. Nunc lobortis convallis enim a eleifend.
2
+
3
+Etiam posuere bibendum ipsum sit amet viverra. In eget magna iaculis, vestibulum sem vel, dapibus mauris. Ut nec ultricies nisi. Ut est nisl, imperdiet vel odio fringilla, gravida lobortis nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis congue egestas. Phasellus in maximus ligula. Ut gravida lacus sed leo laoreet malesuada. Etiam blandit vulputate urna id rhoncus. Morbi sollicitudin neque lectus, non elementum mi commodo vel. Aenean purus velit, vulputate a semper eget, rhoncus nec est. In gravida erat nunc, eu rhoncus neque maximus vitae. Sed eu metus lorem.
4
+
5
+Nunc sed pharetra orci. Nullam est quam, sodales eu suscipit ac, lacinia non sem. Aliquam dolor lectus, euismod vel tellus lacinia, fringilla iaculis erat. Mauris porttitor magna ut tincidunt eleifend. Sed ut nunc egestas, sollicitudin ex posuere, fringilla mauris. Integer fermentum lacus ut dictum mattis. Ut rhoncus vitae tortor et fringilla. Suspendisse vel dolor nec elit luctus viverra fringilla nec diam. Nulla fermentum scelerisque eros, vitae convallis diam iaculis vel. Etiam mattis tempor ex, eget egestas orci mollis sollicitudin. Nunc vitae feugiat diam, nec mattis dolor.
6
+
7
+Aenean ut lorem nibh. Praesent pellentesque porta lectus eget viverra. Duis interdum leo vitae neque bibendum, quis iaculis augue dignissim. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur pretium, arcu et maximus porttitor, lacus erat pellentesque risus, ac interdum purus ipsum in sapien. Ut sodales, dui volutpat feugiat mattis, eros orci vestibulum est, sit amet fringilla arcu urna sit amet lacus. Donec pretium faucibus nisi id feugiat. Vestibulum sodales scelerisque fringilla. Sed maximus finibus blandit. Pellentesque augue massa, volutpat vel imperdiet imperdiet, consequat rutrum leo. Curabitur accumsan nibh vel ipsum convallis sodales.
8
+
9
+In at metus id augue mattis auctor sed ac ante. Proin sollicitudin ultricies felis, sed placerat ipsum condimentum et. Integer elementum lorem ut augue scelerisque pharetra rutrum sed nibh. Aliquam tempus nisl aliquam purus dictum, vel semper enim varius. Ut consectetur elit sed massa rutrum sodales. Integer ultrices viverra eleifend. Integer id tincidunt nisl. Nunc faucibus leo enim, pulvinar sollicitudin dolor gravida a. Pellentesque vitae dapibus neque, lobortis tempor ligula. Aliquam a scelerisque lectus.
10
+
11
+Proin iaculis orci erat, non fringilla libero venenatis non. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris sit amet sapien mollis, vestibulum sapien et, euismod purus. Donec tristique viverra rutrum. Vestibulum imperdiet ante vel magna euismod, vitae suscipit ante porttitor. Morbi ut nisl risus. Aliquam quis luctus quam. Ut et tempus lorem. In magna mi, hendrerit eu egestas in, feugiat in mi.
12
+
13
+In non ex vitae ex commodo fermentum. Nulla est tellus, luctus hendrerit nibh in, eleifend pretium ex. Aliquam convallis viverra tellus, vitae pharetra enim porttitor nec. Curabitur lorem enim, efficitur quis viverra vel, volutpat sed velit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer pretium sollicitudin lobortis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam sed arcu condimentum, luctus nibh in, porttitor metus. Suspendisse pulvinar eget elit eget tristique. Sed tristique magna id sagittis congue. Pellentesque posuere magna vitae pulvinar efficitur. Maecenas ornare et lorem ac bibendum. Ut nisl augue, accumsan et velit sed, sodales tristique sapien. Integer lobortis augue ut urna pretium, at auctor tellus congue. Sed in viverra mauris.
14
+
15
+Sed eu enim in libero venenatis venenatis ut at odio. Nam a dapibus sem, eu vestibulum mauris. Suspendisse sed blandit nulla, at laoreet metus. Maecenas pretium magna ante. Sed a ullamcorper mauris, pretium facilisis diam. Aenean varius non eros eget finibus. Quisque ac turpis vestibulum, tempus risus eu, pretium sapien. Cras est massa, hendrerit sed nunc ac, pharetra porta justo. Vivamus vehicula commodo felis, eget accumsan metus viverra et. Nunc id molestie nibh. Vestibulum elementum nisi sit amet congue feugiat.
16
+
17
+Donec faucibus condimentum viverra. Quisque et commodo diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Proin congue nisl at nunc vulputate faucibus aliquet nec diam. In euismod lobortis dolor sed laoreet. Praesent vitae rutrum metus. Integer vitae dictum nulla, nec rhoncus est. Sed vitae lacinia ante. Sed vel orci accumsan, fringilla libero in, sagittis mi. Quisque pretium est non nisl scelerisque pretium. Praesent ultrices eleifend odio. Etiam fermentum cursus lacinia.
18
+
19
+Fusce convallis lobortis nibh vel maximus. Aenean quam augue, maximus ut euismod ac, tempus non nunc. Aenean sagittis, neque vel placerat fermentum, justo mi finibus libero, non convallis turpis diam sit amet ligula. Integer in volutpat nisl, sollicitudin lacinia erat. Mauris eget elit nec leo pretium sollicitudin. Nunc quis rutrum mauris. Integer et velit viverra, tincidunt neque eget, laoreet lacus.
20
+
21
+Nullam faucibus nunc dui, eget pulvinar libero condimentum vel. Vestibulum tincidunt, velit blandit luctus eleifend, arcu ligula auctor augue, sit amet mollis nunc leo in turpis. Proin feugiat tristique commodo. Sed vitae interdum nunc. Sed sit amet turpis ut turpis blandit ultricies ac sit amet magna. Pellentesque quis ex sodales, tincidunt arcu ac, luctus metus. Vestibulum sit amet tortor consectetur, tincidunt nisl ac, scelerisque sapien. Maecenas eget rutrum magna, quis bibendum sapien. Ut hendrerit ex nec bibendum elementum. Quisque lobortis est eu viverra commodo. Aenean tristique, magna bibendum consectetur feugiat, lorem sem congue dolor, eu efficitur erat urna quis nisl. In hendrerit sapien vitae orci condimentum, et rutrum dui maximus. Quisque sed dolor luctus, tempor ante in, egestas libero.
22
+
23
+Sed metus purus, commodo nec metus vitae, aliquet facilisis diam. Integer lacinia est eu leo dignissim, et posuere libero finibus. Etiam sed felis libero. Curabitur faucibus ut neque id aliquam. Fusce et tincidunt sem. Nam sed tincidunt massa, a sollicitudin purus. Etiam porta placerat posuere. Duis pretium libero vitae dolor elementum, id lobortis dolor luctus.
24
+
25
+Quisque rutrum semper commodo. Ut pretium eros at libero bibendum, vel finibus nunc faucibus. Nulla facilisi. Donec cursus nulla in interdum maximus. Ut lacinia cursus nisl, sed interdum tortor facilisis quis. Cras tortor libero, dapibus ac orci eu, condimentum pretium diam. In bibendum velit sed ante dignissim volutpat. Etiam eu interdum lacus, et rutrum nisl. Sed porttitor placerat dui, eget luctus velit eleifend eget.
26
+
27
+Pellentesque id mollis mi, ac sollicitudin nisi. Fusce vitae nisl et arcu finibus suscipit. Vivamus efficitur scelerisque rhoncus. Morbi velit sapien, interdum sit amet commodo vel, scelerisque ac quam. Etiam feugiat fermentum erat sed gravida. Maecenas gravida justo erat, nec consectetur urna tempor a. Nulla non hendrerit massa. Nulla at gravida quam. Proin tincidunt venenatis nulla. Aliquam vestibulum aliquam lectus, id posuere est tempor eget. Vestibulum convallis rutrum lacus eu ornare. Donec dictum turpis ac massa ultrices vehicula.
28
+
29
+Integer est risus, lobortis et augue vitae, molestie viverra dolor. Nam felis neque, pharetra vitae mauris cursus, facilisis cursus lacus. Vivamus ut ante tortor. Pellentesque laoreet purus lacinia sapien dictum lobortis. Sed nec metus at sapien blandit faucibus. Phasellus diam est, gravida ut mattis tincidunt, mollis in est. Curabitur ultricies feugiat orci, dapibus efficitur sem fermentum ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. Proin at commodo metus, nec euismod turpis. Nam risus lectus, congue eu mi sodales, venenatis mattis tortor. Suspendisse at cursus sem.
30
+
31
+Nulla vehicula mauris at dui lobortis pharetra. Vestibulum rutrum eros id magna sodales tincidunt. Aliquam aliquam, purus eget sollicitudin malesuada, sem arcu iaculis ipsum, quis facilisis arcu est ac lacus. Praesent ut viverra quam. Nunc lacinia volutpat neque. Fusce vestibulum diam id mauris eleifend, in pulvinar lectus elementum. Donec congue tortor non ullamcorper dapibus. Curabitur sed risus justo. Nullam dapibus, elit vitae aliquam consequat, nisl orci malesuada libero, ac pulvinar velit neque sit amet sem. Aenean elementum dolor ac dolor viverra, et tristique dui dignissim. Praesent mattis magna vel ex ultricies, at dignissim odio ornare.
32
+
33
+Mauris convallis semper sem in efficitur. Curabitur auctor risus ac blandit varius. Vivamus fermentum, erat ac dapibus pharetra, lacus elit rhoncus mauris, ac aliquam lorem leo at ipsum. Fusce at magna massa. Mauris tempor et diam at dictum. Nullam varius vel eros quis sodales. Donec dignissim massa quis dolor cursus, euismod ultrices tellus gravida. Suspendisse potenti. Sed posuere est dolor, eget sagittis nulla porttitor et. Sed eleifend nisl odio, a ultrices justo rhoncus viverra. Nam vel suscipit dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
34
+
35
+Morbi turpis neque, congue non pretium eu, laoreet eu eros. Aenean a turpis turpis. Aenean nulla sem, tempus id ornare eget, congue id purus. Sed porta urna odio, eget malesuada ante viverra nec. Aliquam erat volutpat. Mauris nisl mauris, viverra ut iaculis ut, ullamcorper non ante. Duis sodales urna ut risus ornare, et luctus quam lobortis. Sed nec ex sit amet quam euismod porttitor sit amet eget sem. Vestibulum vitae quam id erat varius egestas eu nec felis. Nam diam urna, tempus sit amet urna eget, posuere pellentesque risus. Vestibulum dictum eros ut neque dignissim, ut iaculis augue commodo. Aliquam pulvinar condimentum ipsum sed faucibus. Fusce eget erat a turpis tempus ullamcorper ut ut lorem. Morbi sed feugiat nisi.
36
+
37
+Nam imperdiet est in enim elementum, a maximus quam aliquet. Vivamus gravida maximus velit eget congue. Quisque tristique elit tincidunt est faucibus consectetur. Fusce tristique hendrerit nulla, eget pulvinar orci fermentum vitae. Sed id massa quis odio aliquet cursus ac id eros. Mauris ac porttitor arcu, ac accumsan urna. Sed vehicula sem justo, quis sollicitudin risus rhoncus eu. Praesent interdum leo quis sapien semper, sit amet sollicitudin orci congue. Integer vulputate nisl sapien, sit amet laoreet quam venenatis non. Nullam tincidunt pulvinar dolor blandit ultricies. Morbi aliquet odio in enim iaculis varius. Ut porttitor accumsan dui, at tristique dolor hendrerit vitae. Duis in metus ante. Vivamus diam orci, placerat at mi eu, euismod porttitor purus. Sed cursus enim sit amet massa finibus venenatis. Etiam at velit orci.
38
+
39
+Fusce porttitor sem augue, eget suscipit est consequat quis. Quisque leo ipsum, scelerisque eget iaculis non, vulputate ut libero. Curabitur dictum rutrum congue. Vivamus feugiat nibh luctus nunc porta gravida. Integer mauris sapien, gravida id magna nec, commodo efficitur urna. Nunc pharetra arcu aliquam purus suscipit, id ultrices lectus ultricies. Duis ornare rhoncus semper. Integer consectetur risus ut blandit vestibulum. Morbi sollicitudin facilisis nulla a finibus. Pellentesque in leo vitae mauris ornare vestibulum. Nam ligula diam, pretium ac luctus vitae, venenatis consequat turpis. Maecenas pellentesque a libero vel consectetur. Donec lectus nulla, lacinia quis nulla ut, feugiat sodales erat. Phasellus quis egestas justo, ut pellentesque velit. Fusce congue blandit lectus.
40
+
41
+Integer nulla lectus, malesuada sed gravida id, consectetur vel metus. Integer at tempor nisi. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec vel erat laoreet, gravida urna vel, malesuada augue. Mauris tincidunt dictum gravida. Aliquam quis metus arcu. Aenean blandit sagittis porta. Duis nec eros vel sem facilisis feugiat. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec pretium libero condimentum lobortis condimentum. Donec eu dolor porttitor arcu sagittis ullamcorper vel sit amet risus. Suspendisse et ex ex. Integer scelerisque nunc lectus, ut ultrices dolor consectetur lobortis. Fusce iaculis finibus neque nec vehicula. Morbi vel efficitur magna. Duis ante magna, accumsan ac vulputate vitae, sodales vel elit.
42
+
43
+Nullam pharetra tristique lacinia. Nullam a elementum justo. Quisque sed quam justo. In hac habitasse platea dictumst. Nullam suscipit euismod nulla sed imperdiet. Pellentesque eu dolor tempus velit dapibus porttitor. Vestibulum suscipit ex non lectus cursus ornare. Duis eget accumsan dui. Donec laoreet finibus pretium. Cras in molestie lectus. Mauris ac blandit ipsum, id iaculis metus. Fusce et lorem sed ex ultrices rutrum. Quisque dictum ante ac dui tincidunt elementum.
44
+
45
+Nulla fermentum risus nec lectus interdum varius. Vivamus non enim nulla. Praesent eget dolor vel eros viverra lacinia. Duis vehicula neque iaculis orci facilisis, lobortis posuere nisi condimentum. Etiam nibh felis, convallis ut tellus non, fringilla semper erat. Fusce facilisis in quam tristique finibus. In aliquam lectus a neque fermentum, eu bibendum lorem pretium. Mauris in justo ligula. Nunc imperdiet ligula non felis dapibus, quis gravida dui condimentum.
46
+
47
+Phasellus congue massa ac orci mollis venenatis. Curabitur quis feugiat lacus, dapibus pretium lectus. Nam nec est luctus, pretium metus eget, viverra nisl. Aliquam viverra neque mi, vitae feugiat augue pellentesque at. Mauris pellentesque volutpat ligula. Quisque orci quam, blandit in libero a, malesuada suscipit massa. Ut viverra finibus tortor eget fringilla. Nulla bibendum diam vehicula nulla dapibus, vitae tempus turpis malesuada. Etiam convallis tincidunt viverra. Morbi ut laoreet odio. Cras accumsan ligula nec ipsum pharetra, vitae porttitor est laoreet.
48
+
49
+Curabitur efficitur, mauris sollicitudin condimentum tincidunt, sapien massa consequat sem, id blandit massa ante quis nibh. Phasellus mollis lorem a diam condimentum venenatis. Suspendisse in iaculis urna. Nam pharetra scelerisque tempor. Etiam facilisis leo a tincidunt dignissim. Donec efficitur sed turpis eget dapibus. Nunc ac porttitor odio.
50
+
51
+Maecenas sodales libero a diam sagittis, non rhoncus purus vestibulum. Aenean massa arcu, laoreet lobortis tempor et, faucibus sit amet metus. Curabitur ac aliquam metus, in aliquam massa. Aenean efficitur pulvinar turpis a accumsan. Praesent sed feugiat ligula. Ut in mauris molestie, porttitor lorem eu, consectetur nulla. Praesent id urna vestibulum mauris feugiat viverra. Sed elementum neque dolor, ultricies vehicula nunc finibus vitae. Quisque bibendum dapibus dolor, at molestie eros bibendum eu. Nullam tortor sem, tincidunt sit amet tristique sit amet, finibus at nulla. Vestibulum pellentesque rhoncus nisl ac sollicitudin.
52
+
53
+In elementum mollis nunc in ultrices. Donec at nunc vel mi hendrerit feugiat. Sed vulputate sodales vestibulum. Nulla fringilla massa vitae arcu rutrum, id dignissim ante pulvinar. Donec dictum a purus nec auctor. Mauris quis nisi pellentesque, viverra tellus sed, interdum erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
54
+
55
+Proin eget fermentum lorem. Ut ullamcorper est magna, hendrerit vestibulum felis bibendum quis. Sed sagittis dolor id elit scelerisque rutrum. Donec malesuada commodo ultricies. Maecenas magna libero, molestie vel interdum condimentum, euismod vel leo. Sed id urna id urna condimentum dictum nec quis metus. Vivamus in magna quam. Vivamus volutpat, ante non porta fringilla, diam justo sagittis nisl, at luctus orci enim eget ante.
56
+
57
+Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Sed laoreet vitae nulla ut pulvinar. Curabitur tristique pulvinar nulla a aliquam. Sed blandit ligula odio, eget pulvinar risus tincidunt non. Nullam eget risus at eros scelerisque tempor id a neque. Integer eget nibh non nulla fringilla condimentum. Proin nisl ipsum, placerat ut auctor sed, mollis id enim. Morbi eget dolor sem. Suspendisse metus arcu, pretium ac tempor id, aliquam volutpat diam. Duis viverra, urna vitae hendrerit facilisis, leo quam ultricies mi, id luctus mauris lectus vitae quam.
58
+
59
+Fusce sagittis neque ornare justo aliquet, vitae tempor nunc eleifend. Praesent eget posuere sem. Ut tristique ante vel quam tristique efficitur. Proin eu sapien maximus, hendrerit magna a, convallis nulla. Cras iaculis rutrum imperdiet. Donec tempor felis nec ipsum consectetur fringilla. Aliquam placerat mauris erat, quis venenatis magna maximus vel. Integer porta blandit nulla ut tincidunt. Fusce sed ultricies augue. Proin feugiat placerat nibh, sed hendrerit elit pellentesque a. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Vivamus ut lobortis est, a auctor mi. Morbi pretium dapibus ligula a malesuada. Duis ante quam, lobortis id venenatis sit amet, consequat eu urna.
60
+
61
+Donec mattis rutrum tellus eu pellentesque. In hac habitasse platea dictumst. Quisque elementum a augue non consequat. Vestibulum vel venenatis ante, id gravida erat. Aliquam et ipsum a erat facilisis vehicula eu id purus. Morbi sed tellus at augue convallis commodo quis suscipit eros. Nam eleifend ante sed orci faucibus, vitae accumsan dui blandit. Donec non dolor neque. Sed tristique est id orci finibus venenatis. Sed consectetur dolor eget consectetur ornare. Cras eget bibendum neque. In eleifend mi nec magna gravida, quis ultricies sapien interdum. Donec interdum, orci quis imperdiet porttitor, tortor libero luctus leo, at cursus risus eros at mi.
62
+
63
+Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam at porttitor leo. Nulla imperdiet commodo est id consectetur. Morbi a elit commodo, fringilla dui at, finibus ex. Aliquam aliquam ut risus quis iaculis. Quisque consectetur auctor sapien quis ultricies. Quisque ut condimentum urna. Suspendisse eu massa a velit pharetra luctus sit amet dapibus nisl. Quisque iaculis lectus magna, condimentum lacinia lacus dignissim id. Fusce sit amet urna vitae massa venenatis semper ac eget nunc. Donec fermentum sit amet elit quis malesuada. Morbi facilisis sapien cursus quam vulputate, id facilisis ex pulvinar. Nam id ligula vestibulum, blandit turpis nec, ornare nibh.
64
+
65
+Vivamus in viverra dui. Nulla egestas est eu convallis venenatis. Etiam feugiat dui consequat dui varius, sed consectetur metus laoreet. Mauris ornare sapien non neque gravida placerat. Phasellus mattis eu dolor nec cursus. Etiam libero purus, varius et dictum eget, euismod eget dolor. Phasellus molestie porta ligula, nec imperdiet sem fermentum at.
66
+
67
+In at quam nec quam aliquam tincidunt. Aenean semper vel velit at commodo. Duis et urna ut nibh mollis commodo. Ut rhoncus auctor ante non ultricies. Curabitur at bibendum erat. Donec volutpat nunc est, at tempus ex laoreet at. Aenean rhoncus libero non lobortis maximus. Quisque tincidunt id turpis quis laoreet. Integer id massa ex. Aenean consequat quis ligula eget commodo.
68
+
69
+Etiam in dui ac dui facilisis varius. Donec in magna nunc. Pellentesque a lacinia dui, sed vestibulum est. Mauris sit amet nisi sit amet turpis tristique consectetur. Vivamus sed volutpat velit, vitae fringilla enim. Curabitur massa magna, pretium in nisl eget, blandit aliquam ante. Donec congue euismod finibus. Nulla vel semper eros, nec pharetra metus. Nulla facilisi. Curabitur pharetra sit amet massa a feugiat. Duis pharetra ante nec quam scelerisque iaculis. Morbi vulputate semper lacus, eu viverra lacus porttitor nec. Mauris a lacinia turpis, ut convallis nunc. Pellentesque posuere elementum lectus vel interdum. Nulla ultricies ex lacus, commodo feugiat nisl imperdiet ut.
70
+
71
+Etiam id consequat urna, in consectetur tortor. Praesent pharetra augue eu dolor luctus, eget pulvinar libero ullamcorper. Nam eu feugiat mauris, quis ultrices enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed erat purus, ultrices eu pellentesque efficitur, efficitur ac enim. Mauris eu aliquam nibh, eget congue eros. Suspendisse auctor quis odio interdum imperdiet. Vestibulum et pretium mi, a viverra risus. Mauris sit amet felis sit amet magna condimentum elementum. Donec dapibus, erat ut dignissim tempus, sem nulla mollis nunc, dictum ullamcorper ante eros imperdiet orci. Donec leo tortor, hendrerit at pharetra sit amet, tincidunt et turpis.
72
+
73
+Ut quis elit posuere, efficitur ex id, efficitur metus. Integer dapibus dignissim magna nec pharetra. Fusce id blandit nisl. Sed vulputate justo neque, ac tempor felis sollicitudin eget. Vivamus malesuada dui leo, in accumsan lectus auctor eu. Nunc neque augue, dignissim eget cursus ac, malesuada ut lacus. Duis vitae orci a ante finibus faucibus. Praesent a urna accumsan, viverra purus nec, rhoncus augue. Quisque posuere vehicula viverra. Proin a erat sed risus congue auctor commodo eu eros. Vestibulum sit amet est in ipsum porta maximus vitae non urna. In quis ligula imperdiet, hendrerit diam sagittis, fringilla nisl. Phasellus vitae sollicitudin risus. Etiam eleifend augue nec fermentum posuere. Quisque sit amet scelerisque velit.
74
+
75
+Sed tellus justo, euismod et quam ut, dapibus elementum est. Curabitur at arcu id lectus pulvinar aliquet vel ut massa. Cras ut tortor egestas, condimentum ipsum a, posuere sapien. Maecenas tempor nisi urna, non mattis lectus feugiat id. Cras eget enim a eros iaculis tempus a ut sem. Integer pharetra dui id blandit venenatis. Morbi molestie, diam sed rutrum tristique, ligula lacus facilisis sapien, in fringilla elit eros sed ante. Nulla sollicitudin, felis vel ornare cursus, justo felis rutrum diam, non rutrum libero lectus sed tortor. Donec hendrerit, orci sed tempus dapibus, justo nibh congue elit, non placerat quam turpis a ante. Nulla molestie pellentesque augue, id scelerisque sapien venenatis at. Suspendisse felis massa, blandit nec scelerisque non, placerat vitae tellus. In laoreet est ut augue aliquam elementum. Nulla ornare, eros id pulvinar blandit, nisl mi pretium dolor, eu feugiat ipsum urna vitae arcu.
76
+
77
+Donec tristique, enim id elementum rhoncus, ex ex sagittis massa, sed lobortis mi massa eget justo. Pellentesque luctus rutrum ultricies. Vestibulum rhoncus augue vitae nisi scelerisque volutpat. Integer nec justo sed augue dapibus feugiat. Suspendisse ac mauris arcu. Sed at pellentesque leo. Mauris scelerisque eros orci, ut gravida arcu vehicula vel. Aenean nec aliquet augue. Etiam in urna vel diam vestibulum dictum a quis dui. Pellentesque non dictum sapien. Cras non blandit dolor. Phasellus tempor erat id nibh malesuada lobortis. Proin dapibus dolor quis convallis egestas. Praesent sed nunc hendrerit augue venenatis hendrerit.
78
+
79
+Nulla vestibulum lectus ac nunc feugiat, sit amet euismod metus lacinia. Nullam non lorem turpis. In sed ullamcorper libero. Nullam condimentum in orci non commodo. Quisque fringilla eros eget placerat fringilla. Vestibulum scelerisque neque ex, id sagittis tortor elementum in. Morbi mattis odio ac tortor pulvinar, in bibendum eros pellentesque. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nec tellus quis dui vulputate accumsan. Curabitur porta vitae nunc eu varius. Aliquam aliquam ante ut eros tempor congue vitae in nisi. Nunc auctor ultrices lorem, vitae efficitur erat varius in. Donec quis dolor turpis. Nulla consequat, ex dapibus vulputate condimentum, mauris arcu aliquam velit, sed ullamcorper arcu nisi sed tortor. In placerat euismod tempus.
80
+
81
+Nam venenatis, urna at viverra laoreet, sapien sem dignissim eros, et porttitor mi eros et quam. Aliquam cursus efficitur mi a dictum. Vivamus feugiat elit magna, eu tincidunt dolor faucibus eget. Vestibulum at tempus nunc. Nullam aliquet blandit risus ac efficitur. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu tortor dolor. Suspendisse ultrices tristique ex, non sollicitudin est dapibus sit amet. In sed auctor orci, at malesuada dui. Nulla facilisi. Etiam risus lacus, porttitor eget ligula sed, semper pharetra nisi. Morbi sit amet augue in ex lobortis vestibulum id id nisi. Suspendisse potenti. Quisque lacinia mauris nunc, id commodo tortor posuere aliquam.
82
+
83
+Nullam dictum augue est, dignissim pellentesque lacus blandit ut. Quisque quis erat eget ante consequat fringilla eget sit amet diam. Praesent lectus diam, congue id elit at, auctor fringilla enim. Donec eget maximus felis, id sodales justo. Phasellus vehicula efficitur magna. Nunc congue, augue non ultricies volutpat, est tellus egestas turpis, eu blandit tortor ipsum venenatis dui. Ut malesuada leo libero, in volutpat augue dictum ac. Nulla eleifend erat gravida dolor placerat, sit amet aliquet sapien hendrerit. Curabitur rutrum ligula eu enim imperdiet, eu tincidunt sapien placerat. Suspendisse potenti. Curabitur tincidunt sem ut lectus vestibulum varius. Quisque ultrices odio tempus, pharetra sem et, imperdiet nulla. Donec dapibus pretium dolor. Donec vel turpis dapibus, laoreet nulla a, pharetra neque. Mauris vel dui eget neque accumsan varius consequat id ligula.
84
+
85
+Donec sit amet magna eget libero vestibulum venenatis. Nunc at facilisis arcu. Mauris vulputate dui in massa venenatis, a condimentum diam venenatis. Fusce quis tellus et ex tincidunt malesuada. Aliquam tortor neque, elementum quis commodo quis, iaculis vitae mi. Cras et justo a sem pellentesque interdum ut vel massa. Suspendisse elementum nisl et ante elementum vehicula. Phasellus quis eros sit amet mauris mattis hendrerit sit amet et dui. Etiam sed velit pharetra ante sodales sodales in a odio. Morbi nisi augue, commodo et ante ut, aliquet feugiat urna. Vivamus fringilla justo sit amet enim consequat iaculis. Proin aliquam, metus at ullamcorper dapibus, neque sem congue erat, a pellentesque nulla tortor vitae magna.
86
+
87
+Mauris placerat volutpat semper. Sed imperdiet ante id pharetra porta. Donec volutpat turpis ut ligula ornare, ac eleifend nulla congue. Nulla eget erat id risus faucibus consequat. Phasellus et consectetur lectus. Mauris consequat dolor nec finibus laoreet. Nunc eget magna non lorem ultricies aliquet. Sed auctor ipsum odio, luctus viverra orci mollis nec. Nunc dignissim lectus eu finibus scelerisque. Cras vehicula sem eros, id consectetur arcu bibendum non. Duis eget est ut lectus blandit porttitor vel mollis lorem. Fusce nec volutpat libero. Morbi rutrum at mauris a fermentum. Sed a felis nec lacus pretium semper sed sit amet turpis.
88
+
89
+Aliquam erat volutpat. Nam quis dictum turpis. Vestibulum vitae massa vel magna mattis porta. In ac ligula quis felis congue congue consequat fermentum nunc. Etiam tincidunt lectus ac ex rutrum elementum. Nullam volutpat eu sapien ac dignissim. Quisque congue, turpis nec hendrerit efficitur, nisi erat tincidunt metus, et aliquam turpis ex at lorem. Phasellus ultrices libero non tellus placerat consectetur. Etiam a orci id velit aliquam maximus quis sit amet neque. Quisque accumsan enim non laoreet fringilla. Aliquam vehicula ullamcorper augue, ut varius augue placerat at. Phasellus posuere tellus vitae lectus tempor, vel efficitur massa sagittis. Aliquam erat volutpat. Donec eu auctor est. Vestibulum at urna odio.
90
+
91
+Sed erat justo, placerat id orci eu, finibus facilisis magna. Donec lectus sem, iaculis ac elit eu, tincidunt laoreet dui. Ut hendrerit mollis magna nec malesuada. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam pharetra egestas sem, placerat congue est dapibus vitae. Etiam et nisi lectus. Pellentesque egestas, purus sed suscipit rutrum, quam quam interdum eros, sed tempus odio eros at mi. Pellentesque placerat vestibulum felis accumsan aliquet. Donec lobortis luctus diam sed pretium. Integer lectus velit, viverra et diam non, auctor accumsan mauris. Pellentesque placerat rutrum justo, vitae venenatis nisi condimentum lacinia.
92
+
93
+Sed lacus libero, hendrerit et est vel, dapibus pulvinar tortor. Sed pellentesque dui sed aliquam tempus. Cras sed consequat tortor. Etiam tempor diam vitae sem euismod luctus. Donec mattis auctor efficitur. Donec ut odio in dui pellentesque fringilla. Aliquam erat volutpat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Vestibulum a accumsan arcu. Donec tempor purus fringilla felis mattis efficitur. Sed faucibus volutpat eros sit amet congue. Aliquam magna erat, feugiat vitae magna vitae, pretium ultrices nisi. Cras nec purus eget justo sodales porta quis nec dolor.
94
+
95
+Nulla leo nisl, feugiat eget eleifend ac, lobortis a velit. Quisque ac euismod elit. Curabitur volutpat tristique dolor, et ultrices quam congue id. Morbi efficitur augue in arcu lobortis, ac laoreet augue suscipit. Maecenas tristique congue accumsan. In hac habitasse platea dictumst. Suspendisse vel fermentum sapien, sed vehicula est. In luctus gravida lacinia. Aenean tristique augue vel diam pulvinar, finibus imperdiet neque commodo. Curabitur lorem sapien, sodales a dictum ut, luctus vel massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus nec feugiat lorem, molestie tempor leo. Phasellus rutrum tempor massa, vitae rutrum justo egestas quis. Sed feugiat laoreet euismod.
96
+
97
+Nam et nisi blandit, aliquam enim at, euismod ex. Fusce interdum luctus luctus. Aliquam gravida vitae lorem in rutrum. Nulla a eros eget nulla efficitur hendrerit nec sed velit. Nam luctus pharetra consectetur. Mauris vulputate, enim vel scelerisque dignissim, est risus egestas mauris, sed pretium felis velit quis elit. Mauris vel eros semper, porta eros quis, dapibus neque. Mauris vestibulum vulputate metus in scelerisque. Mauris semper neque massa, quis dignissim metus rhoncus non. Phasellus pharetra auctor ante, id dignissim purus ullamcorper id. Morbi suscipit quis ex et congue. Morbi non vestibulum quam. Nullam pulvinar nisi ut augue vestibulum consectetur. Aliquam fringilla arcu et odio molestie, nec tincidunt dolor efficitur. Praesent vitae molestie nisl. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
98
+
99
+Morbi lectus nibh, pharetra a lectus non, vulputate placerat augue. Sed ac orci dignissim, mattis quam quis, viverra tortor. Cras venenatis consectetur elit, sed ornare felis iaculis ac. Quisque non nulla et eros pellentesque faucibus. Ut nec orci libero. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Quisque gravida augue at nisi ultricies, vitae rhoncus ante fermentum. Etiam consectetur, justo id dapibus blandit, urna eros elementum ligula, iaculis sagittis enim sem et nunc. Etiam nec faucibus tellus.
100
+
101
+Mauris eu velit nec turpis dictum pulvinar. Quisque sed neque odio. Nunc nec neque imperdiet, rhoncus neque vel, venenatis tellus. Sed tincidunt justo blandit, bibendum nisi pulvinar, sollicitudin nibh. Praesent aliquam mattis pharetra. Nam dignissim mi quis suscipit semper. Cras ullamcorper justo sed purus imperdiet sagittis. Aliquam in ullamcorper lectus. Nunc eros arcu, commodo ac blandit a, lobortis id nunc. Duis eu sagittis diam, et feugiat diam. Curabitur ullamcorper sit amet nibh sed rhoncus. Etiam porttitor, lacus eget facilisis porta, risus felis faucibus ligula, eget egestas lorem turpis in nisl. Fusce tincidunt in massa sed lobortis.
102
+
103
+Vestibulum odio ante, convallis ac nisi nec, lacinia bibendum nulla. Sed quis felis feugiat, rhoncus leo sed, aliquet odio. Nam neque felis, maximus in tempor ut, tempus sit amet tortor. In sollicitudin nec enim ac vestibulum. Cras at ultrices erat. Duis hendrerit a nisi eget ultrices. Duis convallis diam elit, eu iaculis velit euismod at. Nulla elementum justo ac sem consequat, eget auctor elit facilisis. Vivamus tincidunt lobortis lacus eget ornare. Nulla facilisi. Morbi elit ligula, tristique vel felis nec, vehicula euismod lorem. Proin interdum nulla eu neque malesuada, non laoreet nisi euismod. Sed malesuada venenatis nibh, non porta leo commodo eu. Fusce vitae mi interdum, scelerisque leo sed, ultricies sapien.
104
+
105
+Praesent rhoncus massa a est pharetra, ac eleifend dui euismod. Donec tincidunt, elit at pellentesque scelerisque, felis justo sollicitudin turpis, a convallis nulla massa sit amet purus. Sed ipsum nisi, finibus non vehicula sit amet, suscipit non eros. Vivamus sed porttitor massa, ac aliquam risus. Quisque euismod metus sem, vel porttitor purus molestie eget. Nulla condimentum leo dictum, volutpat ligula ac, lobortis erat. Pellentesque justo risus, mollis sit amet blandit quis, porttitor quis risus.
106
+
107
+Curabitur tortor magna, consectetur et nulla tristique, semper dapibus dolor. Donec tempus semper convallis. Nunc quam tortor, hendrerit ac facilisis nec, consectetur ac arcu. Mauris consequat magna at lorem facilisis maximus et ut sapien. Nullam at facilisis risus. Vestibulum semper dapibus metus, at rutrum mauris fringilla ullamcorper. Phasellus justo augue, vehicula eget ante in, fringilla euismod sapien. Pellentesque faucibus, urna vitae vehicula maximus, tellus lacus commodo massa, a iaculis nunc est non ex. Nunc lacus elit, scelerisque ut vestibulum nec, pulvinar nec est. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas imperdiet imperdiet facilisis. Integer quis fringilla elit, vitae condimentum purus. Praesent cursus, turpis quis finibus aliquam, leo dolor viverra libero, id porttitor lacus arcu sit amet lectus. Quisque luctus mauris diam, ac blandit lacus interdum ac.
108
+
109
+Mauris nec sapien vel justo efficitur suscipit. Ut facilisis vulputate dolor at pulvinar. Nunc et velit vehicula, fringilla lorem vel, fringilla metus. Praesent id erat nibh. Praesent eu facilisis sem. Ut sit amet nisl dignissim, tristique dolor eget, sollicitudin nisi. Aliquam at tempor ex. Cras viverra interdum consequat. Etiam commodo metus quis venenatis ultrices. Etiam sit amet tincidunt nisi. Mauris consequat rutrum lorem. Etiam tristique urna gravida pellentesque interdum. Proin nec dui at elit posuere cursus quis in eros. Sed condimentum odio nec dui eleifend, accumsan scelerisque arcu fermentum. Morbi condimentum pulvinar gravida. Suspendisse porta viverra turpis ut condimentum.
110
+
111
+Proin posuere libero sem, nec laoreet sem pulvinar nec. Etiam lobortis arcu nec enim commodo vulputate. Vestibulum felis sem, vestibulum id purus hendrerit, lobortis luctus est. Aliquam varius aliquet erat, eu bibendum leo dictum eu. Duis congue magna id nulla maximus, sed bibendum est tempus. Nullam vitae sapien molestie, interdum ligula a, accumsan ex. Ut rhoncus lorem eget mi pharetra laoreet. Maecenas ultrices lobortis risus, et condimentum enim hendrerit in. Proin lacinia risus non nulla convallis ultricies. Etiam eget ultricies quam, quis luctus lectus. Nam sollicitudin cursus felis, et ullamcorper ante. Mauris commodo pulvinar suscipit.
112
+
113
+Praesent ornare nulla eget diam scelerisque aliquet. Sed dictum in augue ut tristique. Proin sodales purus eu nisi sodales convallis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean gravida sapien vitae arcu porttitor, vitae cursus lorem cursus. Nullam accumsan est nec libero facilisis ornare. Praesent dapibus bibendum turpis, ut convallis justo rhoncus a. Suspendisse eu sem eu lorem elementum tincidunt. Sed ornare consectetur massa in lobortis. Vivamus nec tortor sed risus vehicula egestas. Donec porttitor pellentesque leo. Pellentesque sit amet commodo lectus. Nunc accumsan at erat convallis pulvinar.
114
+
115
+Morbi vitae cursus mauris. Praesent imperdiet enim a nulla rutrum, nec sodales sapien porta. Cras lectus metus, porttitor eu massa rutrum, imperdiet cursus quam. Morbi at augue venenatis, auctor nisl id, dictum arcu. Donec vitae interdum ligula. Duis varius sed nibh vel condimentum. In tristique metus vel sodales dapibus. Suspendisse condimentum finibus tellus nec porta. Duis eu eros ut tortor euismod condimentum vel vel nisi. Vestibulum vestibulum tristique sapien eget ullamcorper. Nullam faucibus rhoncus porta. Morbi quis eleifend nulla, eget mollis est. Quisque scelerisque faucibus blandit. Integer condimentum neque tortor.
116
+
117
+Sed id aliquet purus, in iaculis velit. Vestibulum tristique ante eget purus egestas consequat. Aliquam pharetra metus nec ligula pretium, id aliquam ante fermentum. Aenean commodo sed erat vitae dapibus. Etiam quis nulla sed purus mattis venenatis. In mollis in nisi et faucibus. Proin et est nisl. Mauris molestie, tortor quis semper malesuada, ipsum augue luctus massa, in feugiat nunc dui vel dui.
118
+
119
+Nunc commodo justo at est dictum convallis vitae at mi. Nam ex massa, rhoncus ut aliquet et, suscipit a est. Curabitur vitae volutpat urna. Fusce mattis quis nulla gravida tincidunt. Vivamus euismod turpis et lacus varius pretium. Ut vel urna non nibh condimentum sodales. Nullam a rutrum dui.
120
+
121
+Donec pharetra ultrices massa, quis ultrices justo efficitur sed. Fusce nec aliquam nulla. Sed at malesuada erat. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas viverra ornare est at vehicula. In euismod est in molestie vestibulum. In lectus turpis, maximus ac blandit in, elementum sed dui. Aenean quis eros vitae dolor pellentesque cursus. Quisque a tristique metus, at suscipit tellus.
122
+
123
+Pellentesque malesuada quam aliquam metus rhoncus, porttitor dictum tellus commodo. Pellentesque lacinia velit nec ex semper vulputate. Proin fermentum sapien vitae nulla vulputate, non placerat augue volutpat. Nam fermentum sapien at rhoncus cursus. Nullam metus dolor, auctor non erat sit amet, consequat rutrum neque. Pellentesque interdum tellus sit amet dui cursus elementum. Donec et nisi bibendum, consectetur tortor vitae, porttitor ex. Etiam quis dictum libero.
124
+
125
+Duis sagittis tristique facilisis. Quisque nec eros risus. Integer laoreet nisi et elit fermentum auctor. In id mauris ligula. Proin quis sapien ut arcu blandit tempus. Nulla tellus elit, sodales a augue ac, congue cursus arcu. Pellentesque fermentum ultrices nulla ut sagittis. In ultricies lectus ut lacinia tristique. Vestibulum ac augue ultricies, ornare purus vitae, mollis ipsum. Maecenas dictum odio at nunc sollicitudin, vel dignissim mi lacinia.
126
+
127
+Morbi at congue tortor. Vivamus eget massa sodales, lobortis risus ac, rutrum lorem. Cras quam nulla, euismod ut venenatis vel, auctor a purus. Vestibulum dignissim, sem vitae consectetur accumsan, ligula lacus ornare eros, eu mattis dolor ipsum id arcu. Curabitur in odio quis ante accumsan malesuada sit amet ac erat. Aliquam diam tortor, ultrices a quam et, ullamcorper porta massa. Praesent vel mauris sit amet orci fermentum aliquam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sed ante dolor. Vestibulum imperdiet libero turpis, sit amet facilisis neque imperdiet nec. Sed molestie eu ex at vulputate. Phasellus pellentesque consectetur quam, pharetra consectetur urna interdum molestie.
128
+
129
+Nulla facilisi. Nam sollicitudin auctor mi in interdum. Mauris egestas ex felis, vel convallis metus hendrerit in. Quisque a semper erat. Aliquam erat volutpat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nulla erat elit, aliquet id lacus ac, finibus efficitur risus. Fusce eget imperdiet mi. Ut eu ante facilisis, pulvinar orci ac, vulputate purus. Donec scelerisque, turpis eu sodales sagittis, ante risus sollicitudin dui, at facilisis erat tellus sed tortor. Nulla malesuada nulla et sagittis venenatis. Nulla venenatis ornare ex aliquet lobortis. Nam aliquam porta consectetur. In rutrum volutpat rutrum. Nunc dictum, odio vel lacinia suscipit, dolor turpis consectetur dolor, non elementum ligula elit et metus.
130
+
131
+Sed in dictum lorem. Duis vestibulum diam lacus, at bibendum urna posuere ut. Etiam eu ligula ac nunc cursus aliquet semper quis felis. Nullam iaculis lacus pellentesque enim pretium, quis molestie turpis feugiat. Aliquam malesuada ut leo id rutrum. Phasellus in mi odio. Fusce hendrerit ullamcorper tristique. Integer mattis sagittis mi non blandit. Aliquam pretium felis nulla.
132
+
133
+Proin bibendum turpis nec eros facilisis, ut fringilla ipsum consequat. Duis ullamcorper nisl orci, eu venenatis nisl egestas ut. Phasellus id pellentesque orci, id iaculis nisi. Nunc nec malesuada libero. Pellentesque accumsan sem quam, nec ultricies nisi egestas a. Morbi bibendum porttitor massa nec vulputate. Nunc erat diam, malesuada vel pretium eget, mattis sed orci. Duis nec scelerisque lacus, eu volutpat est. Sed id iaculis lacus. Suspendisse pellentesque eros ac metus porttitor cursus. Maecenas sed tellus a quam tempor vulputate. Sed ultrices lorem in eros tristique scelerisque. Nullam ornare odio auctor nisi imperdiet, vel cursus diam iaculis. Vestibulum finibus tortor nec purus semper iaculis. Pellentesque molestie dolor at hendrerit molestie.
134
+
135
+Aenean quis interdum nulla. Nunc mollis, mauris non sagittis iaculis, turpis arcu euismod massa, id varius purus tellus vestibulum est. Aenean consectetur sit amet risus nec tempor. Sed efficitur eros augue. Ut placerat, ex eu dictum scelerisque, tellus ante pharetra elit, ac auctor ipsum dolor non augue. Aenean eleifend nunc tellus, quis blandit dolor blandit ac. Nunc metus augue, pulvinar eu cursus id, scelerisque eu ante. In hac habitasse platea dictumst. Donec suscipit risus quis mauris consequat luctus. Nullam vel purus diam. Cras eget urna in ligula tempor suscipit.
136
+
137
+Sed in ligula eu augue elementum egestas. Curabitur fermentum cursus justo, quis volutpat nunc. Nulla ut maximus turpis. Praesent aliquam, urna cursus rhoncus finibus, augue ipsum elementum enim, ac imperdiet odio nisi iaculis arcu. Suspendisse efficitur tellus eu erat accumsan egestas. Duis at tincidunt elit. Nullam interdum, eros non molestie commodo, quam turpis luctus orci, nec vehicula augue nulla sed velit. Mauris imperdiet, elit non volutpat pulvinar, nisl dolor scelerisque ex, vel euismod elit ipsum ut ipsum. Praesent ut velit semper, varius tortor id, laoreet enim. Aliquam dictum urna mauris, ut vestibulum sapien lacinia eu. Duis egestas varius est, vitae ornare libero porttitor efficitur. Sed euismod ultricies urna vel maximus. Praesent dictum euismod orci consectetur interdum. Sed viverra pulvinar eros, ac egestas lacus tincidunt in. In feugiat dui at feugiat facilisis.
138
+
139
+Praesent volutpat libero in nunc mattis, sed faucibus orci venenatis. Nulla porttitor venenatis tempor. Sed ante felis, tristique fringilla laoreet eu, ultrices eu nulla. Maecenas sed consectetur diam. Fusce eget ante libero. Phasellus pellentesque dignissim consequat. Ut sed iaculis ligula. In hendrerit neque dui, nec finibus odio commodo non. Nunc at metus sapien. Nam facilisis, elit non vulputate lobortis, ligula nibh convallis tortor, eget lobortis diam sapien ut est. Praesent eu libero at turpis suscipit pretium vitae et ante. Quisque sed tincidunt urna, at consequat mi. Sed mattis sit amet orci a gravida. Nunc ex odio, egestas vitae facilisis vel, imperdiet in dui. Nulla eu nisi ut nibh tempor pulvinar ut consectetur neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
140
+
141
+Donec at porttitor nisi, nec luctus dolor. Maecenas blandit augue non gravida malesuada. Vestibulum id finibus felis. Mauris malesuada augue velit, in tempus tellus aliquet eget. Aenean in orci dui. Quisque sit amet tempor lectus. Pellentesque a diam et urna posuere placerat. Suspendisse in nisi eget nulla condimentum bibendum in ut leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed tortor dolor, rutrum et commodo vel, condimentum sit amet tellus. Ut eu lectus in libero rutrum tincidunt quis at purus. Curabitur facilisis efficitur lectus, a suscipit mauris lacinia a. Donec non justo ac libero vehicula tristique. Phasellus id gravida risus, in placerat eros.
142
+
143
+Mauris porta justo non convallis iaculis. Duis varius efficitur lorem. Aliquam a tellus sit amet dolor rutrum tristique. Cras fermentum consequat tempor. Nam sollicitudin metus nulla, quis varius mauris efficitur vitae. Curabitur vehicula, augue et ornare pharetra, nisi nisl pellentesque sapien, nec bibendum libero erat quis augue. Vivamus nec sem ac lorem blandit blandit. Ut maximus erat at augue finibus, ut euismod purus eleifend.
144
+
145
+Nulla at aliquam elit, ac mattis eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum sagittis euismod pellentesque. Nam in hendrerit lectus. Maecenas dignissim quis libero in posuere. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla eu magna finibus, luctus libero at, rutrum lorem. Donec vehicula consequat lorem. Nam hendrerit massa ut tincidunt feugiat. Phasellus pretium turpis eget orci venenatis facilisis. Phasellus et lorem vitae enim rutrum dapibus. Suspendisse et sodales dolor, eget luctus nisi. Fusce sed venenatis metus, blandit rutrum libero. Quisque dignissim a odio quis maximus.
146
+
147
+Proin hendrerit sed tortor scelerisque vehicula. Aenean feugiat magna eros, ac tincidunt erat tincidunt ut. Curabitur malesuada eget sem sed malesuada. Aliquam eu euismod nunc. Sed at hendrerit massa, quis ornare mi. Quisque vel ipsum tincidunt, tempor sem sit amet, condimentum nulla. Praesent pretium, ex id convallis varius, sapien magna commodo tellus, a commodo augue neque at sapien. Nam rutrum, eros et mollis finibus, arcu urna sollicitudin sapien, volutpat fringilla mauris justo ac arcu. Maecenas auctor, nisl nec tristique aliquet, leo metus semper tellus, in porttitor odio felis at erat. Nulla at pellentesque sem. Quisque mattis nulla ac efficitur sollicitudin. Nulla imperdiet semper risus, sit amet volutpat tellus posuere a. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent molestie ut leo vitae porttitor. Suspendisse sed dapibus erat.
148
+
149
+Donec luctus, diam nec imperdiet feugiat, quam nulla sollicitudin justo, vehicula ultricies felis elit non ante. Etiam viverra, mauris a fringilla venenatis, lorem leo consectetur elit, ut interdum augue libero nec turpis. Duis porttitor nibh ante, sed hendrerit nisi fermentum sit amet. Fusce vitae mattis purus. Quisque fermentum aliquet feugiat. Sed mollis nulla a tempor lobortis. Morbi tristique magna a vehicula hendrerit. Nunc tristique enim eget ante vulputate venenatis. Suspendisse scelerisque lacinia lectus eu euismod.
150
+
151
+Vivamus faucibus volutpat rutrum. In at nisi at sapien iaculis venenatis. Maecenas venenatis purus dignissim neque pretium, at commodo justo gravida. Donec vel mi scelerisque nulla congue vulputate sit amet id mauris. Sed placerat ligula sit amet fringilla commodo. Sed nisi dui, lacinia ut congue id, vulputate non orci. Nulla rhoncus, orci non aliquet rutrum, enim ante pharetra libero, sed tincidunt dui neque non lorem.
152
+
153
+Sed vitae lacus sed tortor suscipit accumsan nec id leo. Duis enim augue, cursus nec augue consequat, pellentesque aliquam dolor. Curabitur ut vehicula elit. Fusce ac iaculis ex, eu consequat libero. Aenean non porta augue, et dapibus enim. Nunc a aliquet lectus, a commodo urna. Fusce eleifend faucibus pellentesque. Vestibulum laoreet placerat metus at sodales. Vivamus a commodo velit. Nam turpis tellus, laoreet ac dictum quis, sodales nec purus. Pellentesque in tortor velit.
154
+
155
+Ut orci eros, auctor ac sollicitudin sed, faucibus nec lorem. Integer in porttitor est. Nulla molestie felis id mi rutrum ultricies. Sed hendrerit eleifend fringilla. Fusce elit eros, bibendum vel euismod sed, molestie eu nisl. Mauris dignissim lacus arcu, eget imperdiet lectus egestas et. Suspendisse euismod sapien ac lectus suscipit tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Etiam eleifend placerat eleifend. Maecenas aliquet tincidunt pretium. Vestibulum fringilla pulvinar tellus, nec scelerisque diam pharetra ut. Quisque eu dictum justo. Suspendisse molestie sem sit amet velit dapibus hendrerit. Nam porttitor augue eu sapien aliquet aliquam. Aliquam nec consectetur tellus, quis volutpat neque.
156
+
157
+Proin metus lorem, placerat quis eleifend eget, pellentesque tempor sapien. Aenean interdum urna eget orci iaculis, nec bibendum eros fermentum. Ut sed consectetur elit. Morbi eu sodales dui. Donec accumsan nunc nunc, ac ornare mauris consequat vel. Pellentesque vel est id felis fringilla condimentum vitae at dui. Suspendisse feugiat nibh odio, et iaculis lacus interdum vel. Suspendisse ut dolor ipsum. Proin ut metus id purus mollis eleifend nec et libero. Etiam elementum pretium nulla at fermentum.
158
+
159
+Pellentesque fringilla rhoncus tellus quis tempus. Nunc vitae est sed metus ultricies condimentum id tincidunt neque. Mauris lobortis nibh odio, nec aliquam ligula rhoncus ut. Aliquam commodo molestie fringilla. Proin tincidunt libero eu ipsum tristique laoreet. Praesent nisi leo, aliquet nec eros sed, accumsan accumsan velit. Duis vehicula vitae sapien et pellentesque. Cras tempor velit vitae ullamcorper porttitor. Aliquam ac dapibus nibh. Nunc in justo viverra, interdum eros consequat, sagittis est. Quisque commodo turpis et tincidunt tincidunt. Fusce ullamcorper tellus massa, rutrum egestas risus consectetur at. Nulla quis odio a tortor commodo dapibus.
160
+
161
+Aliquam erat volutpat. Vivamus et varius odio. Proin vulputate semper rhoncus. Sed porttitor ut lacus eu convallis. Duis lectus dui, venenatis a turpis ut, mollis placerat purus. Maecenas sodales urna imperdiet turpis commodo efficitur. Fusce iaculis ante in malesuada gravida. Mauris non lacinia lectus. Proin mollis leo sed ullamcorper aliquam. Integer pulvinar sodales nibh ac hendrerit. Vivamus quis magna sem. Nunc a felis sed sem rutrum dignissim. Integer vulputate porttitor nisl eu efficitur. Praesent aliquet sit amet libero non faucibus.
162
+
163
+Nulla lacinia, nulla sed aliquam pellentesque, tellus ligula pretium tortor, sit amet iaculis erat velit nec nulla. Etiam condimentum cursus leo, lacinia tempor mi finibus id. Duis ac iaculis quam. Nunc et arcu lobortis ex rhoncus tincidunt. Integer at pellentesque odio. Praesent nec est id dolor rhoncus commodo ut viverra elit. Mauris at enim iaculis, lobortis nibh eu, tempus tellus. Nulla quis risus a lorem vulputate bibendum ut at libero. Quisque eleifend finibus leo a ullamcorper.
164
+
165
+Aenean euismod nulla ipsum, sed mollis lacus sodales hendrerit. Cras sit amet tincidunt orci. Integer mattis consequat erat nec vestibulum. Etiam aliquet ante ut sodales luctus. Integer hendrerit lectus ac orci malesuada blandit. Duis imperdiet ipsum nunc, ac mollis lacus sollicitudin gravida. Sed ac diam eu libero vulputate tincidunt id ut ante. Etiam nisl dolor, varius et consectetur sit amet, laoreet in lacus. Etiam porta sed lacus placerat posuere. Ut leo urna, fermentum sed velit eget, molestie elementum purus. Aenean molestie sem felis, id vulputate nisi eleifend id. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
166
+
167
+In nibh eros, accumsan eget consectetur eget, rutrum ut urna. Nam malesuada rutrum nisl mollis semper. Aenean quam ligula, congue at erat id, tristique faucibus ipsum. Donec quis ligula at sapien ultricies bibendum non at quam. Nullam sit amet pharetra quam, eget maximus magna. Phasellus at ligula tellus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum nec pharetra orci. Curabitur nec mauris ut lacus imperdiet laoreet ut viverra nulla. Nullam vel laoreet eros. Vestibulum facilisis quis urna non faucibus.
168
+
169
+Nullam accumsan metus sed rutrum tristique. Vestibulum a neque sed velit tincidunt sagittis a in justo. Suspendisse potenti. Suspendisse molestie quam lectus, vel commodo turpis egestas vel. Nulla eu nulla posuere, facilisis purus at, dapibus felis. Sed tortor justo, rhoncus a augue sit amet, tempor consectetur nunc. Donec ut convallis sem, id convallis nunc. Phasellus a risus nulla. Etiam facilisis ex in felis blandit, non posuere enim maximus. Duis ac volutpat mi. Nulla ullamcorper risus sed commodo rutrum.
170
+
171
+Aenean sed imperdiet dolor. Curabitur pellentesque id erat vel volutpat. Duis finibus pellentesque mi. Mauris non fringilla ex, sit amet commodo est. Fusce pharetra rutrum aliquet. Maecenas feugiat faucibus tortor a imperdiet. Duis ultrices ultricies varius. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam fringilla arcu sit amet arcu malesuada malesuada. Aliquam dictum elit dui, at sagittis ipsum luctus in. Nulla lobortis pulvinar lorem ut tincidunt. Nunc pulvinar orci sit amet elit aliquet, eget blandit velit molestie.
172
+
173
+Donec id nulla ultrices, tincidunt odio eget, sodales massa. Nullam tempus mollis arcu vel ultricies. Cras non neque at neque mollis condimentum nec ac risus. Duis eget massa varius, placerat augue nec, mollis urna. Fusce imperdiet, orci sit amet maximus rhoncus, lorem ligula lacinia nisl, quis congue felis leo a ante. Donec faucibus lectus nec turpis sollicitudin vehicula. Sed purus orci, porta vel commodo ac, lacinia eu lectus.
174
+
175
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed facilisis augue dui, ut luctus urna imperdiet id. Curabitur eleifend molestie pellentesque. Etiam urna justo, laoreet ut feugiat ut, condimentum in libero. Vivamus ultricies magna eget erat cursus ullamcorper. Integer venenatis pellentesque semper. Mauris eu facilisis nulla. Vivamus lacus dui, porttitor non gravida nec, cursus id neque. Nullam maximus luctus est, vitae laoreet velit. Ut tincidunt semper elit, id volutpat eros lacinia non. Nam mauris velit, ullamcorper ut faucibus id, facilisis eu turpis. Donec volutpat posuere dui, eu iaculis lorem commodo ac. Cras porttitor lacus id convallis mattis. Maecenas quis sollicitudin lacus. Cras lobortis nisl quis elit pharetra euismod.
176
+
177
+Curabitur ac nisi sollicitudin, dapibus nisi at, vestibulum libero. Phasellus ultrices malesuada luctus. Ut at justo sit amet odio congue sodales. Donec commodo metus in lacinia facilisis. Proin nec ex odio. Vivamus sit amet nibh ligula. Donec eget ullamcorper enim. Aliquam id rhoncus diam. Aenean et tortor sapien. Quisque porta fringilla augue. Sed non tristique dolor. Sed pharetra, enim non rhoncus maximus, nulla diam eleifend erat, vitae scelerisque odio ex lacinia felis. In cursus ante in porta molestie.
178
+
179
+Nunc lorem ante, sollicitudin quis lectus in, rhoncus iaculis erat. Suspendisse condimentum est eu dolor facilisis dignissim in at dolor. Praesent eget lorem non odio porta mollis. Sed fringilla magna tortor, ac ornare nisi sollicitudin vulputate. Pellentesque nisl nulla, porta eu feugiat vitae, dapibus id turpis. Quisque molestie tortor ac neque fermentum, in commodo risus bibendum. Donec posuere libero ipsum, in fringilla neque pellentesque in.
180
+
181
+Aenean interdum faucibus dignissim. Pellentesque sed odio in metus elementum convallis eget nec nunc. Sed erat diam, tristique eget bibendum eu, molestie nec lectus. Suspendisse congue metus sed tempus placerat. Morbi ac urna at diam accumsan porta. Nam luctus enim tortor, non aliquam nisi rutrum quis. Curabitur ut purus ac quam euismod imperdiet. Praesent in felis vel eros sodales sollicitudin eu eu ex. Nunc nec sem in est consectetur sodales. Nulla posuere odio orci, id viverra neque pretium ac. Quisque tempus erat nec porttitor efficitur. Aenean ut lobortis nisi, sit amet bibendum arcu. Suspendisse potenti. Donec ut nisl nec tellus commodo laoreet at id sapien. Ut semper tempus justo, sollicitudin pulvinar felis eleifend in. In fringilla mi eget orci ullamcorper, a fermentum turpis consectetur.
182
+
183
+Sed sollicitudin luctus nisl at accumsan. Donec auctor dignissim enim id venenatis. Duis lacinia dignissim arcu, sed sodales turpis commodo non. Maecenas nec dolor justo. Nulla id urna id risus pellentesque sollicitudin quis nec leo. Cras viverra a orci sed laoreet. Morbi euismod odio nec consequat sodales. In sit amet interdum lacus, eu rutrum ipsum. Nullam sit amet sollicitudin leo. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque malesuada, elit sed dapibus sollicitudin, augue nibh interdum ante, ac euismod ex risus at risus. Phasellus quis varius arcu. Curabitur ut maximus lacus, eu feugiat quam.
184
+
185
+Vestibulum vel mi efficitur, ornare ante ac, lacinia turpis. Sed facilisis velit vel odio sagittis, eu gravida diam blandit. Morbi iaculis libero urna, eu laoreet urna consectetur nec. In cursus elementum ornare. Nam nec ex tincidunt, ultricies quam vitae, imperdiet turpis. Nulla consectetur elit in luctus aliquam. Ut vel luctus lectus. Curabitur scelerisque vulputate nisi, sit amet condimentum neque lobortis quis. Nunc commodo diam erat, non laoreet purus congue eu. Suspendisse et lorem hendrerit, sodales ipsum porta, porttitor massa. Suspendisse pellentesque ac purus quis aliquet. Nulla at neque ut urna sodales pellentesque. Proin finibus ornare faucibus.
186
+
187
+Ut quis lacus nibh. Vestibulum ornare accumsan nunc, ac interdum quam dictum et. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque sollicitudin nisl nisl, quis mattis sapien pulvinar sed. Cras posuere eget risus eu mattis. Vestibulum quis ligula vitae elit pulvinar placerat sit amet et metus. Vivamus quis dolor dui.
188
+
189
+Nunc sagittis leo quis mattis commodo. Integer non nulla id neque bibendum semper in vel diam. Vivamus vitae felis a lacus facilisis fermentum. Sed malesuada tortor quis nulla vestibulum, posuere tristique velit porta. Donec ut neque pellentesque, aliquam enim nec, vulputate leo. Phasellus augue ipsum, hendrerit ut rhoncus a, scelerisque non dolor. Quisque sed convallis lorem, ut bibendum odio. Donec in tempor nunc. Praesent risus quam, volutpat ac egestas non, imperdiet vel libero. In hac habitasse platea dictumst. Duis metus quam, porttitor in libero id, maximus laoreet velit. Nulla mauris risus, feugiat id tellus vitae, viverra placerat sapien. Aliquam erat volutpat.
190
+
191
+Suspendisse non diam lacus. Curabitur fringilla, mi et dictum blandit, turpis nunc semper felis, in rhoncus lacus sem sed diam. Vivamus a accumsan ligula, convallis varius erat. Nullam libero arcu, consectetur sed velit vestibulum, imperdiet congue sapien. Ut sodales imperdiet diam eu egestas. Nulla mollis tincidunt quam, ac efficitur lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Fusce mollis ornare molestie. Donec ante libero, mattis ac ultricies nec, fringilla eu libero. Etiam tempor ac ligula euismod feugiat. Donec mauris nulla, lobortis eu consectetur eu, faucibus ut velit. Etiam eu elit felis. Maecenas eget velit leo. Sed posuere pulvinar consectetur.
192
+
193
+Cras quis malesuada magna. Suspendisse faucibus rhoncus ultrices. Fusce non imperdiet nulla, at pellentesque nunc. Duis in euismod arcu, at sollicitudin erat. Phasellus a dignissim augue. Nunc tincidunt pharetra magna, porttitor mattis nunc tristique luctus. Etiam sed placerat tellus, nec malesuada diam. Vestibulum in volutpat ligula, sit amet semper leo. Vivamus lacinia consequat augue, at mollis nisi convallis et. Etiam purus justo, aliquam eu quam a, malesuada ornare enim.
194
+
195
+Sed finibus libero nunc, sed malesuada mauris accumsan ut. Mauris iaculis mattis odio non malesuada. Vivamus ultricies tristique lorem, eget laoreet sapien aliquet molestie. Nam nec eros quam. In enim lectus, finibus sed nisl nec, fringilla iaculis velit. Maecenas ut ante lectus. Nam euismod libero a sapien tempor bibendum. Donec non dolor varius, imperdiet urna ut, vehicula nibh. Maecenas consectetur dignissim nulla, sit amet pulvinar tellus consequat ac.
196
+
197
+Nam magna felis, vehicula eget urna vel, varius aliquam mauris. In et leo id ligula pretium venenatis at et nunc. Sed id felis sem. Sed ut efficitur nibh, vitae ultricies odio. Fusce ut maximus orci. Praesent quis elementum sem, quis vestibulum arcu. Quisque lacus ante, scelerisque ac feugiat at, bibendum in urna. Donec quis arcu molestie turpis tincidunt tempus nec eget augue. Nam id orci ante. Donec nunc nunc, egestas et diam sed, laoreet aliquet massa. Curabitur in est vel lectus tincidunt interdum eget sed diam.
198
+
199
+Duis maximus, lectus nec congue sodales, nisl eros laoreet metus, id imperdiet augue ante eleifend sem. Integer mi enim, ornare non feugiat eu, venenatis sed urna. Nunc lacus lorem, varius sed nulla et, feugiat scelerisque lacus. Vivamus quis venenatis orci, vitae congue massa. Interdum et malesuada fames ac ante ipsum primis in faucibus. Praesent commodo metus nec turpis egestas, ut vehicula nisi tristique. Mauris lobortis scelerisque ipsum quis ornare. Nulla malesuada risus at lacus sodales, non cursus nisi sollicitudin. Nam aliquam turpis sit amet euismod varius. Nunc vel quam elit. Phasellus facilisis metus ac eros volutpat, non pharetra libero porttitor. Integer quis fermentum quam, eget aliquam tellus. Pellentesque suscipit ante orci, in sagittis lacus interdum ut. Pellentesque porta posuere commodo. 

+ 28
- 0
lab5/samples/test2.html View File

@@ -0,0 +1,28 @@
1
+<html>
2
+
3
+<title>
4
+Simple HTML file test about Smiley for Fake News assignment
5
+</title>
6
+
7
+<body>
8
+
9
+<h1>A Simple HTML test page for Smiley from Stockholm</h1>
10
+
11
+<p>
12
+  This is a basic HTML Web page.
13
+  It tells a simple story about our yellow friend Floppy,
14
+  who is from Stockholm. Smiley is round, I think.
15
+</p>
16
+<p>
17
+Without your proxy, you should be able to view this page just fine.
18
+</p>
19
+<p>
20
+With your proxy, this page should look a bit different,
21
+with all mentions of Smiley from Stockholm
22
+being changed into something else.
23
+The page should still be formatted properly.
24
+</p>
25
+
26
+</body>
27
+
28
+</html>

+ 36
- 0
lab5/samples/test4.html View File

@@ -0,0 +1,36 @@
1
+<html>
2
+
3
+<title>
4
+HTML page with embedded photos of Smiley for Fake News assignment
5
+</title>
6
+
7
+<body>
8
+
9
+<h1>An HTML file with embedded images of Smiley from Stockholm</h1>
10
+
11
+<p>
12
+  This is a rather large and complicated Web page.
13
+  It tells a simple story about our yellow friend Smiley,
14
+  who is from Stockholm. Smiley is a round, I think.
15
+</p>
16
+<p>
17
+  Here is an image of Smiley, and a photo of Stockholm in the spring:
18
+</p>
19
+<p>
20
+  <img src="./smiley.jpg" width="200" height="200">
21
+  <img src="./Stockholm-spring.jpg" width="400" height="300">
22
+</p>
23
+
24
+<p>
25
+Without your proxy, you should be able to view this page just fine.
26
+</p>
27
+<p>
28
+With your proxy, this page should look a bit different,
29
+with all mentions of Smiley from Stockholm
30
+being changed into something else.
31
+The page should still be formatted properly.
32
+</p>
33
+
34
+</body>
35
+
36
+</html>

+ 55
- 0
lab6/build_and_run.sh View File

@@ -0,0 +1,55 @@
1
+#!/bin/bash
2
+# TDDE18 - Lab 6 - Build script
3
+
4
+red='\e[0;31m'
5
+green='\e[0;32m'
6
+orange='\e[0;33m'
7
+neutral='\e[0;m'
8
+
9
+printout() {
10
+	echo -e "[${green}INFO${neutral}] $@"
11
+}
12
+
13
+printhelp() {
14
+	echo -e "[${orange}HELP${neutral}] $@"
15
+}
16
+
17
+printerr() {
18
+	echo -e "[${red}ERROR${neutral}] $@"
19
+}
20
+
21
+valgrd() {
22
+	echo ""
23
+	valgrind --tool=memcheck --leak-check=yes ./out.o $1 $2 $3 $4 $5
24
+	echo ""
25
+}
26
+
27
+printhelp "Compilation, execution and debugging script for TDDE18 C ++ labs."
28
+
29
+printout "Starting building..."
30
+/usr/bin/time --quiet --output=data.tmp -f "Time elasped: %E (%P cpu)" g++-7 -Wall -Wextra -Wpedantic -std=c++17 test_list.cc -o out.o
31
+
32
+if test $? -eq 0
33
+then
34
+	printout "Build finished."
35
+
36
+	printout `cat data.tmp`
37
+	rm data.tmp
38
+	printout "Running..."
39
+
40
+	echo ""
41
+	./out.o
42
+
43
+	echo "" 
44
+	printout "Done. Cleaning..."
45
+	rm out.o
46
+	printout "Done."
47
+else
48
+	printerr "Build failed."
49
+	printout `cat data.tmp`
50
+	rm data.tmp
51
+	exit 1
52
+fi
53
+
54
+echo ""
55
+exit 0

+ 75
- 0
lab6/list.h View File

@@ -0,0 +1,75 @@
1
+#ifndef _LIST_H_
2
+#define _LIST_H_
3
+
4
+#include <iostream>
5
+#include <string>
6
+
7
+// TDDE18 - Lab 6 - Templates
8
+// Header file
9
+
10
+
11
+template <typename T>
12
+class List
13
+{
14
+public:
15
+  List();
16
+  ~List() { delete first; }
17
+
18
+  void insert(T const& d);
19
+  
20
+  List(List const&);
21
+  List(List&&);
22
+  List& operator=(List const&);
23
+  List& operator=(List&&);
24
+    
25
+private:
26
+
27
+  class Link
28
+  {
29
+  public:
30
+    Link(T const& d, Link* n)
31
+      : data(d), next(n) {}
32
+    ~Link() { delete next; }
33
+    
34
+    friend class List;
35
+
36
+    static Link* clone(Link const*);
37
+    
38
+  private:
39
+    
40
+    T data;
41
+    Link* next;
42
+  };
43
+  
44
+  Link* first;
45
+  
46
+public:
47
+
48
+  using value_type = T;
49
+
50
+  class Iterator
51
+  {
52
+    friend List;
53
+    public:
54
+      Iterator& operator++();
55
+      T& operator*() const;
56
+
57
+      bool operator!=(Iterator const& other) const;
58
+      bool operator==(Iterator const& other) const;
59
+      
60
+    private:
61
+      // Private constructor
62
+      Iterator(Link* ln);
63
+
64
+      Link* l;
65
+  };
66
+
67
+  Iterator begin() const;
68
+  Iterator end() const;
69
+};
70
+
71
+template <typename T>
72
+std::ostream& operator<<(std::ostream& os, const List<T>& lst);
73
+
74
+#include "list.tcc"
75
+#endif

+ 118
- 0
lab6/list.tcc View File

@@ -0,0 +1,118 @@
1
+#include <algorithm>
2
+#include <iostream>
3
+
4
+#include "list.h"
5
+
6
+// TDDE18 - Lab 6 - Templates
7
+
8
+
9
+template <typename T>
10
+void List<T>::insert(T const& d)
11
+{
12
+  first = new Link(d, first);
13
+}
14
+
15
+//-----------------------------------------------------//
16
+// Important copy and assignment stuff
17
+template <typename T>
18
+typename List<T>::Link* 
19
+List<T>::Link::clone(Link const* dolly)
20
+{
21
+  if ( dolly != nullptr )
22
+    return new Link(dolly->data, clone(dolly->next));
23
+  else
24
+    return nullptr;
25
+}
26
+
27
+template <typename T>
28
+List<T>::List() : first(nullptr)
29
+{
30
+  std::clog << "***Default construction" << std::endl;
31
+}
32
+
33
+template <typename T>
34
+List<T>::List(List const& l)
35
+{
36
+  std::clog << "***Copy construction" << std::endl;
37
+  first = Link::clone(l.first);
38
+}
39
+
40
+template <typename T>
41
+List<T>::List(List&& l)
42
+{
43
+  std::clog << "***Move construction" << std::endl;
44
+  first = l.first;
45
+  l.first = nullptr;
46
+}
47
+
48
+template <typename T>
49
+List<T>& List<T>::operator=(List const& rhs)
50
+{
51
+  std::clog << "***Copy assignment" << std::endl;
52
+  if (&rhs != this)
53
+  {
54
+    List copy(rhs);
55
+    std::swap(first, copy.first);
56
+  }
57
+  return *this;
58
+}
59
+
60
+template <typename T>
61
+List<T>& List<T>::operator=(List&& rhs)
62
+{
63
+  std::clog << "***Move assignment" << std::endl;
64
+  if (&rhs != this)
65
+  {
66
+    std::swap(first, rhs.first);
67
+  }
68
+  return *this;
69
+}
70
+
71
+
72
+/////////////////////
73
+/// List Iterator ///
74
+/////////////////////
75
+
76
+template <typename T>
77
+List<T>::Iterator::Iterator(Link* ln): l{ln}
78
+{}
79
+
80
+template <typename T>
81
+typename List<T>::Iterator& List<T>::Iterator::operator++() {
82
+  l = l->next;
83
+  return *this;
84
+}
85
+
86
+template <typename T>
87
+bool List<T>::Iterator::operator!=(Iterator const& other) const {
88
+  return l != other.l;
89
+} 
90
+
91
+template <typename T>
92
+bool List<T>::Iterator::operator==(Iterator const& other) const {
93
+  return l == other.l;
94
+}
95
+
96
+template <typename T>
97
+T& List<T>::Iterator::operator*() const {
98
+  return l->data;
99
+}
100
+
101
+/// Begin and End functions 
102
+template <typename T>
103
+typename List<T>::Iterator List<T>::begin() const {
104
+  return Iterator(first);
105
+}
106
+
107
+template <typename T>
108
+typename List<T>::Iterator List<T>::end() const {
109
+  return Iterator(nullptr);
110
+}
111
+
112
+// OutStream operator
113
+template <typename T>
114
+std::ostream& operator<<(std::ostream& os, const List<T>& lst){
115
+  for (auto i : lst)
116
+    os << i << " ";
117
+  return os;
118
+}

+ 88
- 0
lab6/test_list.cc View File

@@ -0,0 +1,88 @@
1
+#include <iostream>
2
+
3
+#include "list.h"
4
+
5
+using namespace std;
6
+
7
+#define SOLUTION 1 // Change to 1 when completely done
8
+
9
+int main()
10
+{
11
+#if SOLUTION == 0
12
+  
13
+  // Minimal code to use the list
14
+
15
+  // You are recommended to start with your template implementation
16
+  // and convert this code to instantiate it.
17
+  // Move on to the iterator once it compiles.
18
+
19
+  List list;
20
+  decltype(list)::value_type number;
21
+  
22
+  cout << "Enter numbers, finish by Ctrl-D " << endl;  
23
+  while (cin >> number)
24
+  {
25
+    list.insert(number);
26
+  }
27
+  
28
+#else
29
+  // example of using the list with integers
30
+  {
31
+    List<int> list;
32
+    decltype(list)::value_type number;
33
+    
34
+    cout << "Enter numbers, finish by Ctrl-D " << endl;  
35
+    while (cin >> number)
36
+    {
37
+      list.insert(number);
38
+    }
39
+
40
+    for ( decltype(list)::Iterator it{ list.begin() };
41
+          it != list.end(); ++it)
42
+    {
43
+      cout << *it << " ";
44
+    }
45
+    cout << endl;
46
+
47
+    for ( auto i : list )
48
+    {
49
+      cout << i << " ";
50
+    }
51
+    cout << endl;
52
+
53
+    cout << list << endl;
54
+  }
55
+
56
+  cin.clear();
57
+  
58
+  // example of using the list with std::string
59
+  // ( notice the overwhelming similarity to above code? )
60
+  {
61
+    List<std::string> list;
62
+    decltype(list)::value_type word;
63
+    
64
+    cout << "Enter words, finish by Ctrl-D " << endl;  
65
+    while (cin >> word)
66
+    {
67
+      list.insert(word);
68
+    }
69
+
70
+    for ( decltype(list)::Iterator it{ list.begin() };
71
+          it != list.end(); ++it)
72
+    {
73
+      cout << *it << " ";
74
+    }
75
+    cout << endl;
76
+    
77
+    for ( auto w : list )
78
+    {
79
+      cout << w << " ";
80
+    }
81
+    cout << endl;
82
+    
83
+    cout << list << endl;
84
+  }
85
+#endif
86
+  
87
+  return 0;
88
+}

+ 407
- 0
toknow.txt View File

@@ -0,0 +1,407 @@
1
+Commande C++ : 
2
+#include <iostream> // a placer au début 
3
+#include <string> // a placer au début 
4
+#include <fstream> // a placer au début si communication avec fichier texte
5
+#include <iomanip> // a placer au debut si utilisation setw et autre 
6
+#include <vector> // a placer si utilisation storage
7
+using namespace std;  // a placer au début (librairie std)
8
+
9
+//file separation 
10
+Implementation files (.cc) // contains definitions
11
+Header files (.h) // contains declaration (the list of class / functions with variables and fonction)
12
+Executable files // programs the computer run 
13
+Object files (.o) // can be combined to create an executable 
14
+
15
+//in file.h write
16
+#ifndef FILE_H
17
+#define FILE_H
18
+blabla 
19
+#endif
20
+//in test.cc write
21
+#include "file.h"
22
+// in the testing file 
23
+#define CATCH_CONFIG_MAIN 
24
+#include "catch.hpp"
25
+
26
+
27
+//droit d'accès
28
+public // éléments accessibles depuis l'extérieur
29
+private // élément pas accessibles depuis extérieur
30
+protected // élément pas acc depuis extérieur sauf si élément fille (héritage)
31
+
32
+int main() {....; return 0;} // programme de base, on écrit dedans 
33
+cout << "Hello World" << endl; // on écrit sur l'écran et passage a la ligne 
34
+cout << "m'appelle" << flush; // on écrit et on demande a envoyer 
35
+cout << x << endl; // affiche la valeur de la var x 
36
+cin >> x; // input de valeur dans x # le buffer fonctionne bizarre souvient t'en 
37
+cin >> str; // met le premier mot dans str 
38
+getline(cin, str); // met toute la ligne entrée dans str (ligne séparée par \n)
39
+cin.ignore(1000, '\n'); // clean le buffer
40
+cin.clear() // clear all flags raised (fail Stream operaƟon failed, eof device has reached the end, bad irrecoverable stream error, good no errors)
41
+
42
+int x{5}; // variable int 
43
+double y{3.14}; // variable double 
44
+char z{'c'}; // variable char
45
+string str {"hello"}; // variable string 
46
+str.size() // retourne la taille de str
47
+str.front() // retourne la première lettre de str 
48
+int const y{7}; // crée une constante, aucun changement de val possible pour elle 
49
+
50
+x >> y; // met le contenu de x dans y 
51
+
52
+setw(x); // va set le nombre minimum de caractères du prochain cout (si pas suffisant, alors rempli avec espace)
53
+setfill('-'); // remplace l'espace comme caractère vide par le tiret ici 
54
+right; // fout les espaces avant le mot au lieu de après (souvent utilisé avec setw())
55
+
56
+a == b && c != d
57
+a <= b || c > d
58
+
59
+-a // negation
60
+++a // incrémentation prefix (va incrémenter et renvoyer la nouvelle valeur)
61
+a++ // incrémentation postfix (va envoyer la valeur a puis incrémenter)
62
+--a // t'as capté
63
+a-- // t'as capté 
64
+
65
+if(logical statement){}
66
+else if (logical statement){}
67
+else {}
68
+while(statement){} // boucle while 
69
+do{}while(logical statement) // boucle do while (au moins une fois dedans)
70
+for(logical statement){} // boucle for tu coco
71
+
72
+static_cast<double>(a) // fait passer a de int a double 
73
+static_cast<another_type>(var) // change de type of var
74
+dynamic_castt<Cuboid*>(ptr) // change de type si la variable est du type Cuboid ici (variable du type voulu)
75
+
76
+
77
+ifstream txt{"text.txt"}; // met le contenu de text.txt dans var txt 
78
+while(txt >> str) {} // lecture de tout le fichier, mot par mot
79
+while(txt >> str) {} // lecture de tout le fichier, ligne par ligne 
80
+
81
+
82
+int x{1}; // global var
83
+{
84
+cout << x << endl ; //will print 1
85
+int x{2}; // local var 
86
+cout << x << endl ; // will print 2 
87
+}
88
+
89
+returnt_type function_name(parameters); // declaration fonction début code (avant main)
90
+return_type function_name(parameters) // fonction type
91
+{ // statements
92
+return result;}
93
+double add(double a, double b) // exemple fonction
94
+{ return a+b;}
95
+void foo() // fonction ne retournant rien (void)
96
+{cout<<"fonction"<<enld;}
97
+
98
+struct Person // création struct, pour contenir plusieurs var 
99
+{string name{};
100
+int age{};};
101
+Person p; // déclaration d'une var struct 
102
+p.name = "José"; // pour acceder aux infos du struct 
103
+Person p1{"josé";26} // déclaration directe
104
+
105
+string word{"hello"};
106
+string& greeting{word}; // créé un alias, c'est a dire que si on modifie la valeur de greeting, word change aussi
107
+string name{"Jean"};
108
+string const& surname{name}; // créé un alias mais qu'on ne peut pas modifier directement, on peut modifier name par contre
109
+
110
+// modifie la valeur de my_name grâce à l'alias 
111
+void read_name(string& name) 
112
+{cout << "Your name: "; cin >> name;}
113
+int main()
114
+{string my_name; read_name(my_name); cout << my_name << endl;}
115
+
116
+// some string are expensive to copy, so create a const& could be a good choice 
117
+void print(string const& message)
118
+{cout << message << endl;}
119
+int main()
120
+{string my_msg{"Long message!"}; print(my_msg);}
121
+
122
+// deux fonctions peuvent avoir le même nom du moment où elles se différencient qq part 
123
+int add(int a, int b)
124
+{return a + b;}
125
+double add(double a,double b)
126
+{return a + b;}
127
+
128
+void ignore(int n = 1024, char stop = '\n') // paramètre par défaut, pas obligé de les préciser
129
+{cin.ignore(n, stop);}
130
+
131
+bool operator<(Person const& p1, Person const& p2)
132
+{return p1.first_name < p2.first_name;}
133
+int main()
134
+{Person p1{"Christoffer", "Holm"};
135
+Person p2{"Fredrik", "Adolfsson"};
136
+if (p1 < p2) // ca marche car look première ligne 
137
+{cout << p1 << endl;}}
138
+
139
+ostream& operator<<(ostream& os, Person const& p) 
140
+{os << p.first_name << " " << p.last_name;
141
+return os;}
142
+Person p1{"Christoffer Holm"}; // ça marche car première ligne 
143
+cout << p1 << endl;
144
+
145
+istream& operator>>(istream& is, Person& p)
146
+{is >> p.first_name >> p.last_name;
147
+return is;}
148
+Person p;
149
+int x;
150
+cin >> p >> x;
151
+
152
+#include <sstream> // module to facilitate the testing phase 
153
+istringstream iss{"Yes"}; // simulate cin (for test, to don't have to input each time)
154
+ostringstream oss{}; // work like cout but in the terminal 
155
+oss.str() // retrieve the written output 
156
+
157
+Catch.hpp // module to test the code 
158
+TEST_CASE // to create a test 
159
+CHECK // check if the statement inside is true 
160
+CHECK_FALSE // check if the statement inside is false 
161
+REQUIRE // work like check but stops if this one fails 
162
+REQUIRE_THROWS // an execption should be "levé"
163
+REQUIRE_NOTHROW // no exception needed
164
+
165
+
166
+
167
+//class = struct but with fonction like operator in it 
168
+class Date; // class declaration 
169
+class Date {} // class definition
170
+
171
+//this = hidden parameter, to access data, this
172
+data
173
+class Date {void set_year(int year) {this->year = year;}};
174
+
175
+//private variables, to put at the end of the class 
176
+private: int day; int month; int year;
177
+
178
+//public variables, to put at the begining of the class 
179
+public: Date(int d, int m, int y): day{d}, month{m}, year{y}
180
+
181
+Date(int d, int m, int y) //constructeur definition (after "public" in the class)
182
+Date:Date(int d, int m, int y) //constructor definition (outside the class)
183
+Personnage::Personnage() : m_vie(100), m_mana(100), m_nomArme("Épée rouillée"), m_degatsArme(10){} // constructeur
184
+
185
+// const member functions 
186
+
187
+// inner class (class dans d'autre class)
188
+outer::inner::fun() // accède a la fonction fun() de la class inner dans la class outer
189
+outer::inner i{} // créé une variable i de class inner dans outer 
190
+
191
+//friend create something outside the class but that have access to the private part 
192
+
193
+
194
+
195
+//pointers 
196
+int x{5}; int* ptr{&x}; // creation of the ptr variable et typé (int) (pointers)
197
+int y{7}; ptr = &y; // creation of the ptr variable (pointers too)
198
+cout << ptr ; // affiche l'emplacement de ce que le pointeur pointe 
199
+cout << *ptr ;  // affiche la valeur de ce que le pointeur pointe 
200
+nullptr // key word to say the pointer pointe nothing 
201
+int* ptr{new int{5}}; // create a var with no name but an adress given by the pointer 
202
+delete ptr; // delete the case the pointer points on 
203
+
204
+// node 
205
+struct Node {int value; Node* next;}; // créé un struct avec une valeur et un pointeur qui va faire la prochaine case 
206
+Node n2 {2, nullptr}; Node n1 {8, &n2}; // création d'un exemple de 2 cases avec le 1 allant vers 2 
207
+cout << (*n1).value; // affiche la valeur du noeud n1
208
+cout << n1->value ; // affiche la valeur du noeud n1 aussi (pareil que préc)
209
+
210
+// insert 
211
+class List
212
+{
213
+public:
214
+void remove();
215
+void insert(int value)
216
+{
217
+Node* tmp{new Node{value}};
218
+tmp->next = first;
219
+first = tmp;
220
+}
221
+private:
222
+Node* first{};
223
+};
224
+
225
+
226
+// remove 
227
+class List {
228
+public
229
+:
230
+void remove() {
231
+Node* tmp = first;
232
+first = first->next;
233
+delete tmp;
234
+}
235
+void insert(int value);
236
+private
237
+:
238
+Node* first{};
239
+};
240
+
241
+// special member functions  
242
+
243
+
244
+// Objet temporaire 
245
+objet&&
246
+ 
247
+
248
+//return operator function 
249
+return this*
250
+
251
+
252
+// sequential storage
253
+std::vector<int> v {5, 3, 1, 2}; // creation tableau dynamique
254
+v.at(1) = 4; // changement de valeur indice 1 
255
+v.push_back(3); // ajout de la valeur 3 à la fin 
256
+v.front() = 2; // changement de la premiere valeur 
257
+v.back() = 6; // changement de la dernière valeur 
258
+v.pop_back(); // suppression de la dernière valeur 
259
+v[indice] // acceder a une valeur 
260
+v.at(indice) // check si element existe 
261
+v.size(); // how many elements 
262
+
263
+// loop through storage (3 ways to do it)
264
+vector<string> words {...};
265
+for (int i{0}; i < words.size(); ++i){...} // passe par les indices
266
+for (string word : words){} // passe par les valeurs en les copiant dans words
267
+for (string const& word : words){} // passe par les valeurs sans les copier, on peut donc les modifier 
268
+
269
+// Inheritance
270
+class Base {}; // création classe mère 
271
+class Derived : public Base{}; // création classe fille 
272
+
273
+// polymorphisme 
274
+class Moto : public Vehicule  //Une Moto EST UN Vehicule
275
+{   public:
276
+    Moto( int prix, double vitesseMax) // constructeur juste pour cet objet 
277
+    virtual void affiche() const; // on rajoute virtual pour que ca choissise la bonne version de la méthode
278
+    virtual ~Moto() = default;   // destructeur toujours virtuel si use polymorphisme 
279
+    virtual double current() override; // sert à réécrire par dessus si moto est fonction fille 
280
+    using Vehicule::variable; // on réimporte la variable qui était noté dans la classe mère juste pour rappeler qu'elle est là 
281
+    private:
282
+    double m_vitesse;  //La vitesse maximale de la moto
283
+};
284
+
285
+virtual int nbrRoues() const = 0;  //méthode virtuelle pure (i.e. la classe mère ne renvoi rien mais elle dit que les classes filles ont cette fonction qui renvoie qqch) 
286
+
287
+// exception 
288
+int main(){
289
+try{} // on met le code la dedans 
290
+catch (std::exception& e) // on attrape l'exception 
291
+{cerr << e.what();}}
292
+
293
+throw std::exception{""}; // balanche une exception 
294
+
295
+
296
+//verif type 
297
+isalpha() // vérifie si caractere dedans est une lettre
298
+isdigit() // vérifie si chiffre
299
+islower() // vérifie si minuscule 
300
+isupper() // vérifie si majuscule 
301
+isspace() // vérifie si espace 
302
+
303
+tolower() // transforme en minuscule 
304
+toupper() // transforme en majuscule
305
+
306
+
307
+// Containers Sequence : verctor, deque, list, stack, queue, priority_queue
308
+// Containers associative : set, multiset, map, multimap
309
+
310
+// commandes sur container
311
+container.size() // renvoie la size 
312
+container.empty() // renvoie true ou false si container vide ou non 
313
+container.clear() // vide tout 
314
+a.swap(b) // échange les contenus des containers
315
+
316
+
317
+
318
+// Sequence container
319
+// likewise for list, forward_list and deque
320
+std::vector<int> v {1, 2, 3};
321
+// we have to specify a size for array
322
+std::array<int, 3> a {1, 2, 3};
323
+
324
+//vector (sequence)
325
+a.push_back() // ajout élément à la fin 
326
+a.pop_back() // delete dernier élément 
327
+a.front() // renvoie premier élément 
328
+a.back() // renvoie dernier élément 
329
+a.assign() // rempli tout les éléments avec la même valeur 
330
+
331
+// array (comme vector mais taille fixe)
332
+// list 
333
+//forward list
334
+
335
+//deque
336
+a.push_back() // ajout élément à la fin 
337
+a.pop_back() // delete dernier élément 
338
+a.front() // renvoie premier élément 
339
+a.back() // renvoie dernier élément 
340
+a.assign() // rempli tout les éléments avec la même valeur 
341
+a.push_front() // rajoute au début 
342
+a.pop_front() // enlève premier élément 
343
+
344
+
345
+//stack (LIFO)
346
+a.push() // ajouter element 
347
+a.top() // consulter dernier element 
348
+a.pop() // supprimer dernier élément 
349
+
350
+// queue (FIFO) 
351
+a.push() // ajouter element 
352
+a.front() // consulter dernier element 
353
+a.pop() // supprimer dernier élément 
354
+
355
+
356
+
357
+//Associative containers 
358
+
359
+//map : associates value with a key 
360
+map<string, int> a; // declaration 
361
+key have to be comparable with operator <
362
+
363
+//set : like map but only store keys, value unique and sorted 
364
+
365
+// multiset / multimap : like set and map but keys doesn't have to be unique 
366
+
367
+//unordered_(multi)map / unordered_(multi)set : keys not sorted and doesn't have to be comparable anymore
368
+
369
+
370
+
371
+// Iterators 
372
+
373
+// this works ! 
374
+int main()
375
+{set<int> v {1, 2, 3};
376
+for (int e : v)
377
+{cout << e << endl; // works!}}
378
+
379
+// Better 
380
+using iterator = std::vector<int>::iterator;
381
+for (iterator it{v.begin()}; it != v.end(); ++it)
382
+{cout << *it << endl;}
383
+
384
+tab.erase(tab.begin()); // efface le premier element 
385
+tab.insert(tab.begin()); // insert un élément juste après 
386
+
387
+//Iterators categories 
388
+Input : Peut préparer des valeurs déjà existantes dans un conteneur
389
+Outpout : peut ajouter des nouvelles valeurs dans un conteneur 
390
+Forward : can read / overwrite existing value + can step forward in the container + is an input iterator 
391
+bidirectional : can go forward and backward 
392
+Random access : can access n'importe quel élément grâce a l'opérateur + & aussi bidirectional iterator 
393
+
394
+//lambda functions 
395
+[](int n) { return n + 2; } // function that return the number + 2 
396
+
397
+int x {2};
398
+std::vector<int> v {1, 2, 3};
399
+std::transform(v.begin(), v.end(), v.begin(), [x](int n) { return n + x; });
400
+
401
+
402
+
403
+// fonction template (toujours dans fichier .h)
404
+template<typename T> // declaration type générique
405
+T maximum(const T& a,const T& b){blablabla} // création fonction maximum template
406
+maximum<int>(cave,dernierEtage) // appel de ma fonction avec des int 
407
+auto add(T a, U b) // decla d'une fonction avec 2 template et auto en return type

Loading…
Cancel
Save