c++

help with byte array

I have one byte array which has some raw data like 1aa23486b2..and so on. I want to represent each byte in the array as a decimal number. I then have to go through the decimal numbers and pick out the first x decimal to output to screen. if i use int byte [same size as input byte array] would that work? just declare and initialized it ...

How to communicate between Rhapsody models in different processes/systems?

We are using IBM (formerly Telelogic) Rhapsody for a new project to do model driven development of a complex device. The device consists of several subsystems that are connected by various network interfaces. We'd like to model the entire system in Rhapsody and then generate code separately for the various subsystems. The problem is thi...

simulate socket errors

How to simulate socket errors? (sometimes server or client disconnects because of some socket error and it is impossible to reproduce.) I was looking for a tool to do this, but I can't find one. Does anyone know either of a tool or has a code example on how to do this? (C# or C/C++) ...

pthread vs NSThread: which is faster

In Cocoa, is NSThread faster than pthread? is are any performance gain? is it negligible to ignore? ...

Convert MYSQL Timestamp to time_t

I'm writing a multi-threaded program that needs to be able to check if a row requires updating and act accordingly. I had problems using the built in date/time functions of MySql and so decided to just store the "lastupdate" timestamp as an integer in the table. However, I'm having problems converting this timestamp to time_t so that I...

Sequential Key Generation

Right now, I'm working on a project which requires sequential text key generation. I need to seed the key generator with an integer corresponding to a certain key, which the constructor converts to a key. My key generator overloads the increment operators so that the string is incremented directly, rather than what I had previously been...

CComModule UnregisterServer error?

I have a CComModule that is calling RegisterServer (TRUE) on DllRegisterServer and UnregisterServer (TRUE) on DllUnregisterServer. The UnregisterServer is getting a 0x8002801C (Error accessing the OLE registry.) error and leaving around registery keys. I am using a Windows Server 2k8 R2 machine with UAC enabled. The components are x86 an...

Is there any reason that the STL does not provide functions to return an iterator via index?

Hi, Is there a reason that the STL does not provide functions to return an iterator into a container via an index? For example, let's say I wanted to insert an element into a std::list but at the nth position. It appears that I have to retrieve an iterator via something like begin() and add n to that iterator. I'm thinking it would be ...

How to programmatically move Windows taskbar?

I'd like to know any sort of API or workaround (e.g., script or registry) to move (or resize) Windows taskbar to another position including another monitor (if dual monitors). Definitely, we can move task bar by using mouse, but I want to move it by a program, or a sort of automated way. I tried to find Win32 API, but it seems no one do...

Callback to non-static method

I have this weird issue. Think of your basic openGL programs. They simply run from a main method and contain callbacks like `glutMouseFunc(MouseButton) where MouseButton is the name of a method. What I have done is I have encapsulated the main file into a class, so that MouseButton is no longer a static function but has an instance. But...

C++ a NULL pointer in the STL container

Hello! I am, unfortunately, not working on a program developed by myself fully. I recently I noticed a Visual Studio Fatal Error on operator-- of unordered_set, which was called from simple insertion of a pointer to unordered_set. After reviewing the locals, I've noticed that set only has 2 elements last of which is NULL (so I suppose ...

How do I iterate over faces in CGAL

I am trying to use CGAL to do some Delaunay triangulation. I used one of the CGAL samples to compute a triangulation which includes a height field attribute. The problem I have having is that I have no idea how to get the resulting triangulation. I figured out how to get the face_iterator, but I don't know what to do from there. What...

Apache mod_c++ wanted?

Hi guys, I want to experiment a bit with C++ as a server side language. I'm not looking for a framework, and simply want to achieve a silly old "Hello World" webapp using C++. Is there an Apache HTTP server module that I can install? If i can do the PHP equivalent of : <?php $personName = "Peter Pan"; echo "Hello " . $personN...

What could be generating the compiler error in this statement to advance an iterator?

The following line generates a compiler error: std::vector<int>::iterator blah = std::advance(instructions.begin(), x ); where I have declared: std::vector<int> instructions; int x; The error I get is: error C2440: 'initializing' : cannot convert from 'void' to 'std::_Vector_iterator<_Ty,_Alloc>'. What element of that stateme...

Windows Threads: when should you use InterlockedExchangeAdd()?

The naming of this function seems like this is some complicated stuff going on. When exactly does one know that this is the way to go instead of doing something like this: Preparation CRITICAL_SECTION cs; int *p = malloc(sizeof(int)); // Allocation Site InitializeCriticalSection(&cs); // HINT for first Write Thread #1 ...

C++ console keyboard events

Is there any way to get key events in a Windows console? I need a way to get keydown and keyup events quickly without a GUI. I've tried using getch(), but it doesn't get keyups and waits until a key has been pressed to return. ...

Ogre3D Basic Framework issue on Ubuntu

I have been trying to learn to use Ogre3D and have gotten to the stage where I want to start something more serious than the examples it comes with so I found and copied the Basic Ogre Framework I am using Ubuntu 9.10, but have compiled Ogre 1.7 from the Ogre3D website, I am using the Netbeans 6.8 IDE with the c++ plugin. The Basic Ogr...

In C++, is it safe/portable to use static member function pointer for C API callbacks?

In C++, is it safe/portable to use static member function pointer for C API callbacks? Is the ABI of a static member function the same as a C function? ...

C++ method only visible when object cast to base class?!

It must be something specific in my code, which I can't post. But maybe someone can suggest possible causes. Basically I have: class CParent { public: void doIt(int x); }; class CChild : public CParent { public: void doIt(int x,int y,int z); }; CChild *pChild = ... pChild->doIt(123); //FAILS compiler, no method found CParent *pP...

Perspective correct texture mapping; z distance calculation might be wrong

Hi, I'm making a software rasterizer, and I've run into a bit of a snag: I can't seem to get perspective-correct texture mapping to work. My algorithm is to first sort the coordinates to plot by y. This returns a highest, lowest and center point. I then walk across the scanlines using the delta's: // ordering by y is put here order[0...