使用 astyle 在一行上格式化C++中的嵌套命名空间
Format nested namespaces in C++ on one line using astyle
在我公司的编码约定中,我们将嵌套命名空间格式化为一行。例如:
namespace Foo { namespace Bar {
...
}} // Foo::Bar
我正在尝试使用 astyle 强制执行这种样式,但在文档中找不到任何内容 http://astyle.sourceforge.net/astyle.html
当我运行以下 astyle 命令时(忽略不相关的选项(
astyle --style=allman --add-brackets --align-reference=name --align-pointer=name --attach-namespaces --pad-header --pad-oper --unpad-paren -n <filename>
我最终将每个嵌套命名空间放在单独的行上,如下所示:
namespace Foo {
namespace Bar {
...
}
}
尝试修改astyle
源代码。找到方法ASFormater::isOkToBreakBlock
并在开头插入:
if (isBraceType(braceType, NAMESPACE_TYPE))
return false;
确保它不会破坏整个格式。
附言希望astyle
团队能够听到并使用选项进行正确的更改。
相关文章:
- C++格式化输出问题
- 格式化浮点值:返回默认值
- 自动格式化程序> >更改为>>
- 如何从C++中的格式化字符串派生整数?
- 将从格式化文本文件读取的文本数据存储到链表
- 在不使用系统的情况下从C++应用程序格式化 Linux 中的 SD 卡
- 高精度双精度的 Sprintf 格式化问题
- 如何在 c++ 中格式化和访问 2D 矢量数组中的数据
- 叮当格式化程序多行格式配置错误
- 如何格式化我的文本文件以使其不会一遍又一遍地重复同一行?
- 从函数(不抛出函数)返回异常以进行消息格式化?
- 从格式化输入操作中获取读取字符数
- 如何从标准输入中检测格式化输入错误?
- 无法从 spdlog 中格式化参数
- 格式化时间 c++ dd/mm/yyyy hh:ss.
- 如何正确格式化csv文件?
- 格式化sqlite3_exec结果
- 使用 std::locale 格式化法语数字时无效的 UTF-8 数据
- C++逐步格式化字符串
- 如何使用 clang 格式格式化地图初始化?