c++

How to execute C++ code without compiling it?

In order to pass some code to an application created with C++ I have used a C++ open source code which acted as a TCL interpreter. So I could create a file, in there put some XML data and in some tags some TCL code. Finally it is possible to read the file configure some structure and execute the TCL script snippets from the XML file in a...

Getting current time of a different timezone using C++

How do i get the current time of a different time zone? Example, i need to know the current time in Singapore where as my system is set to PT time. ...

C++: Check if bmp file is legit

Hi guys and gals! I'm using C++ (Visual Studio) and I want to check if a .bmp file is legit (not some renamed virus.exe) before the user can share it over the internet with other users using my application. I'm using DirectX 2d rendering and boost framework. Is there an (easy?) way to validate bitmaps? Thanks. ...

C++ - downcasting a diamond shape inherited object without RTTI/dynamic_cast

Hi all! I'm currently working on integrating a third-party package that uses lots of RTTI stuff on a non-RTTI platform (Android). Basically, I did my own RTTI implementation but I'm stuck on a problem. The issue is that a lot of classes are having the diamond inheritance problem since all the classes derive from the same base class (ob...

dynamic memory allocation

here is example how Pointers are used to store and manage the addresses of dynamically allocated blocks of memory #include <iostream> #include <stdio.h> using namespace std; struct Item{ int id; char* name; float cost; }; struct Item*make_item(const char *name){ struct Item *item; item=malloc(sizeof...

Can you programmatically interact with Component-Based Servicing (TrustedInstaller)?

I have been trying to find out how to programmatically interact with Component-Based Servicing (CBS) which is basically the TrustedInstaller and other services. With the goal to be able to query CBS for what packages are installed and get any other information they may have on installed packages. Here is a link to a overview of it. Bas...

How do I get the size of a file after ftp'ing ?

CFtpFileFind finder(mConnection); found = finder.FindFile("*.log"); while (found) { found = finder.FindNextFile(); wsprintf(fileInfo, "%s", finder.GetFileName()); //need file size of this .log //no member function for this in CFTPFileFind class? } EDIT Answer finder.GetLength(); ...

In C++, in the definition of functions, the argument identifiers are optional. In which scenario this feature could be useful?

int foo(int){ ... } Any ideas? ...

CGAL half-edge data structure

Hello, I am trying to learn how to use half-edge data structures in CGAL, and I am confused by the following sample of code provided on their website #include <CGAL/HalfedgeDS_default.h> #include <CGAL/HalfedgeDS_decorator.h> struct Traits { typedef int Point_2; }; typedef CGAL_HALFEDGEDS_DEFAULT<Traits> HDS; typedef CGAL::HalfedgeDS...

MSVC 2010 templates compiler problem

1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\list(1194): error C2451: conditional expression of type 'void' is illegal 1> Expressions of type void cannot be converted to other types 1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\list(1188) : while compiling class template member fu...

How to deal with failed constructor when throwing exceptions is not allowed

I was looking at the Google C++ Style Guide and they have decided not to use exceptions in C++ code, relying on return values instead. My question is: How do you handle failure in constructors in this case, since you cannot return a value in those. Thanks! ...

writing unmanaged DLL consumable by C#/.NET code

I need to implement a small part of my application logic in native code. To test PInvoke capabilities I created a simple solution with an unmanaged C++ Win32 Dll and a WPF project that consumes the dll functions using PInvoke. The problem I run into is that i receive exception about "unbalancing the stack" and "possible signature mismatc...

Using popen to write in a pipe only send data when pipe is closed

I'm using popen to open a write pipe and send commands to an application. The problem is that the commands are only sent to the application when I close the pipe. FILE * fp = open(target_app, "w"); fwrite(command, 1, command.size(), fp); getchar(); //wait for a key, because I don't want to terminate the application pclose(fp); // at thi...

array of arrays of different size

Hello, I've some code that produces a set of tr1::array of different sizes, but same type, like array<int, 2> array<int, 4> array<int, 6> The number of these arrays, and their sizes, are given in compile time, so I know exactly how many of them there will be and how's big each one (but they may be different). Problem: I would like to...

can OpenGL do this?

I'm making an application that draws shapes and I use a camera to draw in other places. Basically, let's say I have a 4x3 rectangle and would like to use glgetpixels to get all the pixels for something that is 1024x768, but my monitor might not support that resolution. How can I render something bigger than the monitor. I do this so I ca...

Unicode, char pointers and wcslen

Hi, I've been trying to use the cpw library for some graphics things. I got it set up, and I seem to be having a problem compiling. Namely, in a string header it provides support for unicode via #if defined(UNICODE) | defined(_UNICODE) #define altstrlen wstrlen #else #define altstrlen strlen Now, there's no such thing as wstrlen o...

General formula to generate a cubic bezier elliptical arc?

How could I implement in C a simple way to generate the 2 missing control points for an elliptic arc given a start and end point? I don't need fancy error estimation, just something that can take points A and D and generate the control points B and C for the elliptical arc where I can then use the cubic bezier interpolation algorithm to ...

C++ Set object member as reference/pointer of member of a different object?

(I'm not sure if that title is worded correctly, as I'm still new to C++) I have two classes, loosely represented here: class SuperGroup { public: LayoutObj theLayout; } class SomeClass { public: LayoutObj myLayout; SuperGroup myGroup; } During SomeClass's constructor, I want to set myGroup.theLayout to be pointing to So...

Will std::multimap preserve the insert order if the key of 2 elements equal to each other?

I am wondering whether this is true? If it is, is this behavior guaranteed by the c++ standard? ...

Are the elements in a std::map guaranteed to be ordered?

Is this just an implementation side effect (red-black tree) or the order is guaranteed by the c++ standard? ...