如何在Netbeans代码模板中将类名称用作变量?

发布于 2025-02-12 22:48:49 字数 611 浏览 2 评论 0原文

您好,我正在尝试编写C ++代码模板,该模板允许使用.h或.cpp文件名作为名称值。

例如,我有classa.cpp:

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
#include <cstdlib>
#include <cstring>

#include "ClassA.h"

ClassA::ClassA() {

}

我使用netbeans IDE编写了一个代码模板:

${TIP default = "void"} ${MET}( ${ARGS default = "void"} ); 

${TIP} ${CLASS default = "Cls"}::${MET}(${ARGS} ) {
   ${selection}${cursor} 
}

使用此模板我可以更改所有名称和类型,但是我想避免写$ {class default =“ cls”}并获得“ classa”(或当我使用此模板代码时,.h和.cpp文件的任何名称)而不是“ CLS”。

我该怎么做?

Hello I'm trying to write a C++ Code Template which allows use .h or .cpp file name as a name value.

For example I have ClassA.cpp:

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
#include <cstdlib>
#include <cstring>

#include "ClassA.h"

ClassA::ClassA() {

}

I wrote a Code Template using NetBeans IDE:

${TIP default = "void"} ${MET}( ${ARGS default = "void"} ); 

${TIP} ${CLASS default = "Cls"}::${MET}(${ARGS} ) {
   ${selection}${cursor} 
}

Using this template I can change all names and types, but I want to avoid write ${CLASS default = "Cls"} and get "ClassA" (Or any name which .h and .cpp files have when I use this template code) instead of "Cls".

How I can do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文