c++

problem with quadTree & union

hi! i have the following quadtree-like structure, in which each cell can either be a inner node or a leaf. if it is a leaf, it can store a color. if it is a inner node, it stores pointers to four children (which can be either leaf or inner node): class RenderBucketCell{ public: RenderBucketCell(); RenderBucketCell(float R, floa...

Is it possible to use a RA-iterator out of range?

Consider the following code: typedef std::vector<int> cont_t; // Any container with RA-iterators typedef cont_t::const_iterator citer_t; // Random access iterator cont_t v(100); const int start = 15; // start > 0. citer_t it = v.begin() - start; // Do not use *it int a1 = 20, b1 = 30; // a1, b1 >= start int a2 = 30, b2 = 40; // a2, b2...

shared_ptr vs scoped_ptr

scoped_ptr is not copy able and is being deleted out of the scope. So it is kind of restricted shared_ptr. So seems besides the cases when you really need to restrict the copy operation shared_ptr is better to use. Because sometimes you don’t know you need to create a copy of your object or no. So the question is: besides the cases menti...

How do I control the text input panel programmatically (tabtip.exe) in windows vista/7.

Hi, I'm adapting an application for touch screen interface and we're want to use the tablet text input panel included in windows vista/7, specifically its keyboard. I want to show and hide it as appropriate for my app. Basically I want ShowKeyboad() and HideKeyboard() functions. What's the best way to control this. I looked at the ITex...

Is it difficult to port C++ to C++/CLI?

I suppose you cannot simply compile a C++ application with a C++/CLI compiler. I am wondering if it would be difficult. Has anybody tried this, and if so: were there a lot of modifications needed? ...

Google Protocol Buffer repeated field C++

I have the below protocol buffer. Note that StockStatic is a repeated field. message ServiceResponse { enum Type { REQUEST_FAILED = 1; STOCK_STATIC_SNAPSHOT = 2; } message StockStaticSnapshot { repeated StockStatic stock_static = 1; } required Type type = 1; optional StockStati...

Pointers to members in swig (or Boost::Python)

Hello, I made some bindings from my C++ app for python. The problem is that I use pointers to members (It's for computing shortest path and giving the property to minimize as parameter). This is the C++ signature: std::vector<Path> martins(int start, int dest, MultimodalGraph & g, float Edge::*) This is what I did (from what I unde...

boost to_upper function of string_algo doesn't take into account the locale

I have a problem with the functions in the string_algo package. Consider this piece of code: #include <boost/algorithm/string.hpp> int main() { try{ string s = "meißen"; locale l("de_DE.UTF-8"); to_upper(s, l); cout << s << endl; catch(std::runtime_error& e){ cerr << e.what() << endl; } try{ ...

How to connect to MySQL Database from eMbedded Visual C++

How can I connect to a remote Mysql database, from Cpp code using Microsoft eMbedded Visual C++ (which is configured for a special board running WindowsCE)? I have downloaded the source files for Mysql C and C++ Connector/APIs but; their 'make' or installation process is pretty complicated and valid only for Visual Studio. ...

Refactoring function pointers to some form of templating

Bear with me as I dump the following simplified code: (I will describe the problem below.) class CMyClass { ... private: HRESULT ReadAlpha(PROPVARIANT* pPropVariant, SomeLib::Base *b); HRESULT ReadBeta(PROPVARIANT* pPropVariant, SomeLib::Base *b); typedef HRESULT (CMyClass::*ReadSignature)(PROPVARIANT* pPropVariant, SomeLib::Bas...

how to implement objects for toy language ?

I am trying to make a toy language in c++. I have used boost spirit for the grammar, and hopefully for parser/lexer. The idea is a toy language where 'everything is an object' like javascript and some implementation of prototype based inheritance. I want to know how to implement the 'object' type for the language in c++. I saw source cod...

What database APIs in C++ and C# are equivalent to JDBC in Java?

I have not done database programming in C++ and C# before, but did some in Java. Now I am asked to figure out the options to do it in C# or C++ (not sure which one yet). We may use the MySQL RDBMS. I searched online and found .NET SQL Data Provider, OleDB and ODBC. What other APIs exist? What's your recommendation? Do I need to buy s...

Grabbing memory from another process

in Windows, lets say I have used DLL Injection to get into another process. I have also done some screencaptures of the memory on the process I have injected into and know the location of the data I want to pull out. Lets say there is data in the other process at 0xaaaaaaaa that contains a certain value. How do I grab this value from tha...

Why doesn't C++ reimplement C standard functions with C++ elements/style?

For a specific example,consider atoi(const std::string& ).I am very frustrated about this,since we programmers would need to use it so much. More general question is why does not C++ standard library reimplement the standard C libraries with C++ string,C++ vector or other C++ standard element rather than to preserve the old C standard ...

AVL Tree Code - I don't understand

void insert( const Comparable & x, AvlNode * & t ) { if( t == NULL ) t = new AvlNode( x, NULL, NULL ); else if( x < t->element ) { insert( x, t->left ); if( height( t->left ) - height( t->right ) == 2 ) if( x < t->left->element ) rotateWithRig...

Effect of exit function in Windows Service Programs

I have a program that is a windows service. It is started by StartServiceCtrlDispatcher function. It's network server that accepts user's inputs as command for controlling purposes. Now, I want it to have the ability to be shutdown by users, i.e. when user type a "quit" command, the service will stop. (Don't worry about how the service c...

Efficient passing of std::vector

When a C++ function accepts an std::vector argument, the usual pattern is to pass it by const reference, such as: int sum2(const std::vector<int> &v) { int s = 0; for(size_t i = 0; i < v.size(); i++) s += fn(v[i]); return s; } I believe that this code results in double dereferencing when the vector elements are accessed, beca...

dhcp client on linux, port or use ?

Hi, On linux platform, I want to have dhcp client. port any open source client to my app (which seems to be a bit time consuming)? or communicate with the standalone client app via Signals? or anyone knows any dhcp client library? thanks for any advice. ...

Explain the Need for Mutexes in Locales, Please

Reading the question Why doesn’t C++ STL support atoi(const string& ) like functions?, I encountered a comment which warned that GCC (at least) has a bug that can slow down multi-threaded applications which use ostringstream frequently. This is apparently due to a mutex 'needed' by the C++ locale machinery. Given my recent interest in g...

Ensuring certain private functions can only be called from a locked state

Say I have a class A: class A { public: A(); void fetch_data() { return 1; } void write_x_data() { // lock this instance of A private_function1_which_assumes_locked(); private_function2_which_assumes_locked(); // unlock this instance of A } void write_y_data() { // lock this instance of A pr...