Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Boost C++ Application Development  Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Boost C++ Application Development  Cookbook

Boost C++ Application Development Cookbook

By : Anton Polukhin Alekseevic
4.2 (5)
close
close
Boost C++ Application Development  Cookbook

Boost C++ Application Development Cookbook

4.2 (5)
By: Anton Polukhin Alekseevic

Overview of this book

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, Android operating systems. From manipulating images to graphs, directories, timers, files, networking – everyone will find an interesting topic. Be sure that knowledge from this book won’t get outdated, as more and more Boost libraries become part of the C++ Standard.
Table of Contents (19 chapters)
close
close
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
chevron up

Preface

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.

What this book covers

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.

What you need for this book

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.

Who this book is for

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.

Sections

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:

Getting ready

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.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions 

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.

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

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.

Customer support

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.

Downloading the example code 

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:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

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..

Errata

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

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.

Questions

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.

Limited Time Offer

$10p/m for 3 months

Get online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech and supported with AI assistants
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon

Create a Note

Modal Close icon
You need to login to use this feature.

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note