c++

which is the most efficient XML Parser for C++ ?

I need to write an application that fetches element name value (time-series data) pair from any xml source, be it file, web server, any other server. the application would consume the XML and take out values of interest, it has to be very very fast (lets say 50000 events/seconds or more) also the XML document size would be huge and frequ...

Example of overloading C++ extraction operator >> to parse data

I am looking for a good example of how to overload the stream input operator (operator>>) to parse some data with simple text formatting. I have read this tutorial but I would like to do something a bit more advanced. In my case I have fixed strings that I would like to check for (and ignore). Supposing the 2D point format from the link ...

best C++ book for interview?

what is the best C++ book to prepare a advanced C++ interview. I would like a book with very good summary on concepts and tricks asked in interviews. ...

How do you dynamically allocate a matrix?

How do you dynamically allocate a 2D matrix in C++? I have tried based on what I already know: #include <iostream> int main(){ int rows; int cols; int * arr; arr = new int[rows][cols]; } It works for one parameter, but now for two. What should I do? ...

Unicode Input Handling in Games

This is a C++ SDL OpenGL question. Hello, I have a game that requires me to allow players to chat with each other via network. All is well, except the part where players can type in Unicode input. So, the question can be split into two parts: When players type, how do I capture input? I have done this before via the game input handl...

[C++] How to solve the problem of global access?

Hi, I'm building an app, and I need the wisdom of the SO community on a design issue. In my application, there needs to be EXACTLY one instance of the class UiConnectionList, UiReader and UiNotifier. Now, I have figured two ways to do this: Method 1: Each file has a global instance of that class in the header file itself. Method 2:...

What is boost's shared_ptr(shared_ptr<Y> const & r, T * p) used for?

boost::shared_ptr has an unusual constructor template<class Y> shared_ptr(shared_ptr<Y> const & r, T * p); and I am a little puzzled as to what this would be useful for. Basically it shares ownership with r, but .get() will return p. not r.get()! This means you can do something like this: int main() { boost::shared_ptr<int> x(ne...

STL map onto itself?

I'd like to create a std::map that contains a std::vector of iterators into itself, to implement a simple adjacency list-based graph structure. However, the type declaration has me stumped: it would seem you need the entire map type definition to get the iterator type of said map, like so: map< int, Something >::iterator MyMap_it; /...

C++ Stack Implementation HWQuestion

Hey all! Having a little trouble with my stack. Im trying to print each element that i've pushed onto the stack. Starting with the stack ctor we know that we have a fixed size for the array. So I allocate the items struct object to hold just that much space: stack::stack(int capacity) { items = new item[capacity]; if ( items ==...

What is the best way to initialize an application?

What is the best way of initializing and terminating an application? The library needs to be initialized/terminated only once and can be used by any number of dlls. Is there any standard design to accomplish this? This initialization has to be the very first step. Is singleton is what I need here. Any number of dlls which are loaded...

Rundll32 load order problem

My product consists of two dlls (A.dll and B.dll for clarity), A.dll depends on B.dll. Both A and B dlls are in the same folder (say c:\app). At the same time old version of B.dll is in Windows\System32 folder. When I try to run following command from command prompt (current folder is c:\app): rundll32.exe "c:\app\A.dll",DoWork I recei...

Visual Studio 2005 C compiler problem when optimizing a switch statement

General Question which may be of interest to others: I ran into a, what I believe, C++-compiler optimization (Visual Studio 2005) problem with a switch statement. What I'd want to know is if there is any way to satisfy my curiosity and find out what the compiler is trying to but failing to do. Is there any log I can spend some time (pro...

How to read/redirect output of a dos command to a program variable in C/C++ ?

I want to run a dos command from my program for example "dir" command. I am doing it like, system("dir"); Is there any way to read the output of that command directly into a program variable? We can always redirect the output to a file and then read that file, by doing system("dir > command.out"); And then reading command.out fil...

C++ reference in constructor

I have a class whose constructor takes a const reference to a string. This string acts as the name of the object and therefore is needed throughout the lifetime of an instance of the class. Now imagine how one could use this class: class myclass { public: myclass(const std::string& _name) : name(_name) {} }; myclass* proc() { ...

How to set the system loudness programmatically (on OSX and Windows)

Hi All, I want to manipulate the system loudness (the global volume, or whatever it is called) from within my program. This might seem ridiculous, but I need to do some measurements, so I am interested in not only attenuating the sound via an internal loudness, but also amplify it, which is only possible using the system loudness. Since...

g++ external reference error

I have issue that is reproduced on g++. VC++ doesn't meet any problems. So I have 2 cpp files: 1.cpp: #include <string> #include <iostream> extern const std::string QWERTY; int main() { std::cout << QWERTY.c_str() << std::endl; } 2.cpp: #include <string> const std::string QWERTY("qwerty"); No magic, I just want place string...

Problem in Line Editor in Qt?

Hi all, I am trying to set the text of line editor in Qt on linux. It works for all but 2 line editors which for some strange reason don't display the text even when we set the text using mValueLineEdit->setText("Hello") I have debugged each and every line of code in my application but nothing fishy was found.I checked after setting ...

Automatically generate C++ file from header?

I have a bunch of C++ header files with various class and function declarations. So far, when I've been writing the C++ source file implementations of the declared classes and functions, I've been manually: Copying the declarations from the header file to the corresponding source file. Deleting "class classname {" and the matching "};"...

During which phase of building a binary is activation record defined ?

Is it during a pre-processing or compilation stage, say on gcc? Is it different on other compilers? ...

Thread safe C++ std::set that supports add, remove and iterators from multple threads

I'm looking for something similar to the CopyOnWriteSet in Java, a set that supports add, remove and some type of iterators from multiple threads. ...