c++

Reverse iteration with an unsigned loop variable

Hi all, I've been discussing the use of size_t with colleagues. One issue that has come up is loops that decrement the loop variable until it reaches zero. Consider the following code: for (size_t i = n-1; i >= 0; --i) { ... } This causes an infinite loop due to unsigned integer wrap-around. What do you do in this case? It seems ...

shared object can't find symbols in main binary, C++

I'm experimenting with making a kind of plugin architecture for a program I wrote, and at my first attempt I'm having a problem. Is it possible to access symbols from the main executable from within the shared object? I thought the following would be fine: testlib.cpp: void foo(); void bar() __attribute__((constructor)); void bar(){ fo...

How do you get info for an arbitrary time zone in Windows?

Ideally, what I'd like to be able to do is take the name of a time zone and ask Windows for its corresponding time zone info (offset from UTC, DST offset, dates for DST switch, etc.). It looks like Windows uses a TIME_ZONE_INFORMATION struct to hold this sort of info. So, presumably, I want a function which takes a string with the time z...

zip file encryption

I'm trying to block zip file open... How to block it.... Is there any other methods except modifying zip header info. My rosources are packed with zip file but I don't want to open it to users... Please let me know it ...

Where should non-member operator overloads be placed?

I want to overload operator<< for my class. Should I add this overloaded definition to the std namespace? (since the ostream operator<< is part of the std namespace) Or should I just leave it in the global namespace? In short: class MyClass { }; namespace std { ostream& operator<< ( ostream& Ostr, const MyClass& MyType ) {} } O...

c++ command line software

Alright, so I've "mastered" the idea of GUI programming in Java and decided I would not touch anything related to windows/linux UI in c++. I've looked at a few UIs programmed in c++ and a few classes already and decided it's not for me. But on that note, what about command line interfaces. I'm currently working on a shipping computer at ...

Are C++ initializers called in Objective-C synthesized properties?

Are C++ initializers called in Objective-C synthesized properties? Meaning if I write a custom initializer for creation from another object of the same type (C++) does the synthesized property setter call that initializer? ...

How to handle unicode character sequences in C/C++ ?

What are the more portable and clean ways to handle unicode character sequences in C and C++ ? Moreover, how to: -Read unicode strings -Convert unicode strings to ASCII to save some bytes (if the user only inputs ASCII) -Print unicode strings Should I use the environment too ? I've read about LC_CTYPE for example, should I care abou...

Rvalue reference

While trying to understand Rvalue references from here, I am unable to understand two things If there are N strings in the vector, each copy could require as many as N+1 memory allocations and [...] What is this +1 in 'N+1'? 2.How the author suddenly arrives at the below guideline Guideline: Don’t copy your function ...

Are there any RIA Frameworks which allow me to use C++?

I have written an simple applications in C++, and I need to connect with any RIA just for viewing the process ... is there is any good RIA based on C++ ...

Using x64 dll in x86 application

I have a DLL that needs to operate large ammounts of memory and must be x64 to do that, but the application, which calls it is x86 and can not be converted to x64. COM is already used for interaction between application and the dll. Is it possible to use surrogate process for that purpose? I know that it is possible to do such a thing...

Help With SharedPreference, For Android Live Wallpaper

Ok well I need help adding settings to choose which texture to show you should be able to tell what I mean because there are already two set up. i have the gui for the settings set up along with the activity I just can't figure out how to implement it. If you can help me I'll credit you in the app in the settings and the market post. Alo...

How to create .txt file in Temporary Internet folder ?

Hi, I want to create a .txt file inside Temporary Internet folder.For that I am reading registry.I am reading HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Cache. But this give me path **%USERPROFILE%\Local Settings\Temporary Internet Files**. Here I need a absolute path like C:\Documents and Se...

How can I get the right click event object file name?

I created a ATL/COM project, and implement the IShellExtInit interface. In the Initialize method, I use the DrapDropFile function to get the file names of the files whose selected in the folder. e.g. 1.In the folder C:\WINDOWS\MyFolder\ contains the files: a.png, b.bmp, c.jpg 2.Right click the "b.bmp". 3.In the Initialize method, I...

Segmentation fault in std::map::insert(...)

hello, i've used search but i didn't find answer satisfying me... so.. this is chunk of code: //VoteContainer.h typedef uint32_t order_id_t; typedef int driver_id_t; class Vote { public: enum DriverVoteResponse {YES, NO, TIMEOUT}; struct DriverResponse { driver_id_t dri...

MSVC 10 + Luabind + std::vector == refuse to compile.

So, I have a code, that compiled on MSVC 9 and some previous (dunno how far back it goes...), GCC, MingW, GCC on Mac... But one line, does not compile on MSVC: class_< vector<unsigned int> >("LayerList") .def(constructor<>()) .def("GetCount", &vector<unsigned int>::size) .def("Get", &NumberGet) .def("Add", &vector<unsigned int>::push_...

What is the meaning of char (& test(...))[2]

What is the meaning of the following declaration: char (& test(...))[2]; I pasted it inside a function body as is and it compiles all right. I don't know what I can do with it but it passes the compilation. I've encountered something similar in this answer. ...

c++ Url Parser using boost regex match

Hello, how can i parse an url in c++ with boost regex like i have an url http://www.google.co.in/search?h=test&amp;q=examaple i need to split the base url www.google.com and then query path search?h=test&q=examaple ...

How to make a QGraphicsTextItem clickable ?

In the "About box" of my software, I used a QGraphicsTextItem to show the about-text. This text contains hypertext links (in the form of: <a href="http://some.random.site"&gt;link&lt;/a&gt;). The item shows up properly (hypertext links are blue and underlined). However, when I click on them, nothing happens. Here is how I created the...

Sending name/value pairs using HttpOpenRequest and HttpSendRequest

I am using HttpOpenRequest to send data of the form /path?data=xyzzy. However xyzzy can be very large, 100s of k at times, and on certain machines HttpOpenRequest fails with error 122 (ERROR_INSUFFICIENT_BUFFER) According to Microsoft kb 208427 the Maximum URL length is 2,083 characters in Internet Explorer but it also states 'However...