c++

Convert video file to TIFF with ffmpeg.dll or avcodec.dll? Is "on-the-fly" possible?

I want to create a program, which gets a video-file from Qt, converts that video file to TIFF-files and sends them to an algorithm which handles these TIFF-Files. My questions: is it possible with ffmpeg or avcodec not to convert a video-file to TIFF-files first on harddrive and send them to the algorithm after that, but to convert f...

Template class with different order or variables (Color/Pixel class).

I got two class templates Color3_t and Color4_t that store 3 and 4 color channels and look like this: template <typename TYPE> struct Color3_t { TYPE Red; TYPE Green; TYPE Blue; void Zero() { Red = Green = Blue = 0; } (...) } Both templates have several function for inverting, swapping etc. color channels a...

Qt portable IPC: only QSharedMemory?

Hi, I'm looking for suggestions about choosing a portable way to achieve local IPC in a robust way, since i'm new to C++ and would like to avoid common pitfalls of fiddling with shared memory and locks; therefore I was thinking about message-passing style ipc. I was planning to use qt for other reasons anyway, thus i took a peek to Qt ...

sort vector by more than 1 field

How do I sort the below code by name, age and score... all three fields #include <string> #include <vector> #include <algorithm> struct student_t { std::string name; int age, score; }; bool by_more_than_1_field( student_t const &lhs, student_t const &rhs ) { // sort by name, age and score } int main() { ...

C++ throwing compilation error on sizeof() comparison in preprocessor #if

I have this which does not compile with the error "fatal error C1017: invalid integer constant expression" from visual studio. How would I do this? template <class B> A *Create() { #if sizeof(B) > sizeof(A) #error sizeof(B) > sizeof(A)! #endif ... } ...

Examples of PHP In C++

Well I want to learn C++ and at the moment I'm only familiar with PHP and Javascript. And I thought a good way to start learning would be to transfer methods in PHP to C++. So basically I want the code snippets below in C++ The post with the best comments will get a big green tick. Also, if you know of a good beginners tutorial please...

Which sorting algorithm is used by STL's list::sort()?

I have a list of random integers. I'm wondering which algorithm is used by the list::sort() method. E.g. in the following code: list<int> mylist; // ..insert a million values mylist.sort(); EDIT: See also this more specific question. ...

How to programatically disable the auto-focus of a webcam.

I am trying to do computer vision using a webcam (the model is Hercules Dualpix). I know it is not the ideal camera to use, but I have no choice here. The probleme is the auto-focus makes it hard/impossible to calibrate the camera. Anyone knows a way to disable the auto-focus feature. Or, if someone has an idea to deal with it and calibr...

Throwing an exception from within a signal handler

We have a library that deals with many aspects of error reporting. I have been tasked to port this library to Linux. When running though my little test suite, one of the tests failed. A simplified version of the test appears below. /* Compiler: 4.1.1 20070105 RedHat 4.1.1-52 Output terminate called after th...

Removing macro in legacy code

I have a lot of legacy code using macro of the form: #define FXX(x) pField->GetValue(x) The macro forces variable pField be in the scope: ..... FIELD *pField = .... ..... int i = FXX(3); int j = FXX(5); Is there way to replace the macro, without touching user code? Since FXX(x) has a function invocation style, I thought about inl...

Find out Type of C++ Void Pointer

Hello, I have a small question: how do I find out what type a C++ pointer is? I often use a small function in my console programs to gather input, which looks something like this: void query(string what-to-ask, [insert datatype here] * input) I would like to create a generic form, using a void pointer, but I can't cin a void pointer,...

default WM_DESTROY not properly cleaning up child windows

I have a WTL 8.0 SDI application for Windows Mobile 5. In this contrived example below, I create a view, destroy it, then re-create it. But, when it's re-created assertions in the WM_INITDIALOG handler fail because the control's HWND isn't valid. I note that I can fix this by handling WM_DESTROY in CMyView and manually destroying every ...

Container of Pointers vs Container of Objects - Performance

I was wondering if there is any difference in performance when you compare/contrast A) Allocating objects on the heap, putting pointers to those objects in a container, operating on the container elsewhere in the code Ex: std::list<SomeObject*> someList; // Somewhere else in the code SomeObject* foo = new SomeObject(param1, param2); ...

What is a reliable way to get a DLL to load when Windows Explorer loads?

I am researching the development of an add-on for Windows Explorer that will add some enhancements to the WebDAV therein, and to that end I'm looking for a good, reliable way to force a DLL to be loaded with Windows Explorer in XP/Vista/Win7 32- and 64-bit OSes. I seem to recall that a BHO would be loaded by Windows Explorer in the same...

Correct use of s/rand or Boost::random

I know this kind of question has been asked a few times, but alot of them answers boil down to RTFM, but I'm hoping if I can ask the right question... I can get a quasi-definitive answer for everyone else as well, regarding implementation. I'm trying to generate a sequence of random numbers in one of the two following ways: #include <c...

When returning a pointer, what to return if it's not found? C++

I'm not sure what to return as a default? myDrugs is a private vector<Drug*> container Drug* DrugDealer::getFirstDrugInSack(DrugType drugtobuy) { for (int i = 0; i < myDrugs.size(); i++) { if (myDrugs[i]->getType() == drugtobuy) return myDrugs[i]; } return 0; // is this right? } So I would call it like: D...

array of pointers as function parameter

I have a basic question on array and pointer in C/C++. Say I have: Foo* fooPtrArray[4]; How to pass the fooPtrArray into a function? I have tried: int getResult(Foo** fooPtrArray){} // failed int getResult(Foo* fooPtrArray[]){} // failed How can I deal with pointer array? EDIT: I once thought the error msg is from passing the...

Just Want to know what this error message really means!

expected unqualified-id before '{' Where is this error on my code? Thanks everyone! #include <iostream> using std::cout; using std::endl; //function prototypes void findsmallest (int[], int &); void findsmallest (int scores [], int & min); int main() { //declare variables int smallest = 0; int scores[20] = { 90, 54...

What is the right approach when using STL container for median calculation?

Let's say I need to retrieve the median from a sequence of 1000000 random numeric values. If using anything but STL::list, I have no (built-in) way to sort sequence for median calculation. If using STL::list, I can't randomly access values to retrieve middle (median) of sorted sequence. Is it better to implement sorting myself and go...

How can I receive emails in C++ via POP3?

Hey guys, I've been trying to find a POP3 C++ client on the internet but I haven't found any luck. We are working on a project for school that is essentially a C++ course (so I can't use C#...), and we are making a Email client that has to support sending and receiving emails and attachments. We are also working with .NET (because app...