c++

parsing an sstream

Hi, I am parsing a file which contains both strings and numerical values. I'd like to process the file field by field, each delimited by a space or an end-of-line character. The ifstream::getline() operation only allows a single delimiting character. What I currently do is thus a getline with the character ' ' as a delimiter, and then m...

Help with this (pointers and polymorphism)

Here is my issue. I'm creating my own GUI Api. All the Widgets are in a container which has add and remove functions. The widgets derive from a base widget class. Here is where I'm unsure. I would ideally like a flow like this: user creates a (desired widget deriving from base class) pointer, the container allocates and manages resources...

Readers/writers and decoupled persistence of derived classes

I'm refactoring a bunch of old code. My primary objective is to decouple the behavior from the database. The current implementation accesses the database directly which makes it hard to test and do things like implement caching layers etc... Up until this point I've been using a combination of dependency inversion and readers/writers ...

Are there any implementations of STL that are not messy and can actually be read?

Possible Duplicate: Is there a readable implementation of the STL? I've been trying to grok the source of the STL and frankly after looking at multiple implementations, I'm left shaking my head. The sheer verbosity of the code is breathtaking. No, not the complexity of the concepts, I mean the way it was implemented, the layer...

AST for any arbitrary programming language or IR

Hi All, Is it possible to create an AST for any arbitrary programming language or IR using C or C++ alone (without the help of tools like YACC and LEX )? If so, how to implement the lexical and syntactic analysis ? If not, what are the tools that have to augmented to C or C++ to successfully create an AST ? Hope I made my doubt clear...

Game File Archive Format

I want to create a single data file that holds all the data that my game will need, and I want it to be compressed. I looked into tar and gzip, but I downloaded their sources and I don't know where to begin. Can somebody give me some pointers to how I can use these? ...

Trouble with char* and char** (C --> C++)

Okay, I am trying to integrate some C code into a C++ project, and have run into a few problems. I will detail the first one here. I keep running into this error: error: cannot convert 'char*' to 'char**' in assignment| here is the offending code (with the breakpoint marked): char** space_getFactionPlanet( int *nplanets, int *faction...

Iterate over items in Boost Property Tree

I'm using boost property tree to store configuration data for my application. In the configuration file I have an item named that looks like this. I'm wondering how I can iterate over the ServerList. ServerList { server1 127.0.0.1:5000 server2 example.com } By the way the solution provided here, didn't seem to work for me: http...

Which tech to use for a server-side repository of files for a desktop C++ application to pull from?

I'm writing a cross-platform application in C++ (with wxWidgets lib), which currently references a server-side MySQL database which contains information (including target file name) of a very large number of files. Currently I am doing this by opening a direct SQL connection with each client (with thousands of users, this is not very eff...

C++ CORBA (ACE/TAO) questions

Guys, Im using ACE TAO as the CORBA implementation. I would like to find out if anyone know of any options to set Maximum Message Size and Maximum number of Connections. omniORB has two options for these, giopMaxMsgSize and maxGIOPConnectionPerServer. Even though TAO has ORBMaxMessageSize and ORBLingerTimeout it causes my server to cr...

How can I read multiple bytes from a file at a time?

I want to read 8byte chunks from a binary file at a time till I reach end of the file. Why doesn't this code work? What are the alternatives? // read a file into memory #include <iostream> #include <fstream> using namespace std; int main () { long long int * buffer; ifstream is; is.open ("test.txt", ios::binary ); // allocat...

Replacing realloc (C --> C++)

In an earlier question, I asked about typecasting pointers, but was directed to the better solution of using the C++ allocation system instead of mallocs. (I am converting some C code to C++) However, I still have an issue with a similar function: I changed: tmp = malloc(sizeof(char*) * mtmp); --> tmp = new char*[mtmp]; and free(tm...

Seeing console output without console?

I'm making an application and would like to test the toString method I just made. I'm using Visual c++ 2008. Is there a way to see console output without having a console window? Such as in the Output panel? Thanks ...

Why does this reject an enum?

Why does this code fail? #include <algorithm> int main() { int a[10]; enum { a_size = sizeof a / sizeof *a }; std::fill(a, a + a_size, a_size); } G++ 4.1.2 and 4.4.3: In function 'int main()': Line 5: error: no matching function for call to 'fill(int [10], int*, main()::<anonymous enum>)' Is this code valid C++0x? ...

java vs C++ pass by reference

Hi, I am confused in the following: In C++ we can pass a parameter to a function by reference (having declared it as a pointer or reference variable) and if we modify it inside the function, the changes are reflected to the caller when the function returns. This is not happening in java and I am not sure I understand why. E.g. this is a...

Why SetMenuInfo doesn't work under Windows 7?

When I use SetMenuInfo to change background color of MenuBar it works under Windows XP,but doesn't work under Windows 7.What is the reason?How can I solve the problem? Thanks. ...

Error in try catch while converting VC6 to VS2008

When I opened a VC6 project in VS2008 and tried building it , initially I got the error: fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory error C2259: 'CException' : cannot instantiate abstract class error BK1506 : cannot open file '.\Debug\SClientDlg.sbr': No such file or directory ...

Which alternative in C++?

One of the things about programming is that there are several ways to achieve the same goal. During my time coding in C++ I have noticed the following variations in ways to implement certain common features. My question is what are the advantages/disadvantages of each, I understand for the most part how each of them work, but I would lik...

VTK : Generate meshes for contour data which have several curves in one contour?

Greetings all, I have stack of contours which generated using someother algorithm outside VTK. Each contour consists of several curves . Please refer to image at : As seen in the image, each curve has an ID to identify which level it is.(Curves in same level have identical color) Now I want to generate Meshes using "vtkVoxelContou...

Near and Far pointers

What is difference between our usual pointers(ones which we normally use), near pointers and far pointers and is there a practical usage for near and far pointers in present day C/C++ systems? Any practical scenario which necessiates use of these specific pointers and not other c,c++ semantics will be very helpful. ...