c++

importing ofstream to sqlite db

Hi, Right now, in my c++ code, I am writing my ofstream to an output xls file. I also want to direct it to a sqlite database from my c++ code. Is there anyway for doing this? ...

Ensuring column visibility in wxListCtrl

I want wxListCtrl in report mode and I want to lock one or more columns such that when you scroll left and right those columns remain visible at all times. For example: | name | field1 | field2 | field3 |....| When scrolled to the left I want it to be like: | name | field3 | field 4 | ... | I can't find a way to get this function...

Getting Spaces to Play Nicely with C++ Input Streams

First consider this sample C++ code: std::string input1, input2, input3; std::cout << "Enter Input 1: "; std::cin >> input1; std::cout << std::endl << "Enter Input 2: "; std::cin >> input2; std::cout << std::endl << "Enter Input 3: "; std::cin >> input3; If for input1 I enter something like "Good day neighbors" then input1 is set to "...

C->C++ Automatically cast void pointer into Type pointer in C++ in #define in case of type is not given (C-style) [MSVS]

Hi! I've used the following C macro, But in C++ it can't automatically cast void* to type*. #define MALLOC_SAFE(var, size) { \ var = malloc(size); \ if (!var) goto error; \ } I know, I can do something like this: #define MALLOC_SAFE_CPP(var, type, size) { \ var = (type)malloc(size); \ if (!var) goto error; \ } But ...

Managed C++ Wrapper for Unmanaged Static Library with static variables hangs

The explanation of the problem is a little long-winded, please bear with me. I have an unmanaged C++ static library that is used for financial application. It has business day conventions, swap conventions, bond conventions, etc. Most of the conventions rely on static global variables, which are initialized on first use. The library als...

Qt:How to tell Qmake to include ws2_32 in visual studio project

Hello all im using some third party lib in side Qt application but i like the *.pro file and the QMAKE to be the default . how can i tell qmake (what to write in the *.pro file ) to include in my visual studio project the windows ws2_32 socket lib in the include lib dir ? ...

Converting HLOCAL to LPTSTR

How is should a HLOCAL data type be converted to a LPTSTR data type? I'm trying to get a code snippet from Microsoft working, and this is the only error, of which I'm not sure how to resolve: // Create a HDEVINFO with all present devices. hDevInfo = SetupDiGetClassDevs(NULL, 0, // Enumerator 0, DIGCF_PRESENT | DIGCF_ALLCLAS...

C++ -- Why I can return an int for class Month

Hello all, Saw the following code snippet and I have problems to understand how it works. class Month { public: static const Month Jan() { return 1; } ... static const Month Dec() { return 12; } int asInt() const { return monthNumber; } private: Month(int number) : monthNumber(number) {} const int monthNumber; ...

Parsing escaped strings with boost spirit

I´m working with Spirit 2.4 and I'd want to parse a structure like this: Text{text_field}; The point is that in text_field is a escaped string with the symbols '{', '}' and '\'. I would like to create a parser for this using qi. I've been trying this: using boost::spirit::standard::char_; using boost::spirit::standard::string; usi...

A C++ Equivalent to PHP's fgets()?

Essentially what I'm looking for is a function with the following prototype: string getln(istream); All I need it to do is work like PHP's fgets(), that is, take an input stream as a parameter and return the next line from the stream. I feel like my current approach is somewhat bulky for creating a temporary variable each time it's call...

Out parameters and pass by reference

I have joined a new group that has coding guidelines that (to me) seem dated. But just rallying against the machine without valid backup is not going to get me anywhere. So I am turning to SO to see if we can up with rational reasons for/against (hey I may be wrong in my option so both sides of the argument would be appreciated). The g...

Get current color

Im using glColor4f(1.0f, 1.0f, 1.0f, alpha_); to set transparency to primitives I'm drawing. However I'd like to be able to read the current opengl alpha value. Is that possible? e.g. float current_alpha = glGetAlpha(); //??? glColor4f(1.0f, 1.0f, 1.0f, alpha_*current_alpha); ...

Detecting an unplugged capture device (OpenCV)

I'm attempting to detect if my capture camera gets unplugged. My assumption was that a call to cvQueryFrame would return NULL, however it continues to return the last valid frame. Does anyone know of how to detect camera plug/unplug events with OpenCV? This seems so rudimentary...what am I missing? ...

Using templated custom wxEvent with wxEvtHandler::Bind

In the following code I do the following: I create a new template wxCommandEvent class that holds some payload specified by the template. I then subclass a wxStringPayloadEvent class. Finally I create an example app that simply issues a wxStringPayloadEvent and then the event handler gets triggered and displays the payload in a message...

Python and win32 API - using a C file

With ActiveState Python comes a win32api module. I need to implement something that monitors directories recursively for file-changes. Actually there's an example in the MSDN library using C. I don't know whether the win32api bindings are sufficient for something like this. Can I import this into a Python project? Because it may be easi...

add Qt to existing Visual Studio c++ project

hey there! I've got an existing Visual Studio c++ project. It creates a mainwindow using GLUT and got a right-click menu (also using glut) all I want to do now is to open a second window used as property inspector to display and change some values. Everyone recommends using Qt for GUI stuff - but all the tutorials I find regard either...

Is there a library that can compile C++ or C

Hi There, I came here to ask this question because this site has been very useful to me in the past, seems to have very knowledgeable users who are willing to discuss a question even if it is metaphysical at times. And also because googling it did not work. Java has a compiler and then it has a JDT library that can compile java on the ...

How do I run a python file that is read into a std::string using PyRun

I am embedding Python into my C++ program, and have used PyRun_SimpleString quite effectively but now am having trouble. What I have done is loaded a python.py file a std::string but am now having troubles running it. PyRun_SimpleFileEx didn't seem to do the trick either so some help would be great! std::string content; if(!ail...

C# calling C++ method that returns a pointer. Explain memory management.

Can someone explain what exactly is happening at a low level / memory management perspective on the 2 C# lines in "Main" in the following? C++ Code (unmanaged): #define DLLEXPORT extern "C" __declspec(dllexport) DLLEXPORT MyClass* MyClass_MyClass() { return new MyClass(); } DLLEXPORT void MyClass_setName(My...

C++ friend function references

I have this situation (two classes with two different header files): b.h #include "a.h" class B { friend void B* A::create(void); private: int x; }; a.h #include "b.h" class A { public: void B* create(void); ... }; basically class A creates "B" objects. I want to give the creation function create() acce...