c++

Sorting an XML file with Qt

Hi how to to sort an XML file using Qt my file look like this : <?xml version="1.0" encoding="UTF-8"?> <project> <task next="2" first="1" name="2" value="name1"/> <task next="3" first="1" name="1" value="name2"/> <task next="4" first="3" name="4" value="name3"/> <task next="4" first="1" name="6" value="name4"/> <t...

Verifying compiler optimizations in gcc/g++ by analyzing assembly listings

I just asked a question related to how the compiler optimizes certain C++ code, and I was looking around SO for any questions about how to verify that the compiler has performed certain optimizations. I was trying to look at the assembly listing generated with g++ (g++ -c -g -O2 -Wa,-ahl=file.s file.c) to possibly see what is going on un...

Customized Windows Save Dialog is no Longer Fancy -- Why?

In accordance with this question I am customizing a Win32 Save File dialog with a custom template description. Now I have a problem where the Save File dialog doesn't show the left-hand bar with my computer, recent places, etc. I can confirm that removing the custom template brings the left-hand sidebar back. What am I doing that warrant...

SQL Server catch error from extended stored procedure

Hello I have an extended stored procedure that sends an error message. srv_sendmsg(pSrvProc, SRV_MSG_ERROR, errorNum, SRV_FATAL_SERVER, 1, NULL, 0, (DBUSMALLINT) __LINE__, buff, SRV_NULLTERM); I've set the severity to SVR_FATAL_SERVER just as a test to see if I can cause the message to throw an exc...

xerces xinclude error

I am using Apache Xerces 3.0.1 XInclude. I want to use the xinclude mechanism to include XML files. I have three XML files all in the same directory. test_a.xml xincludes test_b.xml which xincludes test_c.xml. When I just have test_a.xml xinclude test_b.xml, it works. However, when I have test_b.xml xinclude test_c.xml I get the followin...

Should I use printf in my C++ code?

So I generally use cout and cerr to write text to the console. However sometimes I find it easier to use the good old printf statement. I use it when I need to format the output. So one example of where I would use this is: // Lets assume that I'm printing coordinates... printf("(%d,%d)\n", x, y); // To do the same thing as above us...

A Better Way To Build a Packet - Byte by Byte?

This is related to my question asked here today on SO. Is there a better way to build a packet to send over serial rather than doing this: unsigned char buff[255]; buff[0] = 0x02 buff[1] = 0x01 buff[2] = 0x03 WriteFile(.., buff,3, &dwBytesWrite,..); Note: I have about twenty commands to send, so if there was a better way to send the...

Debugging parameter corruption in C++?

I've got a plugin system in my project (running on linux), and part of this is that plugins have a "run" method such as: void run(int argc, char* argv[]); I'm calling my plugin and go to check my argv array (after doing a bunch of other stuff), and the array is corrupted. I can print the values out at the top of the function, and the...

Why is this a memory copying error - Insure++ false positive?

I've been trying run Insure++ with some scientific code and it reports many errors, although to be fair it officially does not support K&R C and I don't know what having a lot of K&R functions has done to its evaluation process. The C and C++ code it is testing is being run in a DLL invoked from a WPF application. One error report that...

"Forward-unbreakable" accessor class templates [C++]

Hi, Unless I am thoroughly mistaken, the getter/setter pattern is a common pattern used for two things: To make a private variable so that it can be used, but never modified, by only providing a getVariable method (or, more rarely, only modifiable, by only providing a setVariable method). To make sure that, in the future, if you happe...

C#: Workaround for Illegal Switch Statement?

Possible Duplicate: Switch statement fallthrough in C#? The following code is illegal in C# because control cannot fall through from one case label to another. However, this behaviour is perfectly legal in C++. So, how would you go about coding the same behaviour in C#? enum TotalWords { One = 1, Two, Three, Four } ...

HTTP/S proxy starting point

I would like to make an HTTP/S proxy program to filter/deny certain http traffic based on how I parse the HTTP request in C++. Is there some kind of starting point code that I can use with an open license for commercial use? For example if I wanted to do a project on searching I would start with lucene. ...

Definition of templated member function in templated class (C++)

I have the following templated class, declared in an .hpp file with the implementation in a .inl file included at the end of the .hpp file. It has a templated copy constructor, but I don't know nor can't find anywhere the correct syntax for implementing the templated copy constructor in the .inl file. Does anyone know the correct syntax ...

Why must C# operator overloads be static?

Why does C# require operator overloads to be static methods rather than member functions (like C++)? (Perhaps more specifically: what was the design motivation for this decision?) ...

VC++ Building directshow baseclasses

I am a newbie to DirectX SDK, Platfrom SDK and DirectShow. I downloaded latest Platform SDK and DirectX SDK August'09. I tried to build sample project in folder: Microsoft Platform SDK\Samples\Multimedia\DirectShow\Capture\PlayCap\ And had following building errors: LINK : fatal error LNK1181: cannot open input file 'D:\Program F...

How to replace a string between two substrings in a string in VC++/MFC?

Say I have a CString object strMain="AAAABBCCCCCCDDBBCCCCCCDDDAA"; I also have two smaller strings, say strSmall1="BB"; strSmall2="DD"; Now, I want to replace all occurence of strings which occur between strSmall1("BB") and strSmall2("DD") in strMain, with say "KKKKKKK" Is there a way to do it without Regex. I cannot use regex as adding...

Animation in Qt 4.6

I've a block of code where I've used Qt's new animation framework. I needed the animation just in that block of code and I don't need the animation related variables in other places. Clearly, the animation won't work if it is destroyed before the animation completed. For example, the following doesn't work: if (animate) { QPropertyA...

How to turn pcm audio into text using some lib written entirely in the C\C++ programming language?

How to turn pcm audio into text using some lib written entirely in the C\C++ programming language? So I have pcm file. I want to turn it into text. how to do it? (with speech recognizer lib of your choise (BTW i need it to work extreamly fast) So what do I need? Open Source Libs. Tutorials and blog articles on How to do/use it. ...

What are The opencv function useful for 2d skeleton estimation(ofRecursive centroids)

Possible Duplicate: Which is the best algorithm to Estimate and Visulize 2d skeleton using Opencv from the drawn contour Opencv functions or stepts for 2d skeleton estimation ...

Is it possible to run Native C++ code in Windows Azure?

I have an application written in native C++ which intends intensive computation. In fact I'm interested only in result of computation, i.e. it can be done without GUI or be controlled by some .Net service/application. Can I run it in Microsoft's Cloud? How can I do it? ...