c++

Keep a stream from fstream open through member functions

Hi, I am trying to keep a stream to a file /dev/fb0 (linux framebuffer) open throughout several Qt member functions. The goal is to use a myscreen::connect function to open up the framebuffer bool myscreen::connect() { std::fstream myscreen_Fb; myscreen_Fb.open("/dev/fb0") QImage* image; image = new QImage(w, h, QImage::Format_RGB...

Dynamic C++

I'm wondering about an idea in my head. I want to ask if you know of any library or article related to this. Or you can just tell me this is a dumb idea and why. I have a class, and I want to dynamically add methods/properties to it at runtime. I'm well aware of the techniques of using composite/command design pattern and using embedded...

Does the anonymous namespace enclose all namespaces?

In C++ you specify internal linkage by wrapping your class and function definitions inside an anonymous namespace. You can also explicitly instantiate templates, but to be standards conforming any explicit instantiations of the templates must occur in the same namespace. AFAICT this should compile, but GCC fails on it: namespace foo { ...

VS 2005 rebuilds project without changing any files.

This is a really strange issue. One day my project started to do a rebuild every time I launched it in the debugger, even if I hadn't changed the code. ie. I would go Build->Build Solution, then Debug->Start Debugging, it would rebuild when I tried to start debugging. The specific file that it recompiles is shown (left out source code, j...

adding text to a jpeg

How can you (in C/C++) add text to a jpeg-file using libjpeg? I do not mean by editing pixels, but by adding text to the meta-data (like the png_set_text() libpng library for png files). ...

(Obj) C++: Instantiate (reference to) class from template, access its members?

Hi-- I'm trying to fix something in some Objective C++ (?!) code. I don't know either of those languages, or any of the relevant APIs or the codebase, so I'm getting stymied left and right. Say I have: Vector<char, sizeof 'a'>& sourceData(); sourceData->append('f'); When i try to compile that, I get: error: request for member '...

C++ Class read as variable, default-type int? Say what?!

So, I have two classes...Very basic in structure. I try to import one into the other, and declare a new object of that class type...however, it seems to read the class name as the name of a variable?! The header class provided below will not read the "ApplicationManager" class properly. Code: ####ifndef _GAME_H_ ####define _GAME_H_ ...

Why would StretchDIBits fail on turning image upside down when drawing to EMF file?

I'm attempting to draw an image using StretchDIBits with an Enhanced Meta File handle as the HDC to my OnDraw function using C++ and Visual Studio 2008. I load the .bmp source file using GDIplus and using GetHBITMAP. If I use the HDC returned by BeginPaint there are no problems. If I draw the bitmap upright, flipped horizontally, or fli...

Serialisation and Databasetechnics to locate objects

Hello there, I was wondering if there is a (c++ or D) serialisation library that also provides technics to locate a certain object (which was saved to disk) based to certain criterias like a certain attribute combination. I know about sqlite and mySQL and so own, but I search for an alternative. Because those databases are not bound to...

Compilng C/C++ makefile files under Windows (XP)

I'm trying to use a Python library (pyMedia) that has some non-Python requisites libraries. (libogg, libvorbis, liblame, and libfaad2 - this isn't relevant to the question specifically). libogg requires you to manually compile it from the source and comes with a makefile. I have GCC installed for Windows. How would I go about compiling ...

Cross-platform way of hiding cryptographic keys in C++?

Hi, My application needs to use a couple of hard-coded symmetric cryptographic keys (while I know that storing a public key would be the only perfect solution, this is non-negotiable). We want the keys to be stored obfuscated, so that they won't be recognizable by analyzing the executable, and be "live" in memory for as little time as p...

What is the best way to use two keys with a std::map?

I have a std::map that I'm using to store values for x & y coordinates. Currently I'm creating a std::string with the two coordinates (ie "12x45") and using it as a key. This doesn't seem like the best way to do it. My other thoughts were to use an int64 and shove the two int32s into it and use it as a key. Or to use a class with the t...

std::vector of functions

Hi all I want a std::vector to contain some functions, and that more functions can be added to it in realtime. All the functions will have a prototype like this: void name(SDL_Event *event); I know how to make an array of functions, but how do I make a std::vector of functions? I've tried this: std::vector<( *)( SDL_Event *)> functio...

Why can't you use a Template when iterating

When compiling : #include <vector> template<class T> class foo { void bar() { std::vector<T> x; std::vector<T>::iterator i = x.begin(); } }; int main() { return 0; } I get : # g++ ~test.cpp test.cpp: In member function `void foo<T>::bar()': test.cpp:7: error: expected `;' before "i" Shouldn't this w...

Why isn't there an operator[] for a std::list?

Can anyone explain why isn't the operator[] implemented for a std::list? I've searched around a bit but haven't found an answer. It wouldn't be too hard to implement or am I missing something? ...

Loading Native DLL as Debug Module in Managed C# Code for Windows CE

I am writing a Windows CE application in C# that references a native C++ DLL (that I am also coding) using the following method: [DllImport("CImg_IP_CE.dll")] public static unsafe extern void doBlur(byte* imgData, int sigma); This actually works fine but I am unable to debug the DLL. When I check the debug modules that are load...

Trouble restarting exe

Hi, I need to restart the program that im working on after an update has been downloaded except im running into some issues. If i use CreateProcess nothing happens, if i use ShellExecute i get an 0xC0150002 error and if i use ShellExecute with the command "runas" it works fine. I can start the command prompt fine using CreateProcess an...

Beginner's Guide to Setting Up Qt for C++

Hello, I'm interested in playing around with GUIs and I've been trying to set up Qt for Visual Studio 2008 and MinGW but have failed miserably—in that at times I'd compile the library and it still wouldn't work and others the compile would fail. Can anyone recommend a good guide to set up Qt (or another GUI toolkit if setting up Qt just...

Foreach-statement in c++ and language extension?

You can simulate foreach-statement in c++ with macro declaration. I'm using similar syntax for looping arrays in the following way: int array1[10]; vector<int> array2(10); fori(array1) forj(array2) fork(123) if(array1[i]==array[j]) return true; What's your favorite macros for extending c++ l...

From C++ Tools to.... ? Trying to be exposed to modern tools

I'm a long-time C++ programmer developing on Windows, and have been using Visual Studio for developing unmanaged C++. In the past 2-3 months, for the first time, I have been exposed to the world of C# and Java. Man, I'm astounded by the productivity gain! In particular: C# and Java have so many cool tools (TestDriven.NET, NetBeans I...