c++

Regular expression capturing a repeated group

I am trying to parse input string using regular expression. I am getting problem when trying to capture a repeating group. I always seem to be matching last instance of the group. I have tried using Reluctant (non greedy) quantifiers, but I seems to be missing some thing. Can someone help? Regular expression tried: (OS)\\s((\\w{3})(([...

Header file throwing errors in one project, but not in another

I'm trying to integrate two projects, and to that end am including header files from one into the other. I'm using visual studio 2008 express. The line int E4407B_PPM(int &); is throwing errors in the new project, but the original project compiles just fine. The error I'm getting: error C2143: syntax error : missing ')' before '&' ...

C++ case multimap

I have a multimap defined by typedef std::pair<int, int> au_pair; //vertices typedef std::pair<int, int> acq_pair; //ch qlty specified by C typedef std::multimap<int, acq_pair> au_map; typedef au_map::iterator It_au; The no. of simulations depend on the size of the au_map. For eg: if the au_map.size() = 5 I will have C1, C2, C3, C4, C...

How do I capture all matches of a repeating group with Boost::regex_search?

I am trying to parse an input string using a regular expression. I am getting a problem when trying to capture a repeating group. I always seem to be matching last instance of the group. I have tried using Reluctant (non greedy) quantifiers, but I seems to be missing something. Can someone help? Regular expression tried: (OS)\\s((\\w{...

C++ count time overcoming 72 minutes range of clock_t

Hello, I'm trying to count the execution time of part of my application, but since I need to get milliseconds, and I need to get long execution times too. I'm currently using clock_t = clock() from ctime, but it has a range of only 72 minutes I think, which is not suitable for my needs. Is there any other portable way to count large exec...

C++ pass by reference

I've recently (4 days) started to learn C++ coming from C / Java background. In order to learn a new language I ussualy start by re-implementing different classical algorithms, as language specific as I can. I've come to this code, its a DFS - Depth First Search in an unoriented graph. Still from what I read it's best to pass parameters...

Using VBO's and CPU usage is very high

I'm really not sure what to do anymore. I'v made my application use VBO's and my cpu usage still goes into the 70's and 80's. My render proceedure works like this: Set the camera transformation if the shape has not been tesselated, tesselate it. create it's VBO if it has a VBO, use it. You will notice I have display lists too, I might ...

[Qt] Is it possible to have a QMaemo5ListPickSelector which displays images as items ?

Hi all ... I wanted to know if its possible to have a QMaemo5ListPickSelector but one which displays rectangular images as list items instead of text ? Is this possible ? If not, is there any other list-like object in Qt which can show images as items instead of text ? ...

Help understanding a C++ sample app which uses global mouse event hooks?

I'm trying to understand and implement the sample presented in this MSDN forum thread. The sample involves implementing a global hook to catch mouse movement and click events, and act on them under certain circumstances. I know C# pretty well, but I don't know C++ enough to understand what this sample code is doing. The contributor of ...

Exception thrown when exiting program (Ogre3d)

I am getting a weird exception when I exit the program. This has started since today morning and I am ready to pull my hair out. As soon as I exit the program, visual studio gives an exception and stops at line 731 in the file crt0dat.c (see attached screenshot) I know this is very little to go on. I have tried several different things:...

Understanding the low-level mouse and keyboard hook (win32)

I'm trying to capture global mouse and keyboard input. LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { if (wParam == WM_RBUTTONDOWN) printf("right mouse down\n"); if (wParam == WM_RBUTTONUP) printf("right mouse up\n"); } return CallNextHookEx(0, nCode, wParam, lParam); } HHOOK ...

In game programming, what are the specific C++ or STL features that causes performance hogs ?

My question is mostly about STL than the rest of the C++ that can be compared (I guess) to be as much fast as C a long as classes aren't used at every corner. STL is standard for games and in engines like OGRE3D, but I was wondering that if STL's features are nice to use, the problem is while I don't really know how they work, I should ...

Use a model as a source for a QMenu

Hi, I created a model which list the existing configurations (let's say it lists "files", as this doesn't really matter here). So far, it works well when attached to a QListView. Example: --- ListView --- - file #1 - - file #2 - - file #3 - - file #4 - ---------------- Is it possible to use the same model for a d...

Threading a prime number finder in C++

How can I use threading to write a program that finds the prime numbers between 0 and 1001? ...

Threading on both Windows and Linux

I have seen tutorials on the internet for making multithreaded applications in C++ on Windows, and other tutorials for doing the same on Linux, but not for both at the same time. Are there functions that would work even if they were compiled on either Linux or Windows? ...

Why should an API return 'void' ?

When writing an API or reusable object, is there any technical reason why all method calls that return 'void' shouldn't just return 'this' (*this in C++)? For example, using the string class, we can do this kind of thing: string input= ...; string.Join(input.TrimStart().TrimEnd().Split("|"), "-"); but we can't do this: string.Join(i...

how to initialize a char array?

char * msg = new char[65546]; want to initialize to 0 for all of them. what is the best way to do this in C++? ...

Analyze Core Dump

We have a binary that generates coredump. So I ran the gdb command to analyze the issue. Please note the binary and code are in two different locations and we cannot build the whole binary using debugging symbols. Hence how and what details can I find from below backtarce: gdb binary corefile (gdb) where #0 0x101fa37a in f1() #1 0x10...

MySql Connector prepared statement only transfers 64 bytes

I am using the MySql Connector C++ to store a JPEG image from a file into the database. I am using the prepared statement. After execution of the prepared statement, only the first 64 bytes of the file are copied into the database. My research of examples show that no iteration is necessary and the examples assume that the prepared ...

return statements when doing Extract Method

Let's say you have a very long method, like this: int monster() { int rc = 0; // some statements ... if (dragonSlayer.on_vacation()) { cout << "We are screwed!\n"; if (callTheKing() == true) return 1; else return 2; } else { cout << "We are saved!\n"; slay...