c++

Distributed Processing: C++ equivalent of JTA

I'm developing a mission-critical solution where data integrity is paramount and performance a close second. If data gets stuffed up, it's gonna be cata$trophic. So, I'm looking for the C/C++ version of JTA (Java Transaction API). Does anyone know of any C or C++ libraries that supports distributed transactions? And yes, I've googled it...

Does a memory leak at unload of a DLL cause a leak in the host process?

Consider this case: dll = LoadDLL() dll->do() ... void do() { char *a = malloc(1024); } ... UnloadDLL(dll); At this point, will the 1k allocated in the call to malloc() be available to the host process again? The DLL is statically linking to the CRT. ...

What is the best way to obtain an index into a vector when using Iterators to loop over it.

When iterating over elements of a vector it is preferred to use iterators instead of an index (see Why use iterators instead of array indices?). std::vector<T> vec; std::vector<T>::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { // do work } However, it can be necessary to use the index in the body of the loop. Whic...

How to read file content into istringstream?

In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information. My question is, which is the best way to read this information and "import it" into the string stream? A problem with this approach (see bellow) is that...

How to achieve const-correctness in C#?

Hi all, I have programmed C++ for many years but am fairly new to C#. While learning C# I found that the use of the const keyword is much more limited than in C++. AFAIK, there is, for example, no way to declare arguments to a function const. I feel uncomfortable with the idea that I may make inadvertent changes to my function argument...

Show a ContextMenuStrip without it showing in the taskbar

I have found that when I execute the show() method for a contextmenustrip (a right click menu), if the position is outside that of the form it belongs to, it shows up on the taskbar also. I am trying to create a right click menu for when clicking on the notifyicon, but as the menu hovers above the system tray and not inside the form (as...

How to disable #pragma warnings?

While developing a C++ application, I had to use a 3rd party library which produced a huge amount of warnings related with a harmless #pragma directive being used. ../File.hpp:1: warning: ignoring #pragma ident In file included from ../File2.hpp:47, from ../File3.hpp:57, from File4.h:49, Is it possibl...

Why should I ever use inline code?

I'm a C/C++ developer, and here are a couple of questions that always baffled me. Is there a big difference between "regular" code and inline code? Which is the main difference? Is inline code simply a "form" of macros? What kind of tradeoff must be done when choosing to inline your code? Thanks ...

Is there a typical state machine implementation pattern?

We need to implement a simple state machine in C. Is a standard switch statement the best way to go? We have a current state (state) and a trigger for the transition. switch(state) { case STATE_1: state = DoState1(transition); break; case STATE_2: state = DoState2(transition); break; } ... DoState2(int transitio...

How do you handle strings in C++?

Which is your favorite way to go with strings in C++? A C-style array of chars? Or wchar_t? CString, std::basic_string, std::string, BSTR or CComBSTR? Certainly each of these has its own area of application, but anyway, which is your favorite and why? ...

Hashtable in C++?

I usually use C++ STL map whenever I need to store some data associated with a specific type of value (a key value - e.g. a string or other object). The STL map implementation is based on trees which provides better performance (O(log n)) than the standard array or STL vector. My questions is, do you know of any C++ "standard" hashtable...

Determine SLOC and complexity of C# and C++ from .NET

I have been using SourceMonitor on my project for a couple of years to keep records of source-code complexity and basic SLOC (including comments) for C# and C++ components. These are used for external reporting to our customer, so I'm not in a position to argue their merits or lack of. I've been working on a repository analysis tool wh...

c++ boost lambda libraries

What might be the best way to start programming using boost lambda libraries. ...

C/C++ strip chart

Just a quick question. I'm looking for a simple strip chart (aka. graphing) control similar to the windows task manager 'Performance' view. And have found a few, but they all rely on MFC or .NET :( Am hoping that someone here might have or know where to get a simple strip chart Win32 control that is not MFC. Thanks. ...

Sharing GDI handles between processes in Windows CE 6.0

Hello, I know that GDI handles are unique and process specific in 'Big Windows' but do they work the same way in Windows CE 6.0? For example: I've got a font management service that several other services and applications will be using. This service has a list of valid fonts and configurations for printing and displaying; CreateFontInd...

How Do You Write Code That Is Safe for UTF-8?

We have a set of applications that were developed for the ASCII character set. Now, we're trying to install it in Iceland, and are running into problems where the Icelandic characters are getting screwed up. We are working through our issues, but I was wondering: Is there a good "guide" out there for writing C++ code that is designed ...

Conferences/Symposiums/Courses in Britain

I see lots of advertisements for cool looking conferences based on the latest web technologies on tech-ey sites all the time, but they all seem to be based in the USA - which is too far away to justify the expense :( So, does anyone know of some cool/fun/interesting events for web developers occurring in the UK? Or any sites that would l...

How do I know I reached a file's maximum size when using ofstream?

While writing a file using ofstream, how do I know when the file's size has reached the OS' maximum file size - more specifically linux's maximum file size - ?? ...

c++ exception : throwing std::string

Hello, I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a std::string pointer? Here's what I was looking forward to doing: void Foo::Bar(){ if(!QueryPerformanceTimer(&m_baz)){ throw new std::String("it's the end of the world!"); } } void Foo:Caller(){ try{...

Returning a const reference to an object instead of a copy

Whilst refactoring some code I came across some getter methods that returns a std::string. Something like this for example: class foo { private: std::string name_; public: std::string name() { return name_; } }; Surely the getter would be better returning a const std::string&? The current method is returning ...