c++

What is the best way to develop a screensharing/presenting app in java or c++ using RTP?

I am trying to build a server sided HTML rendering based browser much like skyfire. I am evaluating the technologies that I would need to build this. When a user types in a www.yahoo.com on the client box, there is a session started on the server, then i grab the screenshots and send them in a RTP stream back to the client. To do the RTP...

Simple USB host stack

I am trying to connect to a single USB device using the USB host port on an Atmel processor. I have an embedded system with limited memory and no OS. I want to implement a simple dedicated host to interface to a single USB slave device. Can anyone guide me to a simple USB host implementation? The processor is the Atmel AT91SAM9261S. ...

STL-like vector with arbitrary index range

What I want is something similar to STL vector when it comes to access complexity, reallocation on resize, etc. I want it to support arbitrary index range, for example there could be elements indexed from -2 to +7 or from +5 to +10. I want to be able to push_front efficiently. Also I want two-way resize... I know I could write something...

Profiling compilation time

I have a C++ code which I am compiling using VC7 and it is taking a lot of time to build it. Is there any way I could profile it and find why it is taking time to build ? ...

How to throw good exceptions?

I heard you should never throw a string because there is a lack of information and you'll catch exceptions you dont expect to catch. What are good practice for throwing exceptions? do you inherit a base exception class? Do you have many exceptions or few? do you do MyExceptionClass& or const MyExceptionClass& ? etc. Also i know exceptio...

Trim / remove a tab ( "\t" ) from a string

Can anyone suggest a way of stripping tab characters ( "\t"s ) from a string? CString or std::string. So that "1E10      " for example becomes "1E10". Thanks in anticipation. ...

How to embed lua in c++ via SWIG

Currently I have a set of SWIG wrappers for my classes and it all builds. I can create a lua virtual machine and load my wrappers, but at that point I'm flummoxed. Googling tells me how to shove put c++ in lua in swig, but not how to put lua in c++. Really all I want to do is manage to instantiate a lua object and pass it my main game e...

Raw socket implementation in windows?

I need to create TCP/IP headers manually for my application. For that i used Raw socket. My system os is win xp (SP3). My code compiles fine :) but it throws a run time error: Initialising Winsock...Initialised successfully. Creating Raw TCP Socket...Raw TCP Socket Created successfully. Setting the socket in RAW mode...Successful. E...

Making the leap from Java to C++

As the topic says I'm very new to c++, but I have some experience with java. To start learning c++ I had the (not very original) idea of making a simple command line calculator. What I'm trying to do is store the numbers and operators in a binary tree. #include <iostream> using namespace std; class Node { bool leaf; double num; c...

Throwing/catching exceptions from C'tor of a static object in C++

Hi all, I have a case in which I have to read an input file in the C'tor, but sometimes this file doesn't exist. This object is usually held statically, so its C'tor is called while loading the dll. I can't catch the exception I throw if the file doesn't exist because it's too early, and my executable crashes in an ugly way. I know it's...

How to clear the memory allocated for Customized Exception

Hi All I have a customized exception class. say class CustomExcep{}; My Application is a middleware made of C++. It is a webservice which is used for the communication between Java based web Front-end and the DCE Backend. whenever the DCE Backend is not running or down due to some core dumps, the application throws the CustomExcep. I...

Java to C++ converter/tool

Hi I always asked myself if it would be possible to make a Java2C++ Converter. Maybe a Tool that converts the Java Syntax to the C++ Syntax.. i am aware that the languages differ .. but simple things like loops where the semantic matches 1 on 1 .. is there such a tool . or is it possible to make one ? ...

map complex find operation

I want to do the following: Define a map between a string and any kind of object (may be a list, integer - anything). The keys to the map can be as follow (the values are, again, not important): "AAA/123" ==> 1 "AAA/" ==> 2 "BBB/" ==> 3 "CCC/*" ==> 4 "CCC/123" ==> 5 Now, the trick is I want to find the right values given the following st...

How can I launch the on-screen keyboard from my application on Vista and Windows 7

I have a problem, I have an application which has a toolbar icon to launch the system onscreen keyboard. This all works fine with the exception of Windows Vista and Windows 7 beta. The UAC appears to be getting in the way and preventing the osk.exe from running. I have read that because it is used on the logon screen it will not promp...

How can I create a guid in MFC

I need to be able to create guids on the fly. Is there a way to do that in MFC? I see how to do it in .net, but we haven't gone there yet. If not, do you have pointers to some code I can use? ...

How do I get the HMODULE for the currently executing code?

I have a static library that may get linked into either a .exe or a .dll. At runtime I want ony of my library functions to get the HMODULE for whatever thing the static library code has been linked into. I currently use the following trick (inspired from this forum): const HMODULE GetCurrentModule() { MEMORY_BASIC_INFORMATION mbi ...

Bit Operation For Finding String Difference

Dear all, The following string of mine tried to find difference between two strings. But it's horribly slow as it iterate the length of string: #include <string> #include <vector> #include <iostream> using namespace std; int hd(string s1, string s2) { // hd stands for "Hamming Distance" int dif = 0; for (unsigned i = 0;...

Is __declspec(dllexport) needed in cpp files

Probably a simple question but I only have Linux to test this code on where __declspec(dllexport) is not needed. In the current code __declspec(dllexport) is in front of all files in the .h file but just in front of like 50% of the functions in the cpp file so I am wondering if they are really needed in the cpp file at all ? ...

How to create an auto startup c++ program

I am creating a program in c++, which I want to be able to have the option to have users let it auto start in windows. So when a user starts his computer, windows will auto start this program. I have read stuff about modifying the registry or putting it in the startup folder, but what would be the best "clean" way to do this? ...

SWIG Lua and passing arrays

I currently have the following lua code: g = engine.CGeometry() vertexes = {} vertexes[1] = 0 vertexes[2] = 0 vertexes[3] = 0 vertexes[4] = 0 vertexes[5] = -1 vertexes[6] = 0 vertexes[7] = -1 vertexes[8] = 0 vertexes[9] = 0 print "adding vertexes" g:SetVertexes(vertexes) where g...