c++

Confused about use of 'HANDLE' in piece of Visual C++ code for Real-Time IIS 7.0 Event Logging

I'm relatively new to Visual C++. I'm trying to build a module to consume log events generated by the IIS 7.0 server in order to be able to analyze these logs in real-time. I found a Microsoft article which provides code that accomplishes the real-time capture: http://learn.iis.net/page.aspx/581/advanced-logging-for-iis-70---real-ti...

Thread-safe lazy get and release

Hello All, I'm running into kindof an annoying problem and would need some advice... Let's say I have a bunch of small MyObject's, that can construct bigger MyExtendedObject's. MyExtendedObject's are big and CPU consuming so construction is lazy, and I try do remove them from memory as soon as possible: MyExtendedObject * MyObject::Ge...

Ctor Initializer: self initialization causes crash?

I had a hard time debugging a crash on production. Just wanted to confirm with folks here about the semantics. We have a class like ... class Test { public: Test() { // members initialized ... m_str = m_str; } ~Test() {} private: // other members ... std::string m_str; }; Someone changed the initialization to use c...

(C++) Looking for tips to reduce memory usage

Hi, I've got a problem with a really tight and tough memory limit. I'm a CPP geek and I want to reduce my memory usage. Please give me some tips. One of my friends recommended to take functions inside my structs out of them. for example instead of using: struct node{ int f() {} } he recommended me to use: int f(node x) {} ...

Causing a divide overflow error (x86)

I have a few questions about divide overflow errors on x86 or x86_64 architecture. Lately I've been reading about integer overflows. Usually, when an arithmetic operation results in an integer overflow, the carry bit or overflow bit in the FLAGS register is set. But apparently, according to this article, overflows resulting from divis...

boost::numeric::ublas::vector<double> and double[]

I'm using boost for matrix and vector operations in a code and one of the libraries I am using (CGNS) has an array as an argument. How do I copy the vector into double[] in a boost 'way', or better yet, can I pass the data without creating a copy? I'm a bit new to c++ and am just getting going with boost. Is there a guide I should rea...

conversion of uint8_t to sint8_t

Hi folks! What's the best way to convert an "uint8_t" to an "sint8_t" in portable C. That's the code I came up with .... #include <stdint.h> sint8_t DESER_SINT8(uint8_t x) ( return (sint8_t)((x >= (1u << 8u)) ? -(UINT8_MAX - x) : x); ) Is there a better/simpler way to do it? Maybe a way without ...

C++ and Embedded Python - NUL Terminated Strings

I'm working on embedding Python 2.6 into an existing c++ application. So far I have the Libraries linked in and am able to successfully initialize the Python Interpreter and can also transfer data to Python. I'm having trouble retrieving it, and hope someone can steer me the right direction. I'm working with this: Py_Initialize(); p...

Passing a const char* character string from unmanaged to managed

I have two communicating components - one managed, the other unmanaged. The managed needs to retrieve a character string from the unmanaged implementation (the same string or just a copy). I tried the following code. // Unmanaged code const char* GetTestName(Test* test) { return test->getName(); } // Managed wrapper [DllImport(DllN...

What documentation (, links and advices) could you offer me to create a testing library ?

Hi everyone, I'm thinking of designing my own Test library (framework) ->in c++ I am wondering if some of you have already designed there own (and what good advices, documentation they could offer me), decided to not do that (and why), What critics (and argue) you have against differents existing testing frameworks. I want to no more a...

How do I include a SQLite DLL in my C++ project?

I'm trying to add SQLite to my project via a DLL. I downloaded SQLiteDLL-3 from the download page, extracted its contents (a DLL and a .h file), and ran lib.exe on it to produce a .lib file. I then set the directory containing the .lib and the .dll files to be an Additional Library Directory, in the project settings, under Linker >> Gen...

Point in axis aligned rectangle test?

My rectangle structure has these members: x, y, width, height. Given a point x, y what would be the fastest way of knowing if x, y is inside of the rectangle? I will be doing lots of these so speed is important. ...

How to attach to a process as a debugger and query information?

I want to essentially write my own profiler which attaches to my process, freezes execution, inspects the state (current instruction pointer, some metadata, etc..) and write this information to a log. How do I get started with this? If I can get in and inspect this information and then resume execution, I can proceed from there. ...

Querying the status of a bit flag?

I am trying to parse some files that have a bitwise flag column. There are 11 bits in this flag and I need to find out, for each row in the files, what is the value of the 5th bit (1-based). ...

C++ shader question

Hello! Does somebody know where I can find a sample of shader (HLSL / CG / GLSL / Backend-independent) class? Of course, standard API (like D3DXEffect or same in GL) exists, but it's kind of ugly and not what I'm looking for. I'm looking for a high-quality interface design, not "just yet another implementation sample". Ideally someth...

How can I process several inputs at once using cin or getline(), while only pressing "Enter" once?

nodeType* buildSet() { nodeType *first, *newNode, *last; first = NULL; int num = 0; string input = ""; getline(cin,input); stringstream myStream(input); while(myStream >> num) // while(num != -999) { newNode = new nodeType; newNode->info = num; newNode->link = NULL; if(first ...

Programming Floaty Motion

Anyone have a good idea for a method of achieving random floaty motion? Like, just general smooth drift in a constrained area. This is what I tried: var rangeX = 100; var rangeY = 100; var gravity = .001; $('.floating').each(function() { $(this).data('startX', $(this).position().left); $(this).data('startY', $(this).position()...

c++ directx muliti textures

How can I set set more than one texture on a cube like the front of the cube has different texture from the back of it.... I tired to use the stages but it didn't work. for example, if i wanna make a dice i would have top would be 1 side be 2.............. D3DXCreateTextureFromFile(d3ddev, //Direct3D Device ...

C++: ptr_container comparison

How can I customize the comparison of elements in a ptr_container? Using a ptr_set, I would like to define a function that checks for equality of elements. However, defining bool operator==(const Foo& other) (or a friend function) does not work. It just won't be invoked, although boost's unordered containers, on the other side, are aw...

Does anyone know of a free H263 Plus Decoder codec

Hello Experts, I am working on audio/video app & looking for a H263Plus (not H263) decoder to be used in the project(C++ based) Regards, Chuks ...