c++

Processing Escapes using the Spirit Parser Framework

Hello :) I'm trying to parse a string similar to the following using a spirit parser: <junk> -somearg#this is a string with a literal ## in it# <junk> What I'm looking for is a grammar which can extract the portion inside the # marks, but is smart to skip over the double ## in the middle, which is an escape meaning a literal #. This ...

Setting up windows for C++

To quote the FAQ, 'No question is [...] too "newbie"' What is the best way to set up an Windows system (vista, if that matters) to work with C++? Preferably with a nice IDE, easy compiling of software (support for make files, etc.), but suitable for a beginner. I would quite like the IDE to use a relatively portable format, such as ma...

Does there exist a "wiki" for editing doxygen comments?

I'm working on a fairly big open source RTS game engine (Spring). I recently added a bunch of new C++ functions callable by Lua, and am wondering how to best document them, and at the same time also stimulate people to write/update documentation for a lot of existing Lua call-outs. So I figured it may be nice if I could write the docume...

Why does "delete node;" crash my C++ linked list application?

The jDeleteAfter method of my linked list class is supposed to delete the node immediately following the node passed as an argument. If it is doing that, I do not know, but it is abruptly closing my console application when "delete tlp;" (Temp List Pointer) gets read. My instructor, the users of a programming forum and I have yet to de...

C++ atomic operations for lock-free structures

I'm implementing a lock-free mechanism using atomic (double) compare and swap instructions e.g. cmpxchg16b I'm currently writing this in assembly and then linking it in. However, I wondered if there was a way of getting the compiler to do this for me automatically? e.g. surround code block with 'atomically' and have it go figure it out...

Returning different data type depending on the data (C++)

Is there anyway to do something like this? (correct pointer datatype) returnPointer(void* ptr, int depth) { if(depth == 8) return (uint8*)ptr; else if (depth == 16) return (uint16*)ptr; else return (uint32*)ptr; } Thanks ...

How do I make my program watch for file modification in C++?

There are a lot of programs, Visual Studio for instance, that can detect when an outside program modifies a file and then reload the file if the user wants chooses. Is there a relatively easy way to do this sort of thing in C++ (doesn't necessarily have to be platform independent)? ...

How do you make a prototype of a function with parameters that have default values?

A have a function with a prototype of: void arryprnt(int[], string, int, string, string); And a definition of: void arryprnt(int[] a, string intro, int len, string sep=", ", string end=".") { // stuff } And I'm calling it like this: arryprnt(jimmy, "PSEUDOJIMMY: ", 15); ...When I make that call to arryprnt, I get a compiler erro...

Template for cleaning up on vector destruction - how to?

I am trying to implement a template which would allow to create a class derived from vector<> such that on deletion the element of the vector are deleted. The below snippet represents an attempt to do so: include <vector> using namespace std; template <class P> class TidyVector : public vector<P> { public: ~TidyVector() { while...

linking c++ sources in iPhone project

I have a single cpp file added to my iPhone project with a .cpp extension, but I'm seeing errors when linking like: operator new[](unsigned long)", referenced from: ___gxx_personality_sj0", referenced from: I thought as long as I named the cpp files with .cpp or .mm it would do the right thing, do I need to add some linker fla...

Which is more readable (C++ = )

int valueToWrite = 0xFFFFFFFF; static char buffer2[256]; int* writePosition = (int* ) &buffer2[5]; *writePosition = valueToWrite; //OR * ((int*) &buffer2[10] ) = valueToWrite; Now, I ask you guys which one do you find more readable. The 2 step technique involving a temporary variable or the one step technique? Do not worry about opti...

C/C++ USB drive event

Regarding the Windows platform, is their an event I can look for to tell when a USB drive or any type of portable media us plugged in? ...

C++ way of dependency injection - Templates or virtual methods?

I wonder what is the C++ way of using dependency injection? Is that using templates or polymorphic classes? Consider the following code, class AbstractReader { public: virtual void Read() = 0; }; class XMLReader : public AbstractReader { public: void Read() { std::cout << "Reading with a XML reader" << std::endl; } }; class TextF...

finding a function name and counting its LOC

So you know off the bat, this is a project I've been assigned. I'm not looking for an answer in code, but more a direction. What I've been told to do is go through a file and count the actual lines of code while at the same time recording the function names and individual lines of code for the functions. The problem I am having is dete...

gaming with c++ or c# ?

What is the best language for programming a game project and why? Why is the game programing world dominated by c++? ...

fatal error C1034: windows.h: no include path set

OS Windows Vista Ultimate trying to run a program called minimal.c when i type at command line C:\Users\nathan\Desktop>cl minimal.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. minimal.c minimal.c(5) : fatal error C1034: windows.h: no incl...

Reading from a socket 1 byte a time vs reading in large chunk

What's the difference - performance-wise - between reading from a socket 1 byte a time vs reading in large chunk? I have a C++ application that needs to pull pages from a web server and parse the received page line by line. Currently, I'm reading 1 byte at a time until I encounter a CRLF or the max of 1024 bytes is reached. If reading ...

std::string comparison

I need to check whether an std:string begins with "xyz". How do I do it without searching through the whole string or creating temporary strings with substr(). Thanks. ...

What is more efficient a switch case or an std::map

I'm thinking about the tokenizer here. Each token calls a different function inside the parser. What is more efficient: A map of std::functions/boost::functions A switch case I thank everyone in advance for their answer. ...

Default HTML style for controls in the Qt library

This is a question about Qt library, not about Web design. For QLabel and other controls I can set HTML text, for example "<h3>Some Text</h3>". The question is: where is the default HTML style is defined? How can I find out what a font would be used for <h3> tag? The next question: can I change the default HTML style? Edit: I want to ...