c++

Do without USES_CONVERSION macro...

I have this code that uses the USE_CONVERSION macro in a C++ project... I was wondering if this is written well, (not written by me), and if there's any better ways to do it, without the USES_CONVERSION and W2A macros. STDMETHODIMP CInterpreter::GetStringVar(BSTR bstrNamespace, BSTR bstrVar, BSTR *pbstrValue) { USES_CONVERSION; try { ...

Qt - How to get the "Temp" dir for an arbitrary user?

For each OS there is a location for storing temporary data. It could be like: C:/Users/[user name]/AppData/Temp (or so). How can I get this path independently from OS with QT? ...

MessageBox with timeout OR Closing a MessageBox from another thread

If my application crashes, I use an ExceptionFilter to catch the crash, perform some final actions, then show a message box to the user that the application has crashed. Because the application already crashed, there's not much I can (or I dare) to do, because if I do too much, the executed code might access corrupted memory and crash a...

How to get file path from NTFS index number?

I have dwVolumeSerialNumber, nFileIndexHigh, nFileIndexLow values obtained from a call to GetFileInformationByHandle. How can I get file path from these values? ...

Custom interactive shell

I've run into the following problem: My console utility should be running as a process (hope it's the right term) so every command goes to it directly. Like gnuplot, interactive shells (irb, etc.). This shows what I'm talking about: Mikulas-Dites-Mac-2:Web rullaf$ command Mikulas-Dites-Mac-2:Web rullaf$ irb >> command NameError: undefi...

iPhone CoreAudio hang when stopping.

I have an iPhone app that is recording audio and then broadcasting it across the network. In response to a "stop" from the far end it queues a notification to stop the recording. Alas when it gets to the AudioQueueStop call the application just hangs (ie Stop never exits). Thanks to the notification all AudioQueue manipulation is happ...

Exception in two line Xerces program

The following code gives me an exception on the XMLFormatTarget line, but if I change the string from "C:/test.xml" to "test.xml" it works fine. // test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <xercesc/util/XMLString.hpp> #include <xercesc/framework/LocalFileFormatT...

Base 256 GUID String Representation w/Character Offset 0x01F

I need to make a string representation of a 128bit GUID that represents 8bit chunks instead of 4bit; so like base 256 :/ Why? Because I need to shorten the length of the string hex representation of the GUID, it is too long. I have a max array size of 31 plus NULL terminator. Also the character value cannot be from 0x000 to 0x01F.......

Parsing RFC3339 dates in C++

Are there any functions available to parse an RFC3339 date in C++ (even if they are Win32 specific)? I was previously using Qt and the QDateTime::fromString() function to parse the date but I am now using plain old Win32 C++ (No MFC) and I'm struggling to find a way to do it. If there is no standard in way I can write my own but just in ...

Strange behaviour with std::vector

Hi, consider this segment of codes: std::vector<int> vecList; ...populate 3 elements into vecList... if (!vecList.empty()) { std::cout << "List count = " << vecList.size() << std::endl; if (vecList.empty()) { std::cout << "List is empty" << std::endl; } } my printout is: List count = 3 List is empty ...

C++, preventing class instance from being created on the stack (during compiltaion)

I know there are methods to prevent a class from being created on the heap, by preventing the user from using the new and delete operator. I am trying to do just the opposite. I have a class that I want to prevent the user from creating an instance of it on the stack, and that only instances instigated using the new operator will compile...

Does any MOF implementation exist in C++?

Is there any alternative to JMI for C++? Thanks for the links or suggestions. ...

c++ qt read xml file

if i got an xml file like this: <?xml version="1.0" encoding="utf-8"?> <name> <id>1</id> </name> how can i read everything that i got string id = ... (1 in this case); ...

keeping private parts outside c++ headers: pure virtual base class vs pimpl

Hi all, I recently switched back from Java and Ruby to C++, and much to my surprise I have to recompile files that use the public interface when I change the method signature of a private method, because also the private parts are in the .h file. I quickly came up with a solution that is, I guess, typical for a Java programmer: interfa...

C++ mixins via templates: why doesn't this work?

I've got a interface that's implemented as an abstract base class with a number of pure virtual public methods. These pure virtual functions can be implemented using a template since the differences between subclasses aren't large - so my idea was to use multiple inheritance to mix-in the appropriately templated helper-class that provid...

C++: Strange behaviour of `new`

Hi, SDL provides me this struct: typedef struct SDL_Rect { Sint16 x, y; Uint16 w, h; } SDL_Rect; I want to create a new SDL_Rect on the heap as class variable: // Forward declaration private: SDL_Rect *m_pcScreenRect; And in the constructor I do this: /* Screen Rectangle (for clearing) */ m_pcScreenRect = new SDL_Rect...

What free tiniest flash file system could you advice for embedded system?

I've got DSP tms320vc5509a and NOR flash AT26DF321 on the board and I'm going to store named data on the flash. I don't need directory hierarchy, wear leveling (I hope system will write to flash very few times), but CRC is strongly needed. Thank you ...

C++ Keywords not Colored in Emacs

I have been using emacs for a while for mainly python programming, and have started C++ coding with it. When I open a c++ file, it opens without problems with c++-mode. The background and foreground colors are normal for the theme I have with color-theme, but keywords and strings are not colored differently. Below is the code in my .emac...

c++ boost compilation catastrophe

I'm writing a DLL plugin for a windows application, after adding the following includes: #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> I get a wonderful compilation error: Error 3 error C2143: syntax error : missing ';' before '__cdecl' c:\program files (x86)\microsoft visual studio 9.0\vc\incl...

Makefile for compiling a number of .cpp and .h into a lib

I am running Windows 7 with gcc/g++ under Cygwin. What would be the Makefile format (and extension, I think it's .mk?) for compiling a set of .cpp (C++ source) and .h (header) files into a static library (.dll). Say I have a variable set of files: file1.cpp file1.h file2.cpp file2.h file3.cpp file3.h .... What would be the makefile...