c++

Mutual exclusion (in static library )

I have a static library to access a Database. It has a function readMaximum(). readMaximum() reads a maximum value from DB. This function is thread safe (using mutex). But problem is : There are two processes A.exe and B.exe; both are compiled with the static library. Is there any way where I can implement mutual exclusion between p...

Variable Arguement With Class Reference As 1st Parameter

I have the following code : #include <cstdarg> #include <iostream> using namespace std; class a { }; void fun1(a& aa, ...) { va_list argp; va_start(argp, aa); char *p = 0; while ((p = va_arg(argp, char *)) != 0) { cout << p << endl; } va_end(argp); } void fun2(char *aa, ...) { va_list argp; va...

C++ Version For Java String.replaceAll

Java String.replaceAll comes very handy. Has anyone encounter similar library in C++ (Even without regular expression match, but with exact match is OK) ...

C++ expression evaluation order

i ran into a curious problem regarding evaluation of expressions: reference operator()(size_type i, size_type j) { return by_index(i, j, index)(i, j); // return matrix index reference with changed i, j } matrix& by_index(size_type &i, size_type &j, index_vector &index) { size_type a = position(i, index); // find position of i using...

Programmatically assign new letter to existing drive with C++

I want to change a drive letter. For example, I can use diskpart to assign a new letter to a drive (a USB disk or a new hard disk). How can I implement it in C/C++? ...

Is the following C++ code equiv? (in a smart pointer implementation)

Code 1: template<class T> const PtrInterface<T>* PtrInterface<T>::newRef() const { PtrInterface<T>* me = (PtrInterface<T>*) this; ++me->references_; //++this->references_; return this; } Code 2: template<class T> const PtrInterface<T>* PtrInterface<T>::newRef() const { //PtrInterface<T>* me = (PtrInterface<T>*) this; //+...

ROUNDUP? what does it do? in C++

Can someone explain to me what this does? #define ROUNDUP(n,width) (((n) + (width) - 1) & ~unsigned((width) - 1)) ...

useful open source libraries/projects on Windows

Which open-source projects do you feel C/C++ Windows developers should be aware of? Boost Libraries: generic library (smart pointers, command line parsing, threads, formatting, etc) Postgresql: full-feature SQL database. MediaInfo: provides information about audio/video files. ...

cant get ifstream to work in XCode

No matter what I try, I cant get the following code to work correctly. ifstream inFile; inFile.open("sampleplanet"); cout << (inFile.good()); //prints a 1 int levelLW = 0; int numLevels = 0; inFile >> levelLW >> numLevels; cout << (inFile.good()); //prints a 0 at the first cout << (inFile.good());, it prints a 1 and at the second a 0....

Inverse of strftime()

Possible Duplicate: Convert a string to a date in C++ I have a date/time string in a standardized format (RFC 1123) that I would like to convert to a unix timestamp to compare it with another date/time. I can convert a timestamp to a string by using strftime with the magic format string "%a,%d %b %Y %H:%M:%S GMT" The pro...

How to make a Web Browser toolbar ?

How do I make a Web Browser toolbar in C++. in dev-C++ for I.E with no addon libraries? ...

Does anyone have a FileSystemWatcher-like class in C++/WinAPI?

I need a .Net's FileSystemWatcher analog in raw C++/WinAPI. I almost started to code one myself using FindFirstChangeNotification/FindNextChangeNotification, but then it occurred to me that I am probably not the first one who needs this and maybe someone will be willing to share. Ideally what I need is a class which can be used as follo...

Static code analysis tools

Whether JavaSript, C# or C++ main problem i face while reading the code is which function is called by which function. This problem is big when dealing with BIG code. Is there any static code analysis tool/technique/plugins using which a graphical representation of the code can be generated(something like below) so that reading/analyzing...

Fastest cross-platform A* implementation?

With so many implementations available, what is the fastest executing (least CPU intensive, smallest binary), cross-platform (Linux, Mac, Windows, iPhone) A* implementation for C++ using a small grid? Implementations Google returns: http://www.heyes-jones.com/astar.html (Most links on that site are dead.) http://www.grinninglizard.co...

using generic methods?

what is the benefits and disadvantages of using generic methods( in compile time and run time, in performance and memory)? ...

Flat File Database in C++, Is it possible?

Flat File Database in C++, Is it possible? ...

How to store a sequence of timestamped data?

I have an application that need to store a sequence of voltage data, each entry is something like a pair {time, voltage} the time is not necessarily continuous, if the voltage doesn't move, I will not have any reading. The problem is that i also need to have a function that lookup timestamp, like, getVoltageOfTimestamp(float2second(922...

C++ libraries for probabilistic scientific calculations

What are the various open source and commercial C++ libraries for probabilistic scientific calculations ? I'm mainly interested in Bayesian learning ; something similar to the Bayes Net toolbox in Matlab ...

Credential manager for Vista/Windows 7

I have Credential manager implemented in VC++ which captures credentials during login process. It works well in XP/Vista/Windows 7 32 bit env. But is not working in 64 bit. Any idea ? Thanks in advance for any help ...

Problem using MIDI streams in Windows

Hello, I'm writing a Windows program using C++ and the Windows API, and, am trying to queue MIDI messages in a MIDI stream, but am receiving a strange error when I try to do so. If I use midiOutShortMsg to send a non-queued MIDI message to the stream, it works correctly. However, midiStreamOut always returns error code 68, which is #def...