Tag: Boost

  • Using boost::property_tree

    Some short examples of how to use the Boost property tree in order to read from and write to XML files.

    Reading XML into a Boost property tree

    Here’s how to read an example XML into the Boost property tree and traverse each of the the “item” sections within this XML, given that items may contain differing subsections:

    For this XML example file “test1.xml” I use the following example XML taken from the Microsoft MSDN page:
    (more…)

  • Getting started with the Boost libraries in Ubuntu Linux

    1. Install the Boost libraries from the command line

    First try the following

    $ sudo apt-get install libboost*

    You may get an error message similar to the following, like I did:
    (more…)

  • A First Stab at boost::bind

    Boost::bind is “able to bind any argument to a specific value or route input arguments into arbitrary positions.” It’s a means of converting a function into an object that can be copied around and called at a later point, deferred callbacks for example. (more…)

  • Avoiding Memory Leaks using Boost Libraries

    Using boost::scoped_array

    When we want to dynamically allocate an array of objects for some purpose, the C++ programming language offers us the new and delete operators that are intended to replace the traditional malloc() and free() subroutines that are part of the standard library : (more…)

  • Getting Started with Boost Threads in Visual Studio

    Introduction

    This post aims to be an accessible introduction to getting set up with the Boost threads in Visual Studio environments for the first time.  Like with many technical subjects, there is a great deal of information out on the internet, that tells you a lot without actually showing you anything! (more…)

  • Some neat examples of C++ String Formatting

    Some neat string formatting

    A pretty neat snippet found on stackoverflow some time ago (kudos David Rodriguez), that is worth repeating. Some time ago, a ‘moderator’ at StackOverflow removed this thread “for reasons of moderation”. Fair enough, but the result is that code that many would find pretty darn useful is no longer searchable on that site. How very constructive. Here is a snapshot of that particular StackOverflow page as preserved by the WayBack Machine:

    http://web.archive.org/web/20090420233428/http://stackoverflow.com/questions/469696/what-is-your-most-useful-c-c-snippet/470999

    I’m gonna start using this. Essentially it is a bit of in-house stream formatting. This class make_string produces an instance of an object derived from ostream, which has an implicit conversion to a std::string: (more…)

  • Using Smart Pointers to Avoid Memory Leaks

    Using boost::scoped_array

    When we want to dynamically allocate an array of objects for some purpose, the C++ programming language offers us the new and delete operators that are intended to replace the traditional malloc() and free() subroutines that are part of the standard library :
    (more…)

  • How to use the Boost Libraries in Visual Studio

    In this guide we will use boost::format, a Boost library requiring no separate compilation. If you do not already have Boost installed, the first task is to download and extract the Boost zip file to a destination of your choice. Official releases of Boost may be obtained from here:

    http://www.boost.org/users/download/.

    Download and extract the zip file to your destination of choice:

    boost1
    (more…)