[译]VisualClassBuilder-免费代码生成工具
By robot-v1.0
本文链接 https://www.kyfws.com/applications/visualclassbuilder-free-code-generation-tool-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2180 个词 阅读量 0[译]VisualClassBuilder-免费代码生成工具
原文地址:https://www.codeproject.com/Articles/17668/VisualClassBuilder-Free-Code-Generation-Tool
原文作者:darkoman
译文由本站 robot-v1.0 翻译
前言
A free C++ code generator tool with source code.
一个带有源代码的免费C ++代码生成器工具.
介绍(Introduction)
本文是关于一个免费的C ++代码生成器工具的.代码生成器按照其名称所说:生成基于对象模型(如UML类图)的源代码,该对象模型表示类的逻辑结构.它还可以帮助您使用图形用户界面更快地开发应用程序并更改其结构内部的内容.(This article is about a free C++ code generator tool. The code generator does what its name says: it generates source code based on an object model (like a UML class diagram), which represents the logicalstructure of your classes. It also helps you develop your applications faster and change things inside their structure, using a graphical user interface.)
使用应用程序(Using the Application)
该提交是一种工具,因此此处将不讨论源代码.相反,我将讨论如何使用该工具.(This submission is a tool, so the source code will not be discussed here. Instead, I will discuss how to use the tool.)
代码生成器具有图形用户界面,通过它可以在屏幕上构建和操作简单的UML类定义.要插入新类,请选择(The code generator has a graphical user interface by which you can build and manipulate simple UML class definitions on the screen. To insert a new class, select the)**插入->类…(Insert->Class…)**从主菜单中选择.新的类对象将出现在屏幕上.您可以通过拖动将其放置在任意位置.类似地,要插入新结构,请选择(option from the main menu. The new class object will appear onthe screen. You can place it wherever you want by dragging it.Similarly, to insert a new struct, select)**插入->结构…(Insert->Struct…)**从主菜单中,新的struct对象将出现在屏幕上.(from the main menu and the new struct object willappear on the screen.)
要更改班级的设置,请双击班级对象.将出现以下对话框:(To change a class’s settings, double click on the class object. The following dialog box willappear:)
在这里,您可以更改类的名称及其标题和实现文件.您还可以添加authorinformation和简短的类描述.(Here, you can change the names of the class and its header and implementation files. You can also add authorinformation and a short class description.)
在下一页上,您可以将成员变量和属性添加到您的类中:(On the next page you can add member variables and properties to your class:)
C ++开发人员可以轻松识别此选项卡页面上的设置,因此在本文中,我不会通过详细解释所有设置来浪费它们的空间.有趣的选择是(The settings on this tab page will be easily recognizable by C++ developers, so I will not waste space in this article by explaining them all in detail. The interesting option here is the)声明为财产(Declare as property)复选框,启用后将导致一对访问器方法((checkboxwhich, when enabled, will cause a pair of accessor methods () GetPropertyName()
和(and) SetPropertyName()
),以便直接将读/写值添加到成员变量.在添加属性之前,必须为该属性指定一个名称.() to be added to read/write values directly to the member variable. You have to specify a name for the property before you add it.)
下一个标签页用于类方法:(The next tab page is for class methods:)
正如可以添加成员变量一样,也可以通过在此选项卡页面上声明它们来添加类方法.默认的方法主体将在类实现文件中生成.(Just as you can add member variables, you can also add class methods by declaring them on this tab page. A default method body willbe generated in the class implementation file.)
您还可以更改其他班级设置:(There are also additional class settings that you can change:)
在这里,您可以将继承父级添加到此类(派生当前类的类),包括MFC precomededheader,以及打开/关闭注释生成.注释很重要,因为以后代码可能变成一团糟,如果不对创建的内容添加说明,您将找不到所需的内容.(Here you can add inheritance parents to this class (the classes that current class is derived from), include MFC precompiledheaders, and turn on/off comment generation. Comments are important since the code can turn into a real mess later,and you will not be able to find what you need if you don’t add explanations to what you create.)
使用结构比使用类更简单,因此我不会花时间解释它.(Working with structs is simpler than working with classes so I will not take the time to explain it.)
使用结果(Using the Results)
构建类图后,您可以选择(After you build your class diagram you can select)**构建->生成文件(Build->Generate files)**从主菜单中选择"选项",VisualClassBuilder将在默认输出目录中为您生成所需的C ++文件.从那里,您可以将它们添加到Visual Studio(或其他)项目中.(option from the main menu and VisualClassBuilder will generate the required C++ files in the default output directory for you. From there, you canadd them to your Visual Studio (or other) project.)
另外,您可以通过选择(Also, you can print the class diagram you have built by selecting)**文件->打印(File->Print)**从主菜单.要保存您的工作,请使用(from the main menu. Tosave your work, use)文件->保存(File->Save).要加载保存的项目,请使用(. To load a saved project, use)文件->打开(File->Open).(.)
兴趣点(Points of Interest)
我需要一个类似这样的工具来加快我在使用类似类结构的不同项目上的工作,从而避免多次编写相同的源代码.(I needed a tool like this one to speed up my work on different projects that use a similar class structure, so that I could avoidhaving to write the same source code multiple times.)
VisualClassBuilder v1.0(VisualClassBuilder v1.0)特征:(features:)
- 类生成(Class generation)
- 结构生成(Struct generation)
- 类继承支持(Class inheritance support)
- MFC预编译头支持(MFC precompiled header support)
- 评论生成(Comments generation)
- 项目保存/加载(Project saving/loading)
- 类图打印(Class diagram printing)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 WinXP Win2003 Windows Win2K MFC Visual-Studio Dev 新闻 翻译