c++

Simulating low memory using C++

I am debugging a program that fails during a low memory situation and would like a C++ program that just consumes LOT of memory. Any pointers would help! ...

Best C/C++ Library to defang HTML?

I'm looking for a C/C++ functional equivalent to HTML::Defang, and my Google-fu has not been able to uncover anything. I want to keep any benign tags and strip out/defang everything else. Lacking an actual library, any pointers to complete lists of tags/attributes/etc to defang would be appreciated. I know of http://en.wikipedia.org/wiki...

Using typedef from inside a template as template argument type

I'm trying to do something like this (completely synthetic example, because the real code is a bit to convoluted): enum MyInfoType { Value1, Value2 }; template<typename T> struct My_Type_Traits {}; template<> struct My_Type_Traits<int> { typedef MyInfoType InfoType; }; template<typename T> class Wrap { template<My_Type_T...

Don't give away your internals? [C++]

Hi, I am reading book called "C++ coding standard" By Herb Sutter, Andrei Alexandrescu and in chapter 42 of this book is an example:(chapter is short so I'm taking the liberty and pasting part of it) Consider: class Socket { public: // … constructor that opens handle_, destructor that closes handle_, etc. … int GetHandle() cons...

Simple C++ Graphics Library

Any suggestions for a simple C++ library I can use to create an image to a specified size, with either a fixed rgb colour value or ideally supporting gradients. Needs to work on Windows and ideally but not required to work on OS X as well. I've found Cairo, but just wondered if there was anything else as it seems quite simple what I re...

How to embed WebKit into my C/C++/Win32 application?

The solutions I have found are irrelevant: someone used WebKit in a Delphi project someone used it with Java there is QtWebKit (about:blank demo app takes 44 megs) .Net port of it GTK+ port I need a guide how to embed WebKit instance into a pure C/C++ application under Win32. ...

mixing cout and printf for faster output

After performing some tests I noticed that printf is much faster than cout. I know that it's implementation dependent, but on my Linux box printf is 8x faster. So my idea is to mix the two printing methods: I want to use cout for simple prints, and I plan to use printf for producing huge outputs (typically in a loop). I think it's safe t...

std::map of member function pointers ?

I need to implement an std::map with pairs. The function pointers are pointers to methods of the same class that owns the map. The idea is to have direct access to the methods instead of implementing a switch or an equivalent. ( I am using std::string as keys for the map ) I'm quite new to C++, so could anyone post some pseudo-code or...

What can cause an abnormal program termination?

MFC application (uses SQLite3.dll for DB access, along with other DLLs for accessing hardware) terminates abnormally. There is no particular sequence of termination :( My application is a Single threaded Application Uses exception handling Uses more than 6 DLLs to access different hardwares Runs on WinXP SP2 Initially i thought it m...

Control USB port's power?

Does anybody know how to control USB pins on a certain USB port? I think it is definately possible in assembler but what about C++ or C#? I want to be able to use USB battery as a power supply for an LED or something like that. So then a program would power it on and power it off making it flash. I know it sounds pointless but I nee...

MSVC9: How do I view a location in memory?

I'm pretty sure I'm overlooking something totally obvious, but I want to view the raw contents of a point in memory under MSVC9, but I can't find a location in the UI where I can punch in a memory address. How can this be done? ...

Problems passing argument to a const parameter

Say I have a function that takes a const reference to a pointer... Example: void Foo( const Bar *&p_Thing, ); and I pass a pointer Bar *blah = NULL; // Initialized when program starts up to the function Foo( blah ); I may encounter a compiler error like this invalid initialization of reference of type 'const Bar*&' from expres...

Implementing a z buffer in a software rasterizer

Hello, as a homework assignment, we're writing a software rasterizer. I've noticed my z buffering is not working as well as it should, so I'm trying to debug it by outputting it to the screen. (Black is near, white is far away). However, I'm getting peculiar values for the z per vertex. This is what I use to transform the points: floa...

How do I convert System::WideString to a char* in C++ and vice versa?

I have a situation where I need to compare a char* with a WideString. How do I convert the WideString to a char* in C++? ...

C++ how to access a protected base class method through an instance of the derived class

Given the following c++ classes: // base class class A { protected: void writeLogEntry(const std::string& message); }; // derived class class B : public A { }; // c.h class C { myMethod(); } // c.cpp - uses B C::myMethod() { B b; b.writeLogEntry("howdy"); } As expected, class C fails to compile with the error "cannot...

Is There an Archiving Library Without Dependencies? (C/C++)

Hey, I'm looking for an archiving library that functions like GNU's tar, but without any dependencies. I need some sort of archiving format to manage resources in my game engine and am still iffy about rolling my own. ...

What kind of applications should be rewritten to use OpenCL?

Mac OS X 10.6 comes with OpenCL, but how many applications could have better performances if they would be rewritten to use OpenCL? What kind of applications should be rewritten to use OpenCL? ...

Splitting up lines into ints

I have a file that I read from, it contains a bunch of lines each with a different number of integers, I'm having trouble splitting it up into a vector of a vector of ints. This is my current code. std::vector<int> read_line() { std::vector<int> ints; int extract_int; while((const char*)std::cin.peek() != "\n" && std::cin.p...

Recommendations: asynchronous, portable file io in c++

Hi all, Title says it all. I'm looking for a C++, async io library that should be compatible with both unix and windows systems. What are some good libraries? Is this asking too much for a library that does both systems? What are peoples' experiences with this matter? ...

Using __asm to call a function from hex offset.

I don't know assembly so I'm not sure how to go about this. I have a program which is hooking into another. I have obtained the offset to where the function is located within the hooked program's .exe #define FuncToCall 0x00447E5D So now how can I use __asm{} to call that function? ...