c++

Editing a text buffer...

Ok, this is a bit of a cheeky question. I want to build a simple text editor (using my own text mode screen handling). I just want a good example of data structures that can be used to represent the text buffer, and some simple examples of char/text insertion/deletion. I can handle all the rest of the code myself (file i/o, console i/o e...

search 25 000 words within a text

I need to find occurrences of ~ 25 000 words within a text. What is the most suitable algorithm/library for this purpose? target language is C++ ...

Unnamed/anonymous namespaces vs. static functions

A little-used feature of C++ is the ability to create unnamed (anonymous) namespaces, like so: namespace { int cannotAccessOutsideThisFile() { ... } } // namespace You would think that such a feature would be useless -- since you can't specify the name of the namespace, it's impossible to access anything within it from outside. Bu...

Encode/Decode URLs in C++

Does anyone know of any good C++ code that does this ...

Control for getting hotkeys like tab and space

I have a dialog box that allows users to set hotkeys for use in a 3d program on windows. I'm using CHotKeyCtrl, which is pretty good, but doesn't handle some keys that the users would like to use - specifically, tab and space. The hotkey handling is smart enough to be able to fire on those keys, I just need a UI to let them be set. A...

Pre-setting locations for looking for source files in Visual C++ 6.0

Due to the legacy nature of some of our code, we're still using Microsoft Visual 6.0 (SP6). When I attach to a running process to debug it for the first time, it has no knowledge of where the source files are located when I break into the process. It therefore asks me to navigate to the appropriate directory in my source tree, given a so...

Capturing video out of an OpenGL window in Windows

I am supposed to provide my users a really simple way of capturing video clips out of my OpenGL application's main window. I am thinking of adding buttons and/or keyboard shortcuts for starting and stopping the capture; when starting, I could ask for a filename and other options, if any. It has to run in Windows (XP/Vista), but I also wo...

Is there a way to handle a variable number of parameters in a template class?

I have a set of callback classes that I use for handling callbacks with variable numbers of parameters. Right now I have about 6 different instances of it to handle differing numbers of arguments. Is there a way to make one instance than can handle a variable number of arguments?? Ultimately I would love to have each parameter be a POD t...

Priority of C++ operators "&" and "->"

Given the following: &row->count Would &(row->count) be evaluated or (&row)->count be evaluated in C++? EDIT: Here's a great link for C++ precedence. ...

Windows API commctrl.h using application doesn't work on machines without the Platform SDK

I have written something that uses the following includes: #include <math.h> #include <time.h> #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <commctrl.h> This code works fine on 2 machines with the Platform SDK installed, but doesn't run (neither debug nor release versions) on clean installs of windows (VMs of c...

Boost: Fire and forget asynchronous function call?

I would like invoke a function call in a one shot manner. What's the best way to do this in Boost / C++? I would like to pass it two parameters and do not need a result. ...

How to alter a float by its smallest increment (or close to it)?

I have a double value f and would like a way to nudge it very slightly larger (or smaller) to get a new value that will be as close as possible to the original but still strictly greater than (or less than) the original. It doesn't have to be close down to the last bit—it's more important that whatever change I make is guaranteed to pro...

Starting Graphics & Games Programming (Java and maybe C++)

I've always had an interest in creating my own games, and now at university I have the opportunity to create some 2D and 3D games using Java and C++ for those who are that way inclined. I've never really programmed a game before, let alone graphics, so I'm completely new to the area. After a quick trip to the library today I came across...

Best C++ Resource

Java has its own (self-documented) Javadoc, PHP has PHP.net, all the MS documenation can be found at the MS Developers Network, but whenever it comes to throwing together some C++ my first stop is always Google. To all the C++ developers out there, what's your one-stop-shop? ...

Launch web page from my application in Linux

I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build. Right now the Linux version is hardcoded for Firefox in a specific directory and runs a new instance of it each time and doesn't show...

AI Applications in C++: How costly are virtual functions? What are the possible optimizations?

In an AI application I am writing in C++, there is not much numerical computation there are lot of structures for which run-time polymorphism is needed very often, several polymorphic structures interact during computation In such a situation, are there any optimization techniques? While I won't care to optimize the application ...

What is the equivalent of the C++ Pair<L,R> in Java?

Is there a good reason why there is no Pair in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own. It seems that 1.6 is providing something similar (AbstractMap.SimpleEntry), but this looks quite convoluted. ...

Does setbuf() affect cout?

Yet again, my teacher was unable to answer my question. I knew who may be able to... So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put setbuf( stdout , NULL ); at the top of main() in order to get an unbuffered output, thu...

Using .reset() to free a boost::shared_ptr with sole ownership

I'm storing an object (TTF_Font) in a shared_ptr that is provided to me from a third-party API. I cannot use new or delete on the object, so the shared_ptr is also provided a "freeing" functor. // Functor struct CloseFont { void operator()(TTF_Font* font) const { if(font != NULL) { TTF_CloseFont(font); ...

What Does It Mean For a C++ Function To Be Inline?

See title: what does it mean for a C++ function to be inline? ...