c++

Best documentation for Boost:asio ?

The documentation available on the boost website is... limited. From what I've been able to read, the general consensus is that it is simply difficult to find good documentation on the boost::asio library. Is this really the case? If so, why? Notes: I have already found the (non-boost) Asio website - and the documentation looks to ...

How do I sort a CArray of a user defined type?

Is there a built-in way to sort a CArray in C++? ...

MFC Panel and window handle

Is there something like a panel that I can use in a MFC application. This is to overlay the default window in MFC (a dialog application). Then to paint the panel black and paint some random stuff on top of it. Something like a view port. is there a better option than this to achieve the same effect ? ...

Why does OS X define 'nil'

At least the libsigc++2 project is hit by OS X headers defining nil on the preprocessor level, outside of namespaces etc. At least 10.5.5 and XCode 3.1 have this. Note that it is in effect not only in Objective-C sources but C++ as well. Short question: why? http://ardour.sourcearchive.com/documentation/2.5/functor__trait_8h-source.htm...

YAML serialization library for C++?

YAML seems like a great format for configuration files & data binding persistent objects in human-readable form... Is there a C++ library that handles YAML? Does Boost::Serialization have plans for a YAML option? EDIT: I would prefer an OO library. ...

Unit testing Visitor pattern architecture

I've introduced visitors as one of core architecture ideas in one of my apps. I have several visitors that operate on a same stuff. Now, how should I test it? Some tests I'm thinking of are a bit larger then a unit test should be (integration test? whatever) but I still wanna do it. How would you test code like the C++ sample from wiki ...

Monitoring a folder for new files in Windows

What is the best way to go about monitoring a folder to see when an image file has been added to it? Files are added approximately once a minute and the naming goes like this... image0001.jpg, image0002.jpg, image0003.jpg etc. I need to know when a file has been written to the folder so that my app can access and use it. ...

How do I create a generic std::vector destructor?

Having a vector containing pointers to objects then using the clear function doesn't call the destructors for the objects in the vector. I made a function to do this manually but I don't know how to make this a generic function for any kind of objects that might be in the vector. void buttonVectorCleanup(vector<Button *> dVector){ B...

Howto initialise char array style string in constructor

I have a class which I'm serialising to send over a unix socket and it has to have a string which I've stored as a char array. Can I initialise it in the constructor differently to how I've done it here? typedef struct SerialFunctionStatus_t { SerialFunctionStatus_t() : serial_rx_count(0), serial_tx_count(0), socket_rx_cou...

C++ Binary Search Tree Recursive search function

template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x); } template <class T> bool BST<T>::search(struct Node<T>*& root, const T& x) { if (root == NULL) return false; else { if (root->data == x) return true; else if(root->data < x) search(root->left, x); ...

Which variables should I typecast when doing math operations in C/C++?

For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this: int a = 2, b = 3; float c = (float)a / (float)b; If I do not cast a and b to floats, it'll do integer division and return an int. Similarly, if I want to multiply a signed 8-bit number with an unsigned 8-bit number, I will ...

Examples of good gotos in C or C++

In this thread, we look at examples of good uses of goto in C or C++. It's inspired by an answer which people voted up because they thought I was joking. Summary (label changed from original to make intent even clearer): infinite_loop: // code goes here goto infinite_loop; Why it's better than the alternatives: It's specific...

Binary Search Tree Deletion (Inorder Pred method) C++

Ok so I thought it was fixed, but I'm getting totally inconsistent results. I rewrote it kind of from scratch to start fresh and here are my results. I get no errors, no crashing, it just doesn't remove them. It just totally messes up the tree and gives me a ton more leaves, and mixes everything up. Not sure where else to go template...

C++/CLI Reference Variable

void f(cli::array<PointF> ^points){ PointF& a = points[0]; // and so on... } Compile error at line 2. .\ndPanel.cpp(52) : error C2440: 'initializing' : cannot convert from 'System::Drawing::PointF' to 'System::Drawing::PointF &' An object from the gc heap (element of a managed array) cannot be converted to a native re...

What's the best C++ JSON parser?

I've seen the C++ JSON links on www.json.org but would like some feedback on which parser people prefer - for reliability, speed and ease of use. Thanks, Sam ...

Basic sample of a scriptable plugin for FireFox in C++ with VS2005/8

My experience to write a plugin for FireFox is below zero. Is someone out there who could point me to sample code on how to get this accomplished in C++ with VS2005/8? What I need to do with JavaScript in the hosting html page is something like this: var obj = document.getElementById("MyFFPlugin"); var value = obj.CalculateValue; //...

How are Windows VK_ constants declared?

For example VK_LEFT, VK_DELETE, VK_ESCAPE, VK_RETURN, etc. How and where are they declared? Are they constants, #defines, or something else? Where do they come from? If possible, please provide a file name/path where they are declared. Or some other info as specific as possible. ...

c++ dynamic_cast error handling

Is there any good practice related to dynamic_cast error handling (except not using it when you don't have to)? I'm wondering how should I go about NULL and bad_cast it can throw. Should I check for both? And if I catch bad_cast or detect NULL I probably can't recover anyway... For now, I'm using assert to check if dynamic_cast returned ...

c++ class friend

Hi, I'm trying to compile such code: #include <iostream> using namespace std; class CPosition { private: int itsX,itsY; public: void Show(); void Set(int,int); }; void CPosition::Set(int a, int b) { itsX=a; itsY=b; } void CPosition::Show() { cout << "x:" << itsX << " y:" << itsY << endl; } class CCube { fri...

Disable sleep mode in Windows Mobile 6

Hi, Does anyone know how could I programatically disable/enable sleep mode on Windows Mobile? Thanks! ...