c++

google-test: code coverage

Is it possible to get code coverage done by tests using google test framework? ...

Equivalent for TzSpecificLocalTimeToSystemTime() on win2k?

One of our developers used this call: TzSpecificLocalTimeToSystemTime() but unfortunately we cannot keep it as the code must work on Win2K as well. What alternatives are there for similar functionality? ...

Lining up Qt GroupBox labels

Is there an easy way to ensure that controls in different groupboxes on a Qt dialog line up correctly using layouts? If not, is there a way to line them up using code in the dialog's constructor? For example, here is a form with two groupboxes containing controls that are laid out using a grid: Here is how I want it to look: Note...

Answer to a practice interview question

I'm just going through a bunch of C++ interview questions just to make sure there's nothing obvious that I don't know. So far I haven't found anything that I didn't know already, except this: long value; //some stuff value &= 0xFFFF; The question is "what's wrong with this code?" And hints that it's something to do with target archite...

Convert Regular Expression pattern from Javascript to PCRE (perl)

Hello. This is my javascript regex pattern: url = "http://www.amazon.com/gp"; hostname = /^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?@)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??([^#]+)?#?(\\w*)/.exec(url) || []; // would return "www.amazon.com" the above regex extracting the hostname from a given url. I ...

Working with GNU regex functions in C or C++

Can anyone give me complete example program how to work with GNU regex functions in gcc C or C++ (http://docs.freebsd.org/info/regex/regex.info.GNU_Regex_Functions.html), with re_pattern_buffer, re_compile_fastmap? For example, translate this small Python program: import re unlucky = re.compile('1\d*?3') nums = ("13", "31", "777", "1...

How do I make a custom system wide mouse cursor animation?

I write software for the disabled. One of the problems is difficulty tracking the mouse pointer. I want to have the mouse cursor glow (or similar effect. Maybe water like ripples around it) when the user needs to locate it. How is this done? I know it's possible because it's used in a variety of software. ...

Using STL's list object

I want to create a list of queues in C++ but the compiler gives me some cryptic messages: #include <list> #include <queue> class Test { [...] list<queue> list_queue; [...] } Output: error C2143: syntax error : missing ';' before '<' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int...

PCRECPP (pcre) extract hostname from url code problem

I have this simple piece of code in c++: int main(void) { string text = "http://www.amazon.com"; string a,b,c,d,e,f; pcrecpp::RE re("^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?@)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??([^#]+)?#?(\\w*)"); if(re.PartialMatch(text, &a,&b,&c,&d,&e,&f))...

C++ / Linux - How to prevent paging for one program / process?

I don't know if SO or SF is the right place for that kind of question but I think it is something you could achieve with code. I have a program that requires much memory, like 2/3 of all the physical ram. After some runtime my operating system begins to swap the program to hdd. But I need the program to respond very fast all the time, s...

Noob at C++: how to do an associative array of object => value ?

I'm trying to create a global (singleton) class that can associate any type of object with an integer value. I was thinking of using a map<T*, int> variable, but was wondering if there was any other way to do it. UPDATE: Here is a prototype of my class. Let me know what I'm doing wrong ! It compiles and work fine, but I'm not sure if i...

help in displaying the sum of two matrixs (using linked lists)

hey there, Im having problems displaying my results in this program but the program compiles. Any idea as to what is going wrong?. The purpose of the program is to take two, 2 by 2 matrixes and add them to create the matrix called result. but when it comes to displaying the values in each matrix (A,B and result) it hangs. why does at the...

Why exception with this regular expression pattern (tr1::regex)?

Hi everyone, I came accross a very strange problem with tr1::regex (VS2008) that I can't figure out the reason for. The code at the end of the post compiles fine but throws an exception when reaching the 4th regular expression definition during execution: Microsoft C++ exception: std::tr1::regex_error at memory location 0x0012f5f4.....

[newb] C++ const iterator C2662

Hi All, Having problems iterating. Problem has to do with const correctness, I think. I assume B::getGenerate() should be const for this code to work, but I don't have control over B::getGenerate(). Any help is greatly appreciated. Thanks in advance, jbu Code follows: int A::getNumOptions() const { int running_total = 0; BL...

C++ Exceptions questions on rethrow of original exception

Will the following append() in the catch cause the rethrown exception to see the effect of append() being called? try { mayThrowMyErr(); } catch (myErr &err) { err.append("Add to my message here"); throw; // Does the rethrow exception reflect the call to append()? } Similarly, if I rewrite it this way, will bit slicing occur if ...

GC with C# and C++ in same solution

I have a solution consisting of a number of C# projects. It was written in C# to get it operational quickly. Garbage collections are starting to become an issuewe are seeing some 100 ms delays that we'd like to avoid. One thought was to re-write it in C++, project by project. But if you combine C# with unmanaged C++, will the threads...

What's a good directory structure for larger C++ projects using Makefile ?

What's a good directory structure for larger C++ projects using Makefile ? This is how my directory structure looks at the moment: lib/ (class implementations *.cpp) include/ (class definitions *.h) tests/ (main.cpp for quick tests) Now, I'm not sure how my Makefile should look like... it doesn't seem to work when .cpp files and .h f...

After I build my Huffman tree the root's weight is 700k when I've read through 5megs of data.

// Huffman Tree.cpp #include "stdafx.h" #include <iostream> #include <string>//Necessary to do any string comparisons #include <fstream> #include <iomanip> #include <cstdlib>//for exit() function using namespace std; class BinaryTree{ private: struct treenode{ char data; int weight; treenode *LChild; ...

Calling member level functions from a dynamic link library using pinvoke in C#?

How would I use DLLImport pinvoke to invoke a function i wrote in a class in an unmanaged DLL? It always throws that the entry point doesn't exist in the dll. EX: class Foo { int __declspec(dllexport) Bar() {return 0;} }; Bar is in the Foo class. when I use pinvoke as: [DLLImport("Test.dll")] public static extern int Bar(); When ...

How do I use Luabind and C++ to create an asset managing class?

I've made countless attempts to get this working, but everything I do gives me run-time errors. I've been trying to make asset managers to manage content for my game engine, and I'm using lua and luabind for my scripting. Getting everything to compile, binding classes and variables, and getting basic variables back from lua have been no ...