I have a std::map that I use to map values (field ID's) to a human readable string. This map is initialised once when my program starts before any other threads are started, and after that it is never modified again. Right now, I give every thread its own copy of this (rather large) map but this is obviously inefficient use of memory and...
Suppose I run an application, after some time this app will get closed by user. Is it possible to find out when the program exits? Can I get it's process id when I run that application?
...
I am having a function:
int getparam(char *gotstring)
and i am passing the a string argument to it i.e., a string
for eg:
char *sendstring="benjamin"
instead of teh above declaration can i use
int getparam(char gotstring[])
which one is better. and if i have to use int getparam(char gotstring[]) what are all the other changes...
I am writing a cross-platform application that needs to inspect and manipulate Windows-paths.
Specifically, for the particular problem I am having now, I need to know if a path is absolute or relative.
The current code uses boost::filesystem::path which of course works like a charm on Windows:
boost::filesystem::path the_path(the_path...
How can I cast a boost::shared_array<char> to boost::shared_array<const char>?
...
Hi all.
We have a plugin system here, written in c++. Now that this has to have an ability to upgrade plugins(which are COM) we need to unload the plugin, install the plugin and then load it again. Now the problem is that this has to happen without closing an app. c++ COM dlls get unloaded pretty good but .NET ones not. Here's the sample...
I've got code I've been working with to load and convert SDL_Surfaces to OpenGL textures, however I've realized that they only work with RGB(A) surfaces. I need to extend the support onto indexed mode images (with or without transparency).
Initially, I was looking into ::SDL_SetColorKey(), however it seems to only work with SDL blits. I...
After reading C++ compile-time string hashing with Boost.MPL, and considering a problem I have, the following came to my mind.
I have the base class:
template<class Command>
class Base {
typedef Command CommandType;
}
It is supposed to be a utility base class for the Commands classes, so they don't need to typedef and declare some ...
I am trying to perform a less-than-32bit read over the PCI bus to a VME-bridge chip (Tundra Universe II), which will then go onto the VME bus and picked up by the target.
The target VME application only accepts D32 (a data width read of 32bits) and will ignore anything else.
If I use bit field structure mapped over a VME window (nmap'd...
I am in search of an upgradeable read write lock for win32 with the behaviour of pthreads rwlock, where a read lock can be up- and downgraded.
What I want:
pthread_rwlock_rdlock( &lock );
...read...
if( some condition ) {
pthread_rwlock_wrlock( &lock );
...write...
pthread_rwlock_unlock( &lock );
}
...read...
pthread_rwlock...
Hi
I'm developing a game which is based around the user controlling a ball which moves between areas on the screen. The 'map' for the screen is defined in the file ThreeDCubeGame.cpp:
char m_acMapData[MAP_WIDTH][MAP_HEIGHT];
The ThreeDCubeGame.cpp handles most of the stuff to do with the map, but the player (and keyboard input) is co...
The problem is to derive a formula for determining number of digits a given decimal number could have in a given base.
For example: The decimal number 100006 can be represented by 17,11,9,8,7,6,8 digits in bases 2,3,4,5,6,7,8 respectively.
Well the formula I derived so far is like this : (log10(num) /log10(base)) + 1.
in C/C++ I use...
In the following two versions of switch case, I am wondering which version is efficient.
1:
string* convertToString(int i)
{
switch(i)
{
case 1:
return new string("one");
case 2:
return new string("two");
case 3:
return new string("three");
.
.
default:
return new...
Hello all
Well, I've been going through my personal hell these days
I am having some trouble decrypting a message that was encrypted using
RSA and I'm always failing with a "RSA/OAEP-MGF1(SHA-1): invalid
ciphertext"
I have a private key encoded in base64 and I load it:
RSA::PrivateKey private_key;
StringSource file_pk(PK,tru...
Hi,
I want to ensure that my C++ class is never instantiated before main() is entered. Is there any way to achieve this?
--
Some clarification:
I am writing an embedded application. My class must be static (reside in the BSS), but at instantiation it requires some resources that aren't available before certain things has been initial...
Hi there
I am trying to integrate CUDA and openCV in a project. Problem is openCV won't compile when NVCC is used, while a normal c++ project compiles just fine. This seems odd to me, as I thought NVCC passed all host code to the c/c++ compiler, in this case the visual studio compiler.
The errors I get are?
c:\opencv2.0\include\open...
Some code I am working on uses COleDataSource::CacheGlobalData, passing as CF_TEXT an HGLOBAL pointing to some memory allocated for the text. I want to also add a numeric value, so ythe drop-target can access either the text or numeric values.
How can this easily be done? Can a 2nd CacheGlobalData call be made with a different CF_ value...
This question seems like it might be somewhat common, but I didn't find anything when scowering StackOverflow or the interwebs.
I came across a method in a C++ class that takes a list of (for example) Parent objects. For this example, assume that there are two classes that derive from Parent: Child1 and Child2.
For each object in the...
I'm looking at this, where m_Rows is a CAtlList:
void CData::RemoveAll()
{
size_t cItems = m_Rows.GetCount();
POSITION Pos = m_Rows.GetHeadPosition();
while(Pos != 0)
{
CItem* pItem = m_Rows.GetAt(Pos);
if (pItem != 0)
delete pItem;
POSITION RemoveablePos = Pos;
pItem = m_Ro...
The following code gives me a segmentation fault when run on a 2Gb machine, but works on a 4GB machine.
int main()
{
int c[1000000];
cout << "done\n";
return 0;
}
The size of the array is just 4Mb. Is there a limit on the size of an array that can be used in c++?
...