c++

Is there an easy way to push variables onto the stack for later retrieval

I have a member function of an object that is typically used in an iterative manner but occasionally in a recursive manner. The function is basically following the path of a stream of water downhill, and under certain conditions the stream could split. In order to support the occasional recursion I have to push the state of the object ...

Maintaining a recent files list

I would like to maintain a simple recent files list on my MFC application that shows the 4 most recently used file names. I have been playing with an example from Eugene Kain's "The MFC Answer Book" that can programmatically add strings to the Recent Files list for an application based on the standard Document/View architecture: (see "M...

Just-In-Time Derivation

There's a less common C++ idiom that I've used to good effect a few times in the past. I just can't seem to remember if it has a generally used name to describe it. It's somewhat related to mixins, CRTP and type-erasure, but is not specifically any of those things. The problem is found when you want to add some implementation to a clas...

A Reliable way to Identify a computer by its ip address

I have a network of computers that they will connect to the a server with DHCP, so I don't know what Ip address a computer will get when I connects to the server. If 192.168.0.39 for example is connected to the server can I identify the real computer behinde this ip address? ( I can install an external application on each client in order...

Template type deduction in C++ for Class vs Function?

Why is that automatic type deduction is possible only for functions and not for Classes? ...

Drawing SVG images in wxWidgets

I need to be able to draw SVG images (with the ability to scale, and rotate the images by 90,180 and 270 degrees). I also want the ability of instead of rendering the images to a bitmap (e.g. for displaying), to be able to draw them into a new SVG image (exporting the "document" to SVG). wxWidgets does not seem to have any built in SVG...

ILockBytesOnHGlobal WriteAt performance decreases over time

I've created ILockBytesOnHGlobal and I write 64k of data repeatedly. What I've noticed is that WriteAt performance decreases over the time. What could be the reason for the performance slow down? Does it have to do with stream growth? Here is what I'm doing (in C#) public override void Write(byte[] buffer, int offset, int count) ...

Should a person new to windowed applications study X, GTK+, or what?

Let's say the factors for valuing a choice are the library of widgets available, the slope of the learning curve, and the degree of portability (platforms it works on). As far a language binding goes, I'm using C++. Thanks! ...

WinPE 2.0 (Vista) - Looking for a solution for BrowseForFolder using VBSCRIPT & HTA application

Hi, I am creating an HTA application to be run inside of a WinPE 2.0 environment. The purpose of this HTA app is to prompt the user to select a back-up location. I am currently using BrowseForFolder to prompt the user folder location. Script works fine in Vista. However, this does not work in winpe 2.0 - and a dialog appears with n...

C++ cache aware programming

Hi! is there a way in C++ to determine the CPU's cache size? i have an algorithm that processes a lot of data and i'd like to break this data down into chunks such that they fit into the cache. Is this possible? Can you give me any other hints on programming with cache-size in mind (especially in regard to multithreaded/multicore data p...

Using unicode font in c++ console app

How do I change the font in my c++ windows console app? It doesn't seem to use the font cmd.exe uses by default(Lucida Console). When i run my app through an existing cmd.exe (typing name.exe) it looks like this: http://dathui.mine.nu/konsol3.png which is entierly correct. But when i run my app seperatly(double-click the .exe) it looks l...

Find a cycle in an undirected graph (boost) and return its vertices and edges.

I need a functions thats find a cycle in an undirected graph (boost) and returns its vertices and edges. It needs only return the vertices/edges of one cycle in the graph. My question is - what is the best way to do this using with boost? I am not experienced using it. ...

Creating an HICON from a byte array in C++?

I have a PNG-encoded icon as a byte array in memory. What is the recommended way of creating an HICON object from this byte array? Imaginary bonus points if you know a solution without ATL or GDI+... :) ...

thread synchronization - delicate issue

let's i have this loop : static a; for (static int i=0; i<10; i++) { a++; ///// point A } to this loop 2 threads enters... i'm not sure about something.... what will happen in case thread1 gets into POINT A , stay there, while THREAD2 gets into the loop 10 times, but after the 10'th loop after incrementing i's value to 10, befo...

Import a DLL with C++ (Win32)

How do I import a DLL (minifmod.dll) in C++ ? I want to be able to call a function inside this DLL. I already know the argument list for the function but I don't know how to call it. Is there a way of declaring an imported function in C++ like in C# ? ...

Valid Locale Names

How do you find valid locale names? I am currently using MAC OS X. But information about other platforms would also be useful. #include <fstream> #include <iostream> int main(int argc,char* argv[]) { try { std::wifstream data; data.imbue(std::locale("en_US.UTF-16")); data.open("Plop"); } catch...

Running in the Terminal a build made in XCode, how?

Hi, Im creating a project in Xcode using OpenCV as a framework. It works great with the Build&Run option from Xcode, but now I need to run it in the Terminal and it gives me this error: dyld: Library not loaded: @executable_path/../Frameworks/OpenCV.framework/Versions/A/OpenCV Referenced from: /Users/Victor/Documents/PFC/src/opencv/blo...

UTF-16 codecvt facet

Extending from this questions about locales And described in this question: What I really wanted to do was install a codecvt facet into the locale that understands UTF-16 files. I could write my own. But I am not a UTF expert and as such I am sure I would get it nearly correct; but it would break at the most inconvenient time. So I was ...

CString join method?

I need to concatenate a list of MFC CString objects into a single CSV string. .NET has String.Join for this task. Is there an established way to do this in MFC/C++? ...

Can BSTR's hold characters that take more than 16 bits to represent?

I am confused about Windows BSTR's and WCHAR's, etc. WCHAR is a 16-bit character intended to allow for Unicode characters. What about characters that take more then 16-bits to represent? Some UTF-8 chars require more then that. Is this a limitation of Windows? Edit: Thanks for all the answers. I think I understand the Unicode aspec...