c++

How to implement HMAC-SHA1 algorithm in Qt

Hi. I'm trying to implement HMAC-SHA1 algorithm in my C++/Qt application. I have a method for Sha1 algorithm available, I just need to understand the HMAC part of it. This pseudocode is from wikipedia: 1 function hmac (key, message) 2 if (length(key) > blocksize) then 3 // keys longer than blocksize are shortened 4 ...

C++ shift from Unix to Visual Studio in Windows

Hi Everybody, I am a professional working for a software firm.In my past company basically i was working on C & C++ on unix.Now i suddenly shifted to C++ on Windows and i feel like i am in a completely different world.Basically i am working on a very big application which was totally written in C++.To keep it simple ,i dont have the so...

library for matrices in c++

I have a lot of elements in a matrix and when I access them manually it takes a pretty long time to eliminate all the bugs arising from wrong indexing... Is there a suitable library that can keep track of e.g the neighbors,the numbering, if an element is in the outer edge or not and so on. e.g. VA= 11 12 13 14 21 22 23 24 31 32 33 34 4...

How to do Encryption using open ssl(BIO) using C++?

How to do Encryption using open ssl(BIO) using C++? ...

Result of IWebBrowser2->GetDocument() doesn't implement IHTMLDOMNode

I have a Browser Helper Object and want to do some operations on the DOM of a website. I am struggling on one strange thing right now, I hope somebody knows what is happening here. Let's assume I have the following code snippet somewhere in my Browser Helper Object and m_pBrowser holds the current IWebBrowser2: if (m_pBrowser) { CCo...

Problem with AES and Cryptopp

Hello, In my app need to encrypt file usign AES. I found some example with Cryptopp. Encryption working good: #include "iostream" #include "cstring" #include "cryptopp/cryptlib.h" #include "cryptopp/filters.h" #include "cryptopp/files.h" #include "cryptopp/sha.h" #include "cryptopp/modes.h" #include "cryptopp/aes.h" #include "cryptopp/...

How to detect user inactivity in Qt?

How can I detect user inactivity in a Qt QMainWindow? My idea so far is to have a QTimer that increments a counter, which, if a certain value is passed, locks the application. Any mouse or key interaction should set the timer back to 0. However I need to know how to properly handle input events which reset; I can re-implement: virtual v...

Observer pattern with one observer and many subjects

I want to implement the observer pattern and I want class X to observe updates in classes A and B. X is derived from the abstract base class XObs which has the update() function taking an enum as parameter of what has happened. The logical problem here is that X needs to know which of A and B sent the update and X cannot determine th...

Do templates shorten the size of source or binary or both

I read that templates are complied into different entities so does that mean the binary size will be same as we have complied it using different functions? ...

Crash on Windows 7 but running on XP

Hi, i've written a small application using c++, Qt and Visual Studio 2010. It's working on Windows XP (32bit) but it crashes on Windows 7 (64 bit) right after start-up. I see a "The program has stopped working..." error. Do I have to recompile the application for Windows 7? And is it possible to get more information why it crashes? Tha...

Which compiler for default templates args in function

Hi, Is there a compiler which would complile function template definition with new C++ feature namely default templates arguments in function definition? ...

static initialization of Template classes for singleton object

Hi, We have a singleton template class as defines below template<class T> class Singleton{ T& reference(){ return objT; } private: T objT; }; And another user defined class which uses this singleton class TestClass{ static Singleton<TestClass> instance; static TestClass * getPointer() ...

Dynamic linking unable to resolve main symbols

I'm trying to dynamically link a module into my program. If I normally compile and link this module then the symbols in it are normally accessible to the C++ via declaring the function prototypes as extern "C". The module itself is a group of fortran functions, that call C++ functions that I have written. When attempting to dynamically ...

Specifying template argument

How can I specify what is required to be a valid template argument? What I mean is let's for example take something like this: template<class T> void f(const T& obj) { //do something with obj } but I would like T to be only integer type so I would accept char, int, short unsigned etc but nothing else. Is there (I'm sure there is) a w...

How many vptr will a object of class(uses single/multiple inheritance) have?

How many vptrs are usually needed for a object whose clas( child ) has single inheritance with a base class which multiple inherits base1 and base2. What is the strategy for identifying how many vptrs a object has provided it has couple of single inheritance and multiple inheritance. Though standard doesn't specify about vptrs but I just...

Which type to use when iterating a std::vector (without iterators)?

Perhaps this question is trivial, but thinking a second time about it I wonder how to do the following really the right way: std::vector<K> v = ...; for(T i=0; i<v.size(); ++i) { const K& t = v[i]; // use t *and i* } What type should T be? int, unsigned int, int32_t, size_t (which would be the type of v.size()) or any other sugges...

Give a name to a boost thread?

Is it possible to give a name to a boost::thread so that the debuggers tables and the crash logs can be more readable? How? ...

Capture server-client communication with tcpdump

I wrote a simple server and client apps, where I can switch between TCP, DCCP and UDP protocols. The goal was to transfer a file from the one to the other and measure the traffic for each protocol, so I can compare them for different network setups (I know roughly what the result should be, but I need exact numbers/graphs). Anyway after ...

passing C++ classes instances to python with boost::python

I have a library which creates objects (instances of class A) and pass them to a python program which should be able to call their methods. Basically I have C++ class instances and I want to use them from python. Occasionally that object should be passed back to C++ for some manipulations. I created the following wrapper file (let's as...

What's the scenario difference between hash_map and map in STL?

Is there any principle to choose one over another between hash_map and map in STL? ...