c++

C++ in-memory Key-Value stores

I'm looking for suggestions regarding in-memory key-value store engines or libraries, that have C++ interfaces or that are written in C++. I'm looking for solutions that can scale without any problems to about 100mill key-value pairs and that are compatible/compilable on linux and win32/64 ...

Construct OpenCV element type in runtime

In OpenCV, when I need to create a cv::Mat, I will need to do something along the line of cv::Mat new_mat(width, height, CV_32FC3) What happens if I only know that I need the elements to be either float or double + whether I need 1/2/3 channels in runtime? In other words, given the element type (float) and number of channel (int), ho...

how can a pixel in a bitmap can be deleted?

i m decreasing the resolution of a bitmap. i found a method on a site which is as follows Average the values of all surrounding pixels, store that value in the choosen pixel location, then delete all the surrounding pixels.so a 4*6 matrix becomes a 4 x 3 matrix. i am accessing pixels by this code for(int y = 0; y < bmp.bmHeight; y++) ...

What is an efficient way to wrap HWNDs in objects in C++?

I have been working with C++ and Win32 (non MFC/ATL) I am playing around with writing my own class library to wrap certain Win32 objects (HWNDs in particular). When it comes to creating windows, I find the "RegisterClassEx / CreateWindowEx" method very awkward. This design makes it hard to write simple class wrappers (one must resort t...

Inserting <string, function pointer> into map

I'm having trouble with inserting some value_pairs into a map. Here's the basic idea. // private typedef Foo* (*Bar)( const std::string &x, int y ); typedef std::map<std::string, Bar> myMap; template<class T> Foo* DoThing( const std::string &x, int y ) { return new T( x, y ); } myMap m_map; // some map insertion code m_map.insert( ...

non-copying istringstream

So istringstream copies the contents of a string when initialised, e.g string moo("one two three four"); istringstream iss(moo.c_str()); I was wondering if there's a way to make std::istringstream use the given c_str as its buffer without copying things. This way, it wont have to copy large bits of memory before passing the std::istri...

C/C++ equivalent to java Integer.toHexString

C/C++ equivalent to java Integer.toHexString. Porting some code from java to C/C++, does C have a build in function to Integer.toHexString in java? UPDATE: Heres is the exact code i'm trying to port: String downsize = Integer.toHexString(decimal); ...

need help in contrast stretching

i have found this formula and its description on a site l(x,y)=(l(x,y)-min)(no of intensity levels/(max-min)) + initial intensity level where, I( x,y ) represents the images, on the left side it represents the output image, while on the right side it represents the xth pixel in the yth column in the input image. In this equation the "...

Delete a Binary Tree with a Stack

I'm still working on my binary trees, and the insertion, lookup, maximum, minimum functions are all working great so far. So I want to do a deletion function next. I included a Stack which saves- ah hell, I'll just show the code: class Tree { private: int value_; Tree *root_; Tree *left_; Tree *right_; std::stack<Tr...

PyS60 vs Symbian C++

I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++. I want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Pyth...

How to detect SSL handshake with LSP?

Hi, how can i detect that application wants to establish ssl connection using LSP. I need to break that SSL handshake and detect the destination adress and port. Is that possible? I am using vc++. ...

How do I fit a variable sized char array in a struct?

I don't understand how the reallocation of memory for a struct allows me to insert a larger char array into my struct. Struct definition: typedef struct props { char northTexture[1]; char southTexture[1]; char eastTexture[1]; char westTexture[1]; char floorTexture[1]; char ceilingTexture[1]; } PROPDATA; exampl...

C++ multiple operator overloads for the same operator

I know I can answer this question easily for myself by generatin the code and see if it compiles. But since I couldn't find a similar question, I thought it's knowledge worth sharing. Say I am overloading the + operator for MyClass. Can I overload it multiple times. Different overload for different types. Like this: class MyClass{ ... ...

Thread Local Storage

When you allocate some TLS for thread A in a slot, can you then access that same slot from Thread B? Is it internally synchronized or how does that work? ...

Explanation of ambiguity in function overloading for this example in C++.

I'm reading Stroustrup's book, the section on overloading and related ambiguities. There's an example as follows: void f1(char); void f1(long); void k(int i) { f1(i); //ambiguous: f1(char) or f1(long) } As the comment states, the call is ambiguous. Why? The previous section in the book stated 5 rules based on matching formal...

Possible to add another enum item to an existing enum type

Hi all! I wonder, whether it is possible to add/append another item to an existing enum type (part of a framework)? Something like this: We have the enum type typedef enum { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCrossDissolve, UIModalTransitionStylePa...

Weird auto-initialization behavior

Hi! I learned that auto-variables aren't initialized to zero. So the following code will behave correctly and prints random numbers on the screen: #include <iostream> using std::cout; using std::endl; void doSomething() { int i; cout << i << endl; } int main() { doSomething(); } But why won't this snipped behave in the same w...

c++ get PID using system

im running a file using system, but i dont know how to get the pid of that process, does anybody know it? thnx! ...

Is it safe if a virtual function refers to variable in a derived class in C++?

When derived is cast back into base. By safe, I mean it works properly for known c++ compiler. It seems to be working for VIsual C++ 2008. E.g class zero { virtual int v()=0; } class a: public zero { public: int value; a(int vin) { value =vin; } int v() { return value; } } zero *e1= new a(3); cout <<...

How can I pass a variable from class element to class element? (C++)

My question might not be too correct... What I mean is: class MyClass { public: MyClass() { } virtual void Event() { } }; class FirstClass : public MyClass { string a; // I'm not even sure where to declare this... public: FirstClass() { } virtual void Event() { a = "Hello"; // ...