c++

Size of data obtained from SQL query via ODBC API

Hi, does anybody know how I can get the number of the elements (rows*cols) returned after I do an SQL query? If that can't be done, then is there something that's going to be relatively representative of the size of data I get back? I'm trying to make a status bar that indicates how much of the returned data I have processed so I want t...

copy hdc contents to bitmap

How could you copy the contents of an HDC to a bitmap? ...

Stuck on a Iterator Implementation of a Trie

Hello everyone, I have to implement a homemade Trie and I'm stuck on the Iterator part. I can't seem to figure out the increment method for the trie. I hope someone can help me clear things out. Here's the code for the Iterator: template <typename T> class Trie<T>::IteratorPrefixe{ friend class Trie<T>; public: IteratorPrefixe() ...

An algorithm to get the next weekday set in a bitmask

Hello all, I've got this small question - given a bitmask of weekdays (e.g., Sunday = 0x01, Monday = 0x02, Tuesday = 0x04, etc...) and today's day (in a form of Sunday = 1, Monday = 2, Tuesday = 3, etc...) - what's the most elegant way to find out the next day from today, that's set in the bitmask? By elegant I mean, is there a way to d...

Plugin API design

So I have an application that is based heavily on the QT API which using the QPlugin system. It's fairly simple to use, you define a class which inherit from an Interface and when the plugin is loaded you get an instance of that class. In the end it'll boil down to a dlopen/dlsym or LoadLibrary/GetProcAddress, whatever is appropriate for...

C++ Huffman Code Header

Hello, basically, I've got my Huffman table as std::map<std::string, char> ciMap; Where string is the bit pattern and char is the value represented by said pattern. The problem is how do I store that as a header of my compressed file so I can build again the same map when I want to decode it? Trying to store it as binary: size_t m...

How can I discover/control the level of internal buffering in a C++ fstream?

Say I do this (a contrived example): #include <iostream> #include <fstream> using namespace std; int main(int argc, char* argv[]) { ifstream ifs(argv[1]); char ch; while(ifs.read(&ch, 1)) { cout << ch; } } I assume(hope) that the iostream library does some internal buffering here and doesn't turn this into g...

Where is the Don't Fragment Bit of the IP Flags used?

I am curious to know where the "Don't Fragment" [DF] Bit of the IP Flags is used. As fragmentation is invisible to higher layers and they don't care too. I am also looking for an example. Thanks a lot in advance. ...

Finding the type of an object in C++

I have a class A and another class that inherits from it, B. I am overriding a function that accepts an object of type A as a parameter, so I have to accept an A. However, I later call functions that only B has, so I want to return false and not proceed if the object passed is not of type B. What is the best way to find out which type t...

Porting C++ lib/app on android

I want to port few C/C++ libraries to android, how feasible it would be e.g. openssl can it be ported or suppose an application which depends on openssl, what is the best way to port it to android when android i think itself has libssl.so what are the tools available e.g. scratchbox , any alternatives? Has anybody experience with it? ...

Finding the type of an unknown object in C++

There are many ways to check programs for memory leaks. You end up with that list of pointers to leaked memory blocks, but is there a good way to find out more information for each block? For example: if I know that the object was a string, the actual string value could make finding the leak a lot easier. Is there a backdoor into RTTI t...

What is the Future of C++ Language & Developers ?

I wanted to know the future of C++. Now a days more languages are coming like D Language. I am curious to know the future of C++. Whether it will play the same role as it has been since from its inception. Does it play big role in parallel programming. Please share your thoughts. Would be much glad to know. See also What is the fut...

Is there a dereference_iterator in the STL?

I was wondering if there is an iterator in the STL that dereferences the object pointed before returning it. This could be very useful when manipulating containers aggregating pointers. Here's an example of what I would like to be able to do: #include <vector> #include <iterator> #include <algorithm> using namespace std; int main() { ...

Reading from a text field in another application's window

Is there a way for a Windows application to access another applications data, more specifically a text input field in GUI, and grab the text there for processing in our own application? If it is possible, is there a way to "shield" your application to prevent it? EDIT: The three first answers seem to be about getting the another applic...

How to cancel the 'system key down' state in Windows

In Windows, when you press Alt, and release it again, the menu bar gets activated. However, when you press Alt, then click, then release, the menu bar does not get activated because presumably you wanted to Alt+click, not activate the menu bar. I want to support Alt+mouse wheel changes (which would map to horizontal scrolling). This wor...

Multiple Integer-type classes in C++

I often find myself using Integers to represent values in different "spaces". For example... int arrayIndex; int usersAge; int daysToChristmas; Ideally, I'd like to have separate classes for each of these types "Index","Years" and "Days", which should prevent me accidentally mixing them up. Typedefs are a help from a documnentation pe...

what is the difference between stringstream clear and str

I just wanted to know what's the difference between clear() and str(""); For example: stringstream ss("Stack Overflow"); ss.clear(); ss.str(""); I wanted to know the underlying technical difference. ...

How to access to parent widget on qt?

I have an inherited QTreeWidget (called PackList) class and its parent is a KXmlGuiWindow. How can I access to the parent's slots? I've tried getParent()->mySlot() from the QTreeWidget class but I've got error: no matching function for call to 'PackList::mySlot()' Does anybody know the correct way? Thanks ...

Dependency injection in C++

This is also a question that I asked in a comment in one of Miško Hevery's google talks that was dealing with dependency injection but it got buried in the comments. I wonder how can the factory / builder step of wiring the dependencies together can work in C++. I.e. we have a class A that depends on B. The builder will allocate B in t...

_endthreadex(0) hangs

I have some code which I did not originally create that uses _beginthreadex and _endthreadex. For some reason, when it calls _endthreadex(0), the call just hangs and never returns. Any ideas as to what would normally cause this call to hang? ...