c++

CAsyncSocket::Close Crashes

Hey, im doing some client/server stuff in a windows service. Pretty much new to this stuff. The problem I'm encountering is that when I try to stop the service through Service Manager, it crashes. I added some MessageBoxes code, to trace where they are crashing and I found that when it closes the listener socket it crashes!!! I tried t...

Library for password protecting PDF from copying, editing and printing (not viewing)

I'm looking for a good and lightweight library (preferably C or C++) to password protect PDF files from copying, editing and printing. Preferably free or cheap commercial variant, since i want library only to use this functionality. Thanks in advance. ...

How to retrieve cookies for a specific site and path in winhttp

I would like to retrieve the cookies stored in the winhttp session cache based upon a specific host and path that I am about to send a request to. I want to retrieve those cookies before I send the request, so I don't have the request handle yet, all I have is the session and connection handles and of course the path and host I'm going t...

How to design a state machine in face of non-blocking I/O?

I'm using Qt framework which has by default non-blocking I/O to develop an application navigating through several web pages (online stores) and carrying out different actions on these pages. I'm "mapping" specific web page to a state machine which I use to navigate through this page. This state machine has these transitions; Connect, Log...

Memory snapshot of a huge C/C++ project (Windows/Unix)

I'm trying to take a snapshot of the memory used by a large application running on both Unix / Windows. My ultimate aim would be to have a kind of chart breaking down the memory used by which area of code. The program is split into about 30 different projects most of which are either static libraries or dynamic dlls. Some of these are w...

boost::lambda::if_then for copy_if

Hello experts I have been trying to emulate a copy_if by the following codes but my compiler (g++-4.0) just keeps complaining. What's technically wrong? Thanks for your help! template <class STL> // a std container of class A, but I don't know if it's a list or vector or deque void export_(STL& Alist) { //a member function for_each(Al...

#define _AFX_NO_DEBUG_CRT causes a stream of compilation errors

I have an MFC C++ project compiler under Visual Studio 2008. I'm adding a _AFX_NO_DEBUG_CRT in my stdafx.h before the #include to avoid all the debug new and deletes that MFC provides (I wish to provide my own for better cross platform compatibility). However when I do this I get a stream of errors such as the following: >c:\progra...

What is a callback? What is it for and how is it implemented in for example C++.

Hi, I realise this is a newbie question, but as I'm trying to learn C++ I'm stumpling upon this expression "callback" frequently. I've googled it and checked wikipedia, but without finding a good explination. I am familiar with some Java and C#, but how unlikely it sounds, I have never really understood what a callback means. If someon...

Reason why not to have a DELETE macro for c++

Hi! Are there any good reasons (except "macros are evil", maybe) NOT to use the following macros ? #define DELETE( ptr ) \ if (ptr != NULL) \ { \ delete ptr; \ ptr = NULL; \ } #define DELETE_TABLE( ptr ) \ if (ptr != NULL) \ { \ delete[] ptr; ...

Comparing two vectors of maps

I've got two ways of fetching a bunch of data. The data is stored in a sorted vector<map<string, int> >. I want to identify whether there are inconsistencies between the two vectors. What I'm currently doing (pseudo-code): for i in 0... min(length(vector1), length(vector2)): for (k, v) in vector1[i]: if v != vector2[i][k]:...

What could be a reason to not use bracket classes in C++?

It's often needed to accomplish the following task: change the state of something, do action, then change the state back to original. For example, in Win32 GDI it's needed to change background color, then do some drawing, then change the color back. It can be either done directly: COLORREF oldColor = SetBkColor( deviceContext, newColor...

What are preprocessor macros good for?

After reading another question about the use of macros, I wondered: What are they good for? One thing I don't see replaced by any other language construct very soon is in diminishing the number of related words you need to type in the following: void log_type( const bool value ) { std::cout << "bool: " << value; } void log_type( const ...

Problems with Symbian descriptor assignment

Hi, Once again I am struggeling with Symbians Descriptors... char fileName[128] = "somethingsomething"; Next I have then en TEntry object which has a member iName. To this iName I would like to assign my fileName. I tried to do it as follows: TEntry anEntry; anEntry.iName.Copy((TText8* )rEntity->fileName); - no instance of overl...

What is activation record in the context of C and C++?

What does it mean and how important to know about it for a C/C++ programmers? Is it the same across the platforms, at least conceptually? I understand it as a block of allocated memory used to store local variable by a function... I want to know more ...

How to implement a stacktrace in C++ (from throwing to catch site)?

Is the trickery way that we can show the entire stack trace (function+line) for an exception, much like in Java and C#, in C++? Can we do something with macros to accomplish that for windows and linux-like platforms? thanks ...

Get file info into variables?

What is the best way to get this info from a file for each line? the text file looks like this 1 E 1 P 1 C 2 E a 5 E P C So i need to get the info from line 1(1 E) put 1 into a variable and then E into another. The same for the rest of the lines, but some have a different number of elements which I dont understand how to do. ...

C++ plus VS plus WORKFLOW ?

Hello, I have seen there is Workflow Foundation for .NET. Is there some kind of a tool for creating work flow with C++ on VS? Or there maybe there are similar tools which helps to architect application business processes? Thanks in advance ! :) ...

Python non-trivial C++ Extension

I have fairly large C++ library with several sub-libraries that support it, and I need to turn the whole thing into a python extension. I'm using distutils because it needs to be cross-platform, but if there's a better tool I'm open to suggestions. Is there a way to make distutils first compile the sub-libraries, and link them in when ...

C++0x noise, bloat and portability

At first when I saw the upcoming C++0x standard I was delighted, and not that I'm pessimistic, but when thinking of it now I feel somewhat less hopeful. Mainly because of three reasons: a lot of boost bloat (which must cause hopeless compile times?), the syntax seems lengthy (not as Pythonic as I initially might have hoped), and I'm v...

Most useful shortcut in Eclipse CDT

I would like to make a cheat sheet presenting the most useful (and time saving) shortcut for Eclipse CDT (C++). Can you share what are the most useful shortcuts that you use in CDT? Please, post only general shortcuts (available when doing C++) or CDT specific. ...