-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Boost C++ Application Development Cookbook
By :

If you want to take advantage of the real power of Boost and C++ and avoid the confusion about which library to use in which situation, then this book is for you. Beginning with the basics of Boost C++, you will move on to learn how the Boost libraries simplify application development. You will learn to convert data, such as string to numbers, numbers to string, numbers to numbers, and more. Managing resources will become a piece of cake. You'll see what kind of work can be done at compile time and what Boost containers can do. You will learn everything for the development of high-quality, fast, and portable applications. Write a program once, and then you can use it on Linux, Windows, macOS, and Android operating systems. From manipulating images to graphs, directories, timers, files, and networking, everyone will find an interesting topic. Note that the knowledge from this book won't get outdated, as more and more Boost libraries become part of the C++ Standard.
Chapter 1, Starting to Write Your Application, tells you about libraries for everyday use. We'll see how to get configuration options from different sources and what can be cooked up using some of the data types introduced by Boost library authors.
Chapter 2, Managing Resources, deals with data types, introduced by the Boost libraries, mostly focusing on working with pointers. We'll see how to easily manage resources, and how to use a data type capable of storing any functional objects, functions, and lambda expressions. After reading this chapter, your code will become more reliable, and memory leaks will become history.
Chapter 3, Converting and Casting, describes how to convert strings, numbers, and user-defined types to each other, how to safely cast polymorphic types, and how to write small and large parsers right inside the C++ source files. Multiple ways of converting data for everyday use and for rare cases are covered.
Chapter 4, Compile-Time Tricks, describes some basic examples of Boost libraries can be used in compile-time checking for tuning algorithms, and in other metaprogramming tasks. Understanding Boost sources and other Boost-like libraries is impossible without it.
Chapter 5, Multithreading, focuses on the basics of multithreaded programming and all of the stuff connected with them.
Chapter 6, Manipulating Tasks, shows calling the functional object a task. The main idea of this chapter is that we can split all the processing, computations, and interactions into functors (tasks) and process each of those tasks almost independently. Moreover, we may not block on some slow operations (such as receiving data from a socket or waiting for a time-out), but instead provide a callback task and continue working with other tasks. Once the OS finishes the slow operation, our callback will be executed.
Chapter 7, Manipulating Strings, shows different aspects of changing, searching, and representing strings. We'll see how some common string-related tasks can be easily done using the Boost libraries. It addresses very common string manipulation tasks.
Chapter 8, Metaprogramming, presents some cool and hard-to-understand metaprogramming methods. In this chapter, we'll go deeper and see how multiple types can be packed into a single tuple-like type. We'll make functions to manipulate collections of types, we'll see how types of compile-time collections can be changed, and how compile-time tricks can be mixed with runtime.
Chapter 9, Containers, is about boost containers and the things directly connected with them. This chapter provides information about the Boost classes that can be used in everyday programming, which will make your code much faster and the development of new applications easier.
Chapter 10, Gathering Platform and Compiler Information, describes different helper macros used to detect compiler, platform, and Boost features--macros that are widely used across boost libraries and that are essential for writing portable code that is able to work with any compiler flags.
Chapter 11, Working with the System, provides a closer look at the filesystem and how to create and delete files. We'll see how data can be passed between different system processes, how to read files at the maximum speed, and how to perform other tricks.
Chapter 12, Scratching the Tip of the Iceberg, is devoted to some big libraries and to giving you some basics to start with.
You need a modern C++ compiler, Boost libraries (any version will be OK, 1.65 or a more recent version is recommended), and QtCreator/qmake, or just navigate to http://apolukhin.GitHub.io/Boost-Cookbook/ to run and experiment with examples online.
This book is for developers looking to improve their knowledge of Boost and who would like to simplify their application development processes. Prior C++ knowledge and basic knowledge of the standard library is assumed.
In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How it works..., There's more..., and See also). To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"Remember that this library is not only a header, so your program has to link against the libboost_program_options
library".
A block of code is set as follows:
#include <boost/program_options.hpp> #include <iostream> namespace opt = boost::program_options; int main(int argc, char *argv[]) {
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
#include <boost/program_options.hpp>
#include <iostream>
namespace opt = boost::program_options;
int main(int argc, char *argv[])
Any command-line input or output is written as follows:
$ ./our_program.exe --apples=10 --oranges=20
Fruits count: 30
New terms and important words are shown in bold.
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected]
, and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can download the code files by following these steps:
SUPPORT
tab at the top.Code Downloads & Errata
.Search
box.Download
.Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://GitHub.com/PacktPublishing/Boost-Cpp-Application-Development-Cookbook-Second-Edition. We also have other code bundles from our rich catalogue of books and videos available at https://github.com/PacktPublishing/. Check them out!
The source code files of the examples presented in this cookbook are also hosted in the author's GitHub repository. You can visit the author's repository at https://GitHub.com/apolukhin/Boost-Cookbook to obtain the latest version of the code..
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata
section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata
section.
Piracy of copyrighted material on the internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at [email protected]
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected]
, and we will do our best to address the problem.
Change the font size
Change margin width
Change background colour