简体   繁体   中英

Converting MFC classes to the C++ standard library

I'd doing some research to see if it's possible to convert an MFC-based Windows app to an HTML5 browser-based app. However, I'd like to keep some non-visual classes in a separate library that can be called from the browser or used by other applications, as required. Mostly this non-visual code is CObject-derived data classes that use strings, collections, etc. I'm not really familiar with the C++ Standard Library, would it be possible to post most of my existing of code to it without too many problems? Also, if I wanted to port the serialization code could I use something like the Boost serialization library as an extension to the standard library?

Are there any tools out there that would help with this type of conversion, and identify potential problems?

It is certainly possible to replace a UI layer of an application with a different UI technology. Exactly how difficult this will be will depend on how well separated the layers are in the existing application architecture (ie it's easier to replace the 'V' of an MVC app then an app where the model is mixed with the presentation logic)

Keeping non-visual MFC code in separate libraries (typically DLLs) is common place, but this usually implies that the application will continue to be an MFC application.

There are a few unusual things mentioned in your post:

  1. You are talking about replacing desktop UI (MFC) with web UI ("HTML5"). This is still somewhat unusual, unless you are also transitioning to a web application, and placing the non-visual code on the server. That said, if you search on "using html5 for desktop apps" you'll find a lot of tools and discussions. For some apps, coding a UI within the constraints of a browser is still too limiting (eg limits on top-level window management and placement, etc.). If your goal is to have a more portable desktop application, you may want to investigate desktop UI libraries (eg Qt, wxWindows, etc.)
  2. The C++ standard library and MFC string and container classes are significantly different, aside from offering some of the same general data structures. AFAIK there are no automated tools to convert from MFC to C++ standard library. Again, if your goal is portability, this is a sensible step, and you can write some wrapper classes around the C++ implementation to help adapt your code (although this can be a good opportunity to re-implement classes, or even entire libraries.)

A not-so-unusual thing is to consider using Boost libraries in addition to the standard library - they are high-quality libraries, and can save you a lot of time over rolling your own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM